PostSharp Documentation

The goal of PostSharp is to help improve the C# and VB languages so that you can deliver features faster and with fewer defects. PostSharp make design patterns and thread safely first-class citizen in VB and C#, allowing to write code at the right level of abstraction, with lower boilerplate code.

This manual is designed to help you learn how to use PostSharp, from basic to advanced techniques. It can be read from start to finish or used as a reference.

Get the right format

This documentation is available in several formats:

Format | Description
Online | The online documentation is always up to date and works with all modern web browsers.
CHM | The old good MSHelp format is still a favorite one. The CHM rendering contains both conceptual documentation and the API reference. You can download an older version of the PDF documentation.
PDF | The PDF format is optimized for print and is suitable for tablets. It does not contain the API reference. You can download an older version of the PDF documentation.
How to read this documentation?

Getting Started

If you just discovered PostSharp and want to get started, we recommend you start by reading PostSharp Overview. When you get at the topic Getting Started with PostSharp, continue on the right learning path according to your role and interests.

Reference Documentation

If you have already been using PostSharp for some time, you can use the current documentation as a reference and jump directly to the topic of interest. We suggest you have a look at What's New in PostSharp to make sure you are not missing the new features.

Copyright © SharpCrafters s.r.o. 2015. All rights reserved.

Send comments on this topic to PostSharp Technologies


Introduction

Introduction

This part is a general introduction to PostSharp.

It is composed of the following chapters.

Chapter | Description
PostSharp Overview | This chapter gives a general overview of PostSharp: what PostSharp actually is and what it can do for you, how it works and what are its principal components and technologies.
Getting Started with PostSharp | This chapter suggests a few learning resources according to your role in and the phase of the project.
What's New in PostSharp | This chapter lists the new features in each major and minor release.


PostSharp Overview

PostSharp Overview

This chapter gives a high-lever overview of PostSharp. It is composed of the following topics:

Topic | Description
What Is PostSharp | This topic describes how PostSharp can help your development team to deliver better software in less time.
PostSharp Components | This topic describes all components of PostSharp (Visual Studio extension, NuGet packages).
How Does PostSharp Work | This topic gives a high-level understanding of how PostSharp integrates with your build process.
Key Technologies | This topic positions PostSharp in the realm of metaprogramming, aspect-oriented programming, static analysis and dynamic analysis.


What Is PostSharp

What Is PostSharp

PostSharp is a 100%-compatible extension to the C# or VB languages that adds support for design patterns and thread safety. Teams that use PostSharp are able to deliver features with fewer lines of code and fewer defects.

In conventional object-oriented programming, technical concerns like threading, INotifyPropertyChanged or logging generally result in a large amount of boilerplate code. This boilerplate code is tangled with business code, and makes it more difficult to understand and modify the business meaning of the source code.

Boilerplate code is in fact instances of source code patterns. As any pattern, their instances exhibit a great amount of regularity and predictability. Any decent software developer would be able to explain to their colleague how to properly implement INotifyPropertyChanged. These implementation guidelines would form some sort of algorithm, expressed in natural language, that the colleague would execute. Most of the work would be repetitive and would only require a limited amount of creativity.

Algorithmic work is exactly what machines are good at, so why not offload it the compiler? This is exactly what PostSharp has been designed for. Traditional languages have concepts like classes, methods, fields, but they don't have any construct to represent patterns like the implementation of INotifyPropertyChanged.

PostSharp adds support for patterns into the C# and VB languages, allowing developers to work more productively at a higher level of abstraction and to avoid the bugs that stem from working with a large amount of technical details.

This section gives you an overview of the tools that PostSharp give you to automate the implementation and validation of patterns in your code:

  • Standard patterns
  • Thread safety patterns
  • Implementation of custom patterns
  • Validation of custom patterns
Standard patterns

PostSharp provides implementations of some of the patterns that are the most commonly found in .NET code bases:

  • INotifyPropertyChanged: see INotifyPropertyChanged.

  • Parent/child relationships: see Parent/Child Relationships.

  • Undo/redo: see Undo/Redo.

  • Code contracts: see Contracts.

  • Logging: see Walkthrough: Adding Detailed Tracing to a Code Base.

Example

The following code snippet illustrates an object model where INotifyPropertyChanged, undo/redo, code contracts, aggregation and code contracts are all implemented using PostSharp ready-made attributes.

C#
Copy
[NotifyPropertyChanged]
public class CustomerViewModel
{
   [Required]
   public Customer Customer { get; set; }

   public string FullName { get { return this.Customer.FirstName + " " + this.Customer.LastName; } }
}

[NotifyPropertyChanged]
[Recordable]
public class Customer
{
   public string FirstName { get; set; }
   public string LastName { get; set; }

   [Child]
   public AdvisableCollection<Address> Addresses { get; set; }

   [Url]
   public string HomePage { get; set; }

   [Log]
   public void Save(DbConnection connection)
   {
      // ...
   }
}

[NotifyPropertyChanged]
[Recordable]
public class Address
{
   [Parent]
   public Customer Parent { get; private set; }

   public string Line1 { get; set; }
}
Thread safety patterns

Multi-threading is a great demonstration of the limitations of conventional object-oriented programming. Thread synchronization is traditionally addressed at an absurdly low level of abstraction, resulting in excessive complexity and defects.

Yet, several design patterns exist to bring down the complexity of multi-threading. New programming languages have been designed around these patterns: for instance Erlang over the Actor pattern and functional programming over the Immutable pattern.

PostSharp gives you the benefits of threading design patterns without leaving C# or VB.

PostSharp supports the following threading models and features:

  • Immutable: see Immutable Threading Model.

  • Freezable: see Freezable Threading Model.

  • Actor: see Actor Threading Model.

  • Reader/Writer Synchronized: see Reader/Writer Synchronized Threading Model.

  • Synchronized: see Synchronized Threading Model.

  • Thread Unsafe: see Thread-Unsafe Threading Model.

  • Thread Affine: see Thread Affine Threading Model.

  • Thread Dispatching: see Dispatching a Method to Background and Dispatching a Method to the UI Thread.

  • Deadlock Detection: see Detecting Deadlocks at Runtime.

Example

The following code snippet shows how a data transfer object can be made freezable, recursively but easily:

C#
Copy
[Freezable]
public class Customer
{
   public string Name { get; set; }

   [Child]
   public AdvisableCollection<Address> Addresses { get; set; }

}

[Freezable]
public class Address
{
   [Parent]
   public Customer Parent { get; private set; }

   public string Line1 { get; set; }
}

public class Program
{
   public static void Main()
   {
      Customer customer = ReadCustomer( "http://customers.org/11234" );

      // Prevent changes.
      ((IFreezable)customer).Freeze();

      // The following line will cause an ObjectReadOnlyException.
      customer.Addresses[0].Line1 = "Here";
   }
}
Implementation of custom patterns

The attributes that implement the standard and thread safety patterns are called aspects. This terms comes from the paradigm of aspect-oriented programming (AOP). An aspect is a class that encapsulates behaviors that are injected into another class, method, field, property or event. The process of injecting an aspect into another piece of code is called weaving. PostSharp weaves aspects at build time; it is also named a build-time aspect weaver.

PostSharp Aspect Framework is a pragmatic implementation of AOP concepts. All ready-made implementations of patterns are built using PostSharp Aspect Framework. You can use the same technology to automate the implementation of your own patterns.

To learn more about developing your own aspects, see Developing Custom Aspects.

Example

The following code snippet shows a simple [PrintException] aspect that writes an exception message to the console before rethrowing it:

C#
Copy
[Serializable]
class PrintExceptionAttribute : OnExceptionAspect
{
    public override void OnException(MethodExecutionArgs args)
    {
        Console.WriteLine(args.Exception.Message);
    }
}

In the next snippet, the [PrintException] aspect is applied to a method:

C#
Copy
class Customer
{
    public string FirstName { get; set; }
    public string LastName { get; set; }

    [PrintException]
    public void Store(string path)
    {
        File.WriteAllText( path, string.Format( "{0} {1}", this.FirstName, this.LastName ) );
    }
}
Validation of custom patterns

Not all patterns can be fully implemented by the compiler. Many patterns involve a lot of hand-written code. However, they are still patterns because we want to follow the same conventions and approach when solving the same problem. In this case, we have to validate the code against implementation guidelines of the pattern. This is typically achieved during code reviews, but as any algorithmic work, it can be partially automated using the right tool. This is the job of the PostSharp Architecture Framework.

PostSharp Architecture Framework also contains pre-built architectural constraints that help solving common design problems. For instance, the InternalImplementAttribute constraint prevents an interface to be implemented in an external assembly.

See Validating Architecture for more details about architecture validation.

Example

Consider a form-processing application. There may be hundreds of forms, and each form can have dozens of business rules. In order to reduce complexity, the team decides that all business rules will respect the same pattern. The team decides that each class representing a business rule must contain a public nested class named Factory, and that this class must have an [Export(IBusinessRuleFactory)] custom attribute and a default public constructor. The team wants all developers to follow the convention. Therefore, the team decide to create an architectural constraint that will validate the code against the project-specific Business Rule Factory pattern.

C#
Copy
[MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
public class BusinessRulePatternValidation : ScalarConstraint
{
    public override void ValidateCode(object target)
    {
        var targetType = (Type)target;

        if (targetType.GetNestedType("Factory") == null)
        {
            Message.Write( targetType, SeverityType.Error,  "2001",
                           "The {0} type does not have a nested type named 'Factory'.",
                           targetType.DeclaringType,  targetType.Name );
        }

        // ...
    }
}

[BusinessRulePatternBalidation]
public abstract BusinessRule
{
  // ...
}


How Does PostSharp Work

How Does PostSharp Work

On a conceptual level, you can think of PostSharp as an extension to the C# or VB compiler. Practically, Microsoft's compilers themselves are not extensible, but the build process can be easily extended. That's exactly what PostSharp is doing: it inserts itself in the build process and post-processes the output of the compiler.

This topic contains the following sections.

  • MSBuild Integration
  • MSIL Rewriting
MSBuild Integration

PostSharp integrates itself in the build process thanks to PostSharp.targets, which is imported into each project using PostSharp by the NuGet installation script install.ps1. PostSharp.targets adds a few steps to the build process. The principal step is the post-processing of the compiler's output by PostSharp itself.

See Configuring Projects Using MSBuild for details.

MSIL Rewriting

PostSharp post-processes the compiler output by reading and disassembling the intermediate assembly, execute the required transformations and validations, and rewriting the final assembly to disk.

Although this might sound magic or dangerous, PostSharp's MSIL technology is stable and mature, and has been used by tens of thousands of projects since 2004. Other .NET products relying on MSIL transformation or analysis include Microsoft Code Contracts, Microsoft Code Analysis, and Microsoft Code Coverage.


PostSharp Components

PostSharp Components

PostSharp is composed of the following components:

Component Name

Component Kind

Description

PostSharp Tools for Visual Studio

Visual Studio Extension

This is the user interface of PostSharp. It extends the Visual Studio editor and provides a new menu, option pages, toolbox windows, and smart tags. PostSharp Tools for Visual Studio must be installed on each developer workstation but is not required on build servers.

PostSharp

NuGet Package

This is the core of PostSharp. It contains the PostSharp compiler, the MSBuild integration (the PostSharp.targets file is added to your projects upon installation of the PostSharp package), and the facade library PostSharp.dll, which exposes features to developers:

  • PostSharp Aspect Framework allows you to automate the implementation of other code patterns and address code repetitions that are specific to your own applications, or simply that are not available off-the-shelf in a pattern library. For more information, see sections Developing Custom Aspects and Adding Aspects to Code.

  • PostSharp Architecture Framework allows you to automate the validation of design pattern implementations, to enforce design intend, or simply to verify coding guidelines. The framework allows you to create constraint classes that encapsulate the validation logic and that can be applied to code artifacts. The framework provides tools to analyze the relationships between code artifacts and have access to the AST of method bodies. For more information, see section Validating Architecture.

PostSharp Common Pattern Library

NuGet Package

This package contains definitions and aspects that are shared by other pattern libraries, including:

  • Aggregatable pattern: see Parent/Child Relationships for details.

  • Basic definitions for threading aspects.

PostSharp Model Pattern Library

NuGet Package

This package contains the following features:

  • NotifyPropertyChanged aspect: see INotifyPropertyChanged for details.

  • Recordable pattern for undo/redo: see Undo/Redo for details.

  • Code contracts: see Contracts for details.

PostSharp Model Pattern Library (Controls)

NuGet Package

This package contains the undo/redo buttons for WPF. See Adding Undo/Redo to the User Interface for details.

PostSharp Threading Pattern Library

NuGet Package

This package contains all threading aspects and their infrastructure, including:

  • All threading models: see Writing Thread-Safe Code with Threading Models for details.

  • Thread dispatching aspects: see Dispatching a Method to Background and Dispatching a Method to the UI Thread for details

  • Deadlock detection: see Detecting Deadlocks at Runtime for details.

PostSharp Diagnostics Pattern Library

NuGet Package

This package contains the logging aspect. See Walkthrough: Adding Detailed Tracing to a Code Base for details.


Key Technologies

Key Technologies

PostSharp combines several technologies to leverage design pattern automation.

Metaprogramming

Metaprogramming is the writing of a program that analyzes and transforms itself or other programs. PostSharp internally represents a .NET program as a mutable .NET object model, so PostSharp can be considered a metaprogramming tool for .NET.

However, general metaprogramming (the ability to perform arbitrary modifications on a program) is a highly complex discipline. Although it may seem easy to perform simple modifications on simple programs, it is actually much more difficult to implement non-trivial transformations that work in all cases. Metaprogramming can result in a decrease in productivity when used improperly and it is very difficult, for application developers who lack specific training in compilers and metaprogramming, to use it properly.

Since general metaprogramming is too complex and too low level, we need a higher layer of abstraction that makes it easier and safer to express program transformations. Essential qualities of this abstraction layer would include safe composition of several transformations on the same declaration and restrictions on changing the program semantics.

Aspect-Oriented Programming fulfills these qualities as a disciplined approach to metaprogramming.

Aspect-Oriented Programming

PostSharp Aspect Framework is built on the principle of Aspect-Oriented Programming (AOP), a well-established programming paradigm, orthogonal to (and non-competing with) object-oriented programming or functional programming, that allows to modularize the implementation of some features that would otherwise cross-cut a large number of classes and methods.

We can confidently say that PostSharp is the most advanced AOP framework for Microsoft .NET.

For details on PostSharp's implementation of AOP, see Developing Custom Aspects.

Static Program Analysis

Static program analysis is the analysis of a program without executing it.

There are two families of static analysis tools:

  • Structural static analysis tools analyze the program's declarations and instructions, but do not attempt to understand the run-time behavior of the program. Microsoft Code Analysis belongs to this category.

  • Behavioral static analysis tools are based on iterative techniques like abstract interpretation, model checking or data-flow analysis. Behavioral static analysis is much more complex and time consuming. Microsoft Code Contracts belong to this category.

PostSharp contains tools for structural static analysis only. These tools consist in complete access of the System.Reflection model of the assembly being built, navigating through code relationships using the ReflectionSearch facility, and an expression tree decompiler.

The most important use case for static analysis in PostSharp is when writing aspects, in order to determine how the target program should be transformed. Any of the static analysis tools can be used to build aspects. This contrasts with other AOP implementation like AspectJ, which defines its own specific language (pointcut language) to select target declarations.

Aspects like NotifyPropertyChangedAttribute or threading models make advanced use of static analysis.

A secondary role for static analysis is architecture validation. This role is marketed as the PostSharp Architecture Framework, which defines a notion of architectural constraint. see Validating Architecture for more information.

Dynamic Program Analysis

Dynamic program analysis is the analysis of a program during its execution. Dynamic analysis is often used to detect issues early, before they cause bigger damage. A typical example of dynamic analysis is the one that occurs when an object is cast to a type: when the safety of the type conversion cannot be proved using static analysis, the type conversion must be verified at runtime, and an InvalidCastException is thrown when an invalid cast is detected.

PostSharp uses dynamic analysis to check the program against threading models. Since many model properties cannot be reliably verified at build time, they must be enforced at runtime. For instance, with the Synchronized threading model, accessing a field without owning access to the object would result in a ThreadAccessException. For details, see Writing Thread-Safe Code with Threading Models.

Another example of use of dynamic program analysis in PostSharp is deadlock detection. For details, see Detecting Deadlocks at Runtime.

In PostSharp, dynamic analysis is achieved by adding instrumentation aspects to the program.


Getting Started with PostSharp

Getting Started with PostSharp

A PostSharp implementation project is typically composed of three phases, in which three roles typically interact differently with the product. Each role requires different skills and knowledge. We have created a learning path for each of these roles. Depending on your team's organization, you may be involved in one or more roles.

Topic

Description

Getting Started: Selecting and Creating Aspects

In the first phase, the team learns about the concepts and abilities of PostSharp, and identify how it could fit into the application's design and architecture. The team selects the ready-made aspects that will be used in the application and, when no ready-made aspects can be used, it creates custom aspects or architecture rules.

People in this role are typically called architects, technical leads or senior developers. They must acquire an extensive knowledge of PostSharp and their decisions affect the whole team's productivity.

Getting Started: Installing and Deploying PostSharp

The next typical step is to deploy PostSharp into your development infrastructure and configure licensing. PostSharp works mostly out of the box for individual developers and small teams, but you may want some planning if you are responsible for a complex solution.

Getting Started: Using Aspects

Your team is finally ready to use PostSharp on a daily basis. At this point, typically, the team already knows which aspects will be used and when and how they will be used. As a developer who will use existing aspects, you don't need to invest a large amount of effort to learn PostSharp upfront. However, you will need to understand the aspects that have been selected by the team, and how to apply them to a code base.


Getting Started: Selecting and Creating Aspects

Getting Started: Selecting and Creating Aspects

The first step in the process of adopting PostSharp is typically to understand what the product can do for you and why you should use (or not use) its features. This activity is typically part of the architecture role.

As you will see, PostSharp offers a set of pre-built aspects implementing some of the most common patterns. As an architect, you will need to understand what these aspects can do for you and how they could fit and simplify your architecture.

However, standard patterns are only the top of the iceberg. To cover your specific needs, PostSharp includes construction kits that allow you to build you own pattern automation, namely the PostSharp Aspect Framework and the PostSharp Architecture Framework. Determining the need for custom aspects or architecture validation rules is typically also a part of the architecture role.

In a typical team, only a few people must be able to create custom aspects or architecture rules. These people must have a deeper understanding of PostSharp than the developers who will only use existing aspects and rules. This is why this skill set is included in the current section.

Note Note

When writing this section, we realized that the current documentation has some serious weaknesses regarding conceptual and architectural materials. This is why we are also referring to other resources hosted on our web site.

Introduction

Understanding the principles behind PostSharp will give you a foundation to build on. All patterns and techniques used by PostSharp relate back to this foundation.

Topic | Articles
About PostSharp | PostSharp Overview Requirements and Compatibility
More About Design Pattern Automation | Article: Design Pattern Automation
More About Aspect-Oriented Programming | Aspect-Oriented Programming in Microsoft .NET White Paper: Producing High-Quality Software with Aspect-Oriented Programming
Selecting pre-built pattern implementations

PostSharp offers a number of different pre-built patterns. The following documentation will outline how to use each of the available patterns.

Topic | Articles
General patterns | Contracts Parent/Child Relationships
User interface patterns | Understanding the NotifyPropertyChanged Aspect Understanding the Recordable Aspect
Multi-threading | White Paper: Threading Models for Object-Oriented Programming Detecting Deadlocks at Runtime Dispatching a Method to the UI Thread Dispatching a Method to Background
Diagnostics | Logging
Creating automation for custom patterns

PostSharp's built-in patterns won't cover all scenarios in your codebase that can benefit from AOP. Learn how to build custom patterns using the same foundational components as are used for the built-in patterns.

Topic | Articles
Aspects | Developing Custom Aspects
Architecture Validation | Validating Architecture


Getting Started: Installing and Deploying PostSharp

Getting Started: Installing and Deploying PostSharp

This section describes how to deploy PostSharp in different situations. Read it if you are responsible to integrate process into your build process.

Topic | Articles
Deploying to the Development Environment | Installing PostSharp Tools for Visual Studio Installing PostSharp Into a Project Deploying License Keys Uninstalling PostSharp
Deploying to the Build Infrastructure | Using PostSharp on a Build Server Restoring Packages at Build Time Using PostSharp with Visual Studio Online
Deploying to Production or End-User Devices | Deploying PostSharp to End-User Devices
Deploying to Large or Regulated Development Environments | License Audit Using PostSharp License Server Upgrading Large Repositories from a Previous Version of PostSharp


Getting Started: Using Aspects

Getting Started: Using Aspects

Using aspects requires much less training than creating new ones. In typical large teams, only a few developers or architects develop new aspects, while the rest of the team uses existing aspects. This section focuses on the skill set that you need to acquire if you have to be able to use PostSharp aspects but don't need to create your own.

In this session, we also assume that PostSharp has been properly deployed into your development and build environments.

Note Note

You can of course learn PostSharp as much as you want. The role of this section is to provide a short list of articles to minimize your learning curve and get you productive as quickly as possible, but this should not stop you from learning and experimenting more.

This topic contains the following sections.

  • Installing and upgrading PostSharp
  • Working with pre-built patterns
  • Working with Patterns
Installing and upgrading PostSharp

Every process has a starting point. Learn how to add PostSharp to your project so that you can get started with improving your codebase.

Topic | Articles
Install PostSharp to your machine | Requirements and Compatibility Installing PostSharp Tools for Visual Studio
Add PostSharp to a project and keep it up-to-date | Installing PostSharp Into a Project Upgrading from a Previous Version of PostSharp
Working with pre-built patterns

PostSharp offers a number of different pre-built patterns. You will need to learn those that will be used in your application.

Topic | Articles
Diagnostics | Logging
Code Contracts | Contracts
INotifyPropertyChanged | INotifyPropertyChanged
Aggregatable | Parent/Child Relationships
Disposable | Walkthrough: Automatically Disposing Children Objects
Undo and Redo | Undo/Redo
Threading Models | Writing Thread-Safe Code with Threading Models Freezable, Immutable, Actor, Reader/Writer Synchronized, Synchronized, Thread-Unsafe, Thread Affine Compatibility of Threading Models Opting In and Out From Thread Safety
Deadlock Detection | Detecting Deadlocks at Runtime
Dispatching Threads | Dispatching a Method to the UI Thread Dispatching a Method to Background
Architecture Validation | Restricting Interface Implementation Controlling Component Visibility Beyond Private and Internal
Working with Patterns

The following resources are for all aspects. You can save a great amount of time in learning to master them.

Topic | Articles
Adding aspects to several declarations | Adding Aspects Declaratively Using Attributes
Resolving Errors | Working with Errors, Warnings, and Messages


What's New in PostSharp

What's New in PostSharp

PostSharp has been around since the early days of .NET 2.0 in 2004. Since the first version, many features have been added to make PostSharp the most popular and by far the most powerful tool for aspect-oriented programming and design pattern automation in .NET.

This chapter contains the following sections:

  • What's New in PostSharp 4.1

  • What's New in PostSharp 4.0

  • What's New in PostSharp 3.1

  • What's New in PostSharp 3.0

  • What's New in PostSharp 2.1

  • What's New in PostSharp 2.0

  • What's New in PostSharp 1.5


What's New in PostSharp 4.1

What's New in PostSharp 4.1

The focus of PostSharp 4.1 was to broaden the set of supported platforms for both PostSharp, with the addition of Xamarin and Visual Studio 2015, and improvements in the support of Windows Phone and Windows Store.

PostSharp 4.1 includes the following improvements:

  • Support for Xamarin
  • Threading Pattern Library: support for Windows Phone and Windows Store
  • Support for Visual Studio 2015
  • PostSharp Assistant
Support for Xamarin

Xamarin has become an inseparable part of the .NET ecosystem and was the number-one feature request of the PostSharp community. PostSharp 4.1 makes it possible to build applications for iOS and Android using Xamarin.

Note that Xamarin applications must be built using Visual Studio. Xamarin Studio is not supported.

Threading Pattern Library: support for Windows Phone and Windows Store

Threading Pattern Library newly supports Windows Phone, Windows Store and Xamarin. This allows you to create thread-safe applications for both Windows and Windows Phone (both Silverlight and WinRT) in the same way as for desktop applications.

Support for Visual Studio 2015

PostSharp Tools for Visual Studio have been almost completely rewritten to take advantage of the new compiler family "Roslyn" at the heart of Visual Studio 2015. New features include integration with the light bulb (instead of the smart tag), live code diagnostics and a few refactorings.

PostSharp Assistant

PostSharp Assistant guides you when you are implementing various patterns from Pattern Libraries so that you don't miss any detail. For instance, it would point at relevant documentation articles or at pieces of code that need to be fixed.

PostSharp Assistant is supported in Visual Studio 2015.


What's New in PostSharp 4.0

What's New in PostSharp 4.0

The principal focus of PostSharp 4 was to redesign the Threading Pattern Library from the ground up and make it a real solution to write thread-safe code with C# and VB. Additionally, we've introduced the undo/redo feature into the Model Pattern Library. To achieve these objectives properly, we had to implement a good old concept from UML and object-oriented modeling: aggregation and composition. We introduced significant improvements in the PostSharp Aspect Framework to support these new features.

PostSharp 4.0 includes the following improvements:

  • Aggregatable pattern
  • Disposable pattern
  • Immutable threading model
  • Freezable threading model
  • Synchronized threading model
  • Redesign of reader-writer-synchronized, actor, and thread-unsafe threading models
  • Recordable pattern (undo/redo)
  • Dynamic location imports
  • Aspect repository
  • OnInstanceConstructed advice
  • InitializeAspectInstance advice
  • NotifyPropertyChanged optimization
Aggregatable pattern

As it turns out, multiple patterns rely on the notion of parent-child relationships. These concepts are a part of the UML specification, where it is known as aggregation, but even modern programming languages don't implement the notions. We fixed that in PostSharp 4.0 with our AggregatableAttribute aspect. For details, see Parent/Child Relationships.

Disposable pattern

Once we have a notion of parent-child relationship, it is easy to build an aspect that recursively disposes a whole object tree. This is our DisposableAttribute aspect. For details, see Walkthrough: Automatically Disposing Children Objects.

Immutable threading model

The Immutable patterns made functional languages popular for its great usefulness in multi-threaded programs. Unfortunately, the concept has traditionally been difficult to object-oriented programming. PostSharp 4.0 provides a pragmatic implementation with the ImmutableAttribute aspect. For details, see Immutable Threading Model.

Freezable threading model

Even a well-implemented Immutable pattern can be too strict for some object-oriented scenarios. In this case, the Freezable patterns may be more suitable. Based on the Aggregatable pattern, the FreezableAttribute aspect makes it possible to build freezable object trees. For details, see Freezable Threading Model.

Synchronized threading model

A threading model library could not be complete without it, so we added the SynchronizedAttribute aspect. For details, see Synchronized Threading Model.

Redesign of reader-writer-synchronized, actor, and thread-unsafe threading models

We took the right way in PostSharp 3.0 with threading models, but the vision was not yet fully consistent and the implementation was only partial. With PostSharp 3.2, we felt we had a better understanding of what we wanted to achieve, and completely revisited our threading models. Based on the Aggregatable pattern, and based on a consistent object model, the Threading Pattern Library is now much more powerful and consistent.

Recordable pattern (undo/redo)

The RecordableAttribute aspect, together with the Recorder class, make is possible to implement an undo/redo feature at the domain level.

Dynamic location imports

To allow to import several fields and properties into a single aspect field (which was not possible using ImportMemberAttribute, we added the IAdviceProvider interface and the ImportLocationAdviceInstance class.

Aspect repository

The new IAspectRepositoryService service exposes the list of all aspects added to the code model, both using custom attributes or IAspectProvider, and offer a way to execute validation logic after all aspects have been discovered.

OnInstanceConstructed advice

The OnInstanceConstructedAdvice custom attribute allows you to define an advice that is executed after the instance constructor exits.

InitializeAspectInstance advice

The InitializeAspectInstanceAdvice custom attribute allows you to define an advice that is similar to RuntimeInitializeInstance but passes information about the reason why the aspect is initialized (constructor, clone, deseralization).

NotifyPropertyChanged optimization

Our NotifyPropertyChangedAttribute is four times faster at runtime on average.


What's New in PostSharp 3.1

What's New in PostSharp 3.1

PostSharp 3.1 builds on the vision of PostSharp 3.0, but makes it more convenient to use. It also catches up with the C# compiler features, and add more flexible licensing options.

PostSharp 3.1 includes the following improvements:

  • Better support for iterator and async methods
  • Improved configuration system
  • Build-time performance improvement
  • Resolution of file and line of error messages
  • Indentation in logging
  • Separate licensing of Pattern Libraries
Better support for iterator and async methods

When you applied an OnMethodBoundaryAspect to a method that was compiled into a state machine, whether an iterator or an async method, the code generated by PostSharp would not be very useful: the aspect would just be applied to the method that implements the state machine. An OnException advice had no chance to get ever fired.

Starting from PostSharp 3.1, OnMethodBoundaryAspect understands that is being applied to a state machine, and works as you would expect.

Improved configuration system

PostSharp 3.1 makes it easier to share configuration across several projects. For instance, you can now add aspects to all projects of a solution in just a few clicks. This is not just a UI tweak. This scenario has been made possible by significant improvements in the PostSharp configuration system:

  • Support for solution-level configuration files (SolutionName.pssln), and well-known configuration files (postsharp.config) additionally to project-level files (ProjectName.psproj). See Working with PostSharp Configuration Files for details.

  • Support for conditional configuration elements

  • Support for XPath in expressions (instead of only property references as previously). See Using Expressions in Configuration Files for details.

Build-time performance improvement

PostSharp can now optionally install itself in GAC and generate native images. This decreases build time of a fraction of a second for each project: a substantial gain if you have a lot of projects.

Resolution of file and line of error messages

When previous versions of PostSharp had to report an error or a warning, it would include the name of the type and/or method causing the message, but was unable to determine the file and line number. You can now double-click on an error message in Visual Studio and you’ll get to the relevant location for the error message.

Indentation in logging

For better log readability, PostSharp Diagnostics Pattern Library now automatically indents log entries when entering and exiting methods.

Separate licensing of Pattern Libraries

PostSharp Pattern Libraries can now be purchased separately, so you don't have to buy the full PostSharp Ultimate if you just want to use INotifyPropertyChanged. The licensing system has been modified to support this scenario.


What's New in PostSharp 3.0

What's New in PostSharp 3.0

The focus in PostSharp 3.0 was to deliver more value to customers with less initial learning. Instead of having to learn the product before being able to build aspects, customers can now choose from a set of ready-made implementations of some of the most popular design pattern, and apply them to their application from the Visual Studio code editor, using smart tags and wizards. We also improved support for Windows Phone, Silverlight, Windows Store and Portable Class Library.

PostSharp 3.0 includes the following improvements:

  • Model Pattern Library
  • Diagnostics Pattern Library
  • Threading Pattern Library
  • Smart tags and wizards in Visual Studio
  • Better platform support through Portable Class Libraries
  • Unified deployment through NuGet and Visual Studio Gallery
  • Transparency to obfuscators
  • Deprecation of old platforms
Model Pattern Library

The NotifyPropertyChangedAttribute aspect is a ready-made implementation of the NotifyPropertyChanged design pattern. The PostSharp.Patterns.Contracts namespace provides code contracts that can validate, at runtime, the value of a parameter, a property, or a field.

Diagnostics Pattern Library

The LogAttribute and LogExceptionAttribute aspects provide a ready-made and high-performance implementation of a tracing aspect. They are compatible with the most popular logging framework, including log4net, nlog, and Enterprise Library.

Threading Pattern Library

PostSharp Threading Pattern Library invites you to raise the level of abstraction in which multi-threading is being addressed. It provides three threading models: actors (Actor), reader-writer synchronized (ReaderWriterSynchronizedAttribute) and thread unsafe (ThreadUnsafeAttribute). Additionally, BackgroundAttribute and DispatchedAttribute allow you to easily dispatch a thread back and forth between a background and the UI thread.

Smart tags and wizards in Visual Studio

Smart tags allow for better discoverability of ready-made aspects and pattern implementations. When the aspect requires configuration, a wizard user interface collects the parameters and then generates the proper code.

Better platform support through Portable Class Libraries

Windows Phone, Windows Store and Silverlight are now first-class citizens. All features that are available for the .NET Framework now also work with these platforms. All platforms are supported transparently through the portable class library. To provide this feature, we had to develop the PortableFormatter, a portable serializer similar in function to the BinaryFormatter. All you have to do is to replace [Serializable] with [PSerializable].

Unified deployment through NuGet and Visual Studio Gallery

Installation of PostSharp is now unified and built on top of Visual Studio Gallery and NuGet Package Manager.

Transparency to obfuscators

PostSharp no longer requires specific support from obfuscators, as it no longer uses strings to refer to metadata declarations.

Deprecation of old platforms

Support for Silverlight 3, .NET Compact Framework, and Mono has been deprecated.


What's New in PostSharp 2.1

What's New in PostSharp 2.1

The objective of release 2.1 was to fix a number of 'gray points' of the version 2.0, which added friction to the adoption path of PostSharp, or even prevented people from using the product.

PostSharp 2.1 includes the following improvements:

  • Build-time performance improvement
  • Support for NuGet and improved no-setup experience
  • Compatibility with obfuscators
  • Extended reflection API
  • Architectural validation
  • Compatibility with Code Contracts
  • Support for Silverlight 5.0
  • License server
Build-time performance improvement

We traded our old text-based compilation engine to a brand new binary writer.

Support for NuGet and improved no-setup experience

PostSharp 2.1 can be installed directly from NuGet. Local installation is no longer a requirement to use the Visual Studio Extension. However, because the setup program creates ngenned images, it still provides the faster experience.

Compatibility with obfuscators

PostSharp can now be used jointly, and without limitation of features, with some obfuscators. See [obfuscators] for details.

Extended reflection API

The class ReflectionSearch allows you to programmatically navigate the structure of an assembly: find custom attributes of a given type, find children of a given type, find members of a given type, find methods referring a given type or members, or find members accessed from a given method.

Architectural validation

Architecture Validation allows you annotate your code with constraints, which define the conditions in which your API is allowed to be used. Constraints are verified at build time and their violation generates a build warning and an error. See Validating Architecture for details.

Compatibility with Code Contracts

PostSharp 2.1 can be used jointly with Microsoft Code Contracts. Aspects and contracts can be applied to the same method.

Support for Silverlight 5.0

Silverlight 5.0 is added to the list of supported platforms.

License server

The license server helps customer manage and deploy license keys. The license server is a simple ASP.NET application that can be deployed easily on any Windows machine. Its use is optional.


What's New in PostSharp 2.0

What's New in PostSharp 2.0

PostSharp 1.0 and 1.5 made aspect-oriented programming (AOP) popular in the .NET community. PostSharp 2.0 makes it mainstream by enhancing convenience (Visual Studio Extension), reliability (dependency enforcement), run-time performance (optimizer), and features (composite aspects, property- and event-level aspects).

PostSharp 2.0 includes the following improvements:

  • Visual Studio Extension
  • Composite aspects (advices and pointcuts)
  • Adaptive code generation
  • Interception aspect for fields and properties
  • Interception aspect for events
  • Aspect dependencies
  • Instance-scoped aspects
  • Support for new platforms
  • Build performance improvements
Visual Studio Extension

As developers start being comfortable with PostSharp and add more and more aspects to their code, two questions become manifest: How can I know to which elements of code my aspect has been applied? How can I know which aspects have been applied to the element of code I am looking at? Answering these two questions is precisely what the PostSharp Extension for Visual Studio 2008 and 2010 has been designed for. It provides two new features to the IDE: an Aspect Browser tool window, and new adornments of enhanced elements of code with clickable tooltip.

Composite aspects (advices and pointcuts)

Part of the success of PostSharp 1.5 was due to its ability to introduce aspects without appealing to barbaric terms such as advices and pointcuts. So why to introduce them now? Because they make it easier to develop complex aspects. Thanks to advices and pointcuts, you can implement complex patterns such as observability awareness (INotifyPropertyChanged) with just a few lines of code. And just with PostSharp 1.5, you can still write your own aspects without knowing about advices and pointcuts.

Adaptive code generation

PostSharp 2.0 generates much smarter, faster, and smaller code than before. Let's face it: PostSharp 1.5 was quite dumb. It generated a lot of instructions that your aspects did not even need. PostSharp 2.0 analyzes your aspect to see which features are actually being used at runtime, and generates only instructions that support these features. Result: you could probably not write much faster code by hand.

Interception aspect for fields and properties

PostSharp 2.0 comes with a new kind of aspect that handles fields and properties: LocationInterceptionAspect (in replacement of OnFieldAccessAspect). The aspect is much more usable than its predecessor; for instance, it is possible to call the field or property getter from the setter.

Interception aspect for events

The new aspect kind EventInterceptionAspect allows an aspect to intercept all event semantics: add, remove, and fire.

Aspect dependencies

By enforcing aspect dependency rules, PostSharp ensures that aspects behave in a predictable and robust way, even when multiple aspects are applied to the same element of code. This feature is important for large and complex projects, where aspects may be written by different teams, or provided by numerous third-party vendors who don't know about each other.

Instance-scoped aspects

In PostSharp 1.5, all aspects had static scope, i.e. there was a single instance of the aspect for every element of code to which they applied. It is now possible to define aspects that have instance lifetime. For instance, if the aspect is applied to an instance field, a new instance of the aspect will be created for every instance of the type declaring the field. This is named an instance-scoped aspect.

Support for new platforms
  • Microsoft .NET Framework 4.0
  • Microsoft Silverlight 3.0
  • Microsoft Silverlight 4.0
  • Microsoft Windows Phone 7 (Applications and Games)
  • Microsoft .NET Compact Framework 3.5
  • Novell Mono 2.6
Build performance improvements

Just starting the CLR and loading system assemblies takes considerable time, too much for an application (such as PostSharp) that is typically started very frequently and whose running time is just a couple of seconds. To cope with this issue, PostSharp now preferably runs as a background application


What's New in PostSharp 1.5

What's New in PostSharp 1.5

PostSharp 1.5 was published 3 years after the start of the project, and was the first release to be really production-ready.

PostSharp 1.5 includes the following improvements:

  • Aspect inheritance
  • Reading assemblies without loading them in the CLR
  • Lazy loading of assemblies
  • Build-time performance improvement
  • Support for Mono
  • Support for Silverlight 2.0 and the Compact Framework 2.0
  • Pluggable aspect serializer & partial trust
Aspect inheritance

It is now possible to put an aspect on an interface and have it implicitly applied to all classes implementing that interface. The same works with classes, virtual or interface methods, and parameters of virtual or interface methods. Read more...

Reading assemblies without loading them in the CLR

In version 1.0, PostSharp required assemblies to be loaded in the CLR (i.e. in the application domain) to be able to read them. This limitation belongs to the past. When PostSharp processes a Silverlight or a Compact Framework assembly, it is never loaded by the CLR.

Lazy loading of assemblies

When PostSharp has to load a dependency assembly, it now reads only the metadata objects it really needs, resulting in a huge performance improvement and much lower memory consumption.

Build-time performance improvement

The code has been carefully profiled and optimized for maximal performance.

Support for Mono

PostSharp is now truly cross-platform. Binaries compiled on the Microsoft platform can be executed under Novell Mono. Both Windows and Linux are tested and supported. A NAnt task makes it easier to use PostSharp in these environments.

Support for Silverlight 2.0 and the Compact Framework 2.0

You can add aspects to your projects targeting Silverlight 2.0 or the Compact Framework 2.0.

Pluggable aspect serializer & partial trust

Previously, all aspects were serializers using the standard .NET binary formatter. It is now possible to choose another serializer or implement your own, and enhance assemblies that be executed with partial trust.


Deployment and Configuration

Deployment and Configuration

This part describes how to deploy and configure PostSharp in complex situations.

Although PostSharp is very intuitive to use and get started with in small projects, large teams and regulated environments have specific challenges that are addressed here.

You can typically skip the reading of this part if you just want to get started quickly with PostSharp, then come back when you decide to deploy it at a larger scale.

This part is composed of the following chapters.

Chapter | Description
Deployment | This chapter describes how to install, uninstall and upgrade PostSharp, how to register license keys and to cope with build servers.
Configuration | This chapter explains configuration settings and how to modify them.


Deployment

Deployment

PostSharp has been designed for easy deployment in typical development environments. Over the years, source control and build servers have become the norm, so we optimized PostSharp for this deployment scenario.

PostSharp is composed of the following components:

  • PostSharp Tools for Visual Studio is the user interface of PostSharp. It extends the Visual Studio editor and provides a new menu, option pages, and toolbox windows, and smart tags. PostSharp Tools for Visual Studio must be installed on each developer workstation but is not required on build servers.

  • PostSharp Compiler contains the build-time components and the run-time libraries. PostSharp Compiler is distributed only as a NuGet package. It is typically included in the source repository or is restored before build from the package repository.

  • PostSharp Pattern Libraries provide ready-made implementations of the most common design patterns. They are distributed as NuGet package and depend on the PostSharp package.

In most situations, PostSharp should work just fine without any advanced configuration. This chapter includes a detailed description of all deployment and configuration scenarios


Requirements and Compatibility

Requirements and Compatibility

You can use PostSharp to build applications that target a wide range of target devices. This article lists the requirements on development, build and end-user devices.

This topic contains the following sections.

  • Requirements on development workstations and build servers
  • Requirements on end-user devices
  • Compatibility with ASP.NET
  • Compatibility with Microsoft Code Analysis
  • Compatibility with Microsoft Code Contracts
  • Compatibility with Obfuscators
  • Known Incompatibilities
Requirements on development workstations and build servers

The following software components need to be installed before PostSharp can be used:

  • Microsoft Visual Studio 2012 or 2013, 2015 except Express editions, but including Community Edition (Visual Studio is not required on build servers).

  • .NET Framework 4.5.

  • Windows Vista SP2, Windows 7 SP1, Windows 8, Windows 8.1, Windows Server 2003 SP2, Windows Server 2003 R2 SP2, Windows Server 2008 SP2, Windows Server 2008 R2 SP1, Windows Server 2012, Windows Server 2012 R2.

  • NuGet Package Manager 2.2 or later.

Note Note

The latest version of NuGet Package Manager will be installed automatically by PostSharp if NuGet 2.2 is not already installed. This operation requires administrative privileges.

Caution note Caution

NuGet Package Manager needs to be configured manually in order to match the requirements of some corporate environments, especially in situations with a large number of Visual Studio solutions. Please contact our technical support if this is a concern for your team.

Requirements on end-user devices

The following table displays the versions of the target frameworks that are supported by the current release of PostSharp and its components.

PostSharp Component | .NET Framework | Silverlight | Windows Phone (Silverlight) | Windows Phone (WinRT) | Windows (WinRT) | Xamarin
Aspect Framework | 3.5 SP1, 4.0, 4.5, 4.6 | 4, 5 | 7, 8 | 8.1 | 8, 8.1 | 3.8
Architecture Framework | 3.5 SP1, 4.0, 4.5, 4.6 | 4, 5 | 7, 8 | 8.1 | 8, 8.1 | 3.8
Diagnostics Pattern Library | 4.0, 4.5, 4.6 | - | - | - | - | -
Model Pattern Library | 4.0, 4.5, 4.6 | - | 8 | 8.1 | 8, 8.1 | 3.8
Threading Pattern Library | 4.0, 4.5, 4.6 | - | 8 | 8.1 | 8, 8.1 | 3.8
Threading Pattern Library - Deadlock Detection | 4.0, 4.5, 4.6 | - | - | - | - | -
Note Note

PostSharp supports Portable Class Library projects that target frameworks shown in the table.

Compatibility with ASP.NET

There are two ways to develop web applications using Microsoft .NET:

  • ASP.NET Application projects are very similar to other projects; they need to be built before they can be executed. Since they are built using MSBuild, you can use PostSharp as with any other kind of project.

  • ASP.NET Site projects are very specific: there is no MSBuild project file (a site is actually a directory), and these projects must not be built. ASP.NET Site projects are not supported.

Additionally, ASP.NET "vNext", which has a different project system than MSBuild, are not supported.

Compatibility with Microsoft Code Analysis

By default, PostSharp reconfigures the build process so that Code Analysis is executed on the assemblies as they were before being enhanced by PostSharp. If you are using Code Analysis as an integrated part of Visual, no change of configuration is required.

You request the Code Analysis to execute on the output of PostSharp by setting the ExecuteCodeAnalysisOnPostSharpOutput MSBuild property to True. For more information, see Configuring Projects Using MSBuild.

Compatibility with Microsoft Code Contracts

PostSharp configures the build process so that Microsoft Code Contracts is executed before PostSharp. Additionally, Microsoft Code Contracts' static analyzer will be executed synchronously (instead of asynchronously without PostSharp), which will significantly impact the build performance.

Compatibility with Obfuscators

Starting from version 3, PostSharp generates assemblies that are theoretically compatible with all obfuscators.

Caution note Caution

PostSharp 3 generates constructs that are not emitted by Microsoft compilers (for instance methodof). These unusual constructs may reveal bugs in third-party tools, because they are generally tested against the output of Microsoft compilers.

Known Incompatibilities

PostSharp is not compatible with the following products or features:

Product or Feature | Reason | Workaround
Visual Studio 2010 | Not Supported | Use PostSharp 3.1.
ILMerge | Bug in ILMerge | Use another product (such as SmartAssembly).
Edit-and-Continue | Not Supported | Rebuild the project after edits
Silverlight 3 or earlier | No longer under Microsoft mainstream support | Use PostSharp 2.1 or Silverlight 5
Silverlight 4 | No longer under Microsoft mainstream support | Use PostSharp 3.1 or Silverlight 5
.NET Compact Framework | No support for PCL | Use PostSharp 2.1 or Windows Phone 8
.NET Framework 2.0 | No longer under Microsoft mainstream support | Target .NET Framework 3.5 or use PostSharp 3.1
Windows Phone 7 | No longer under Microsoft mainstream support | Target Windows Phone 8 or use PostSharp 3.1
Mono | Not Supported | Compile on Windows using MSBuild
Visual Studio Express | Microsoft's licensing policy | Use Visual Studio Community Edition
Delayed strong-name signing on cloud build servers | No way to unregister verification of strong names | Use normal (non-delayed) strong-name signing or use build servers where you have administrative access.
ASP.NET Web Sites | Not built using MSBuild | Convert the ASP.NET Web Site to an ASP.NET Web Application.


Installing PostSharp Tools for Visual Studio

Installing PostSharp Tools for Visual Studio

PostSharp Tools for Visual Studio are PostSharp's user interface. Install them on a developer's computer, does not affect the projects until the PostSharp NuGet package has been added to this project. See Installing PostSharp Into a Project for details.

To install PostSharp Tools for Visual Studio:

  1. Download the file PostSharp-X.X.X.exe from http://www.postsharp.net/download.

  2. Run the file PostSharp-X.X.X.exe.

  3. Start Visual Studio.

  4. Complete the configuration wizard. You will be asked to enter a license key or to start the trial period. The wizard may ask the permission to install NuGet Package Manager or to uninstall the user interface of PostSharp.

See Also

Other Resources

Installing PostSharp Into a Project
Uninstalling PostSharp


Installing PostSharp Into a Project

Installing PostSharp Into a Project

The compiler components of PostSharp are distributed as a NuGet package named simply PostSharp. If you want to use PostSharp in a project, you simply have to add this NuGet package to the project.

This topic contains the following sections.

  • Adding PostSharp to a project
  • Including files in source control
Adding PostSharp to a project

To add PostSharp to a project:

  1. Open the Solution Explorer in Visual Studio.

  2. Right-click on the project.

  3. Click on Add PostSharp.

Tip Tip

Remember that adding PostSharp to a project just means adding the PostSharp NuGet package. If you want to add PostSharp to several projects in a solution, it may be easier to use NuGet to manage packages at solution level. You may need to select the Include Prerelease option to install a prerelease version of PostSharp.

Tip Tip

NuGet Package Manager can be configured using a file named nuget.config, which can be checked into source control and can specify, among other settings, the location of the package repository (if it must be shared among several solutions, for instance) or package sources (if packages must be pre-approved). See NuGet Configuration File and NuGet Configuration Settings for more information.

Including files in source control

After you add PostSharp to a project, you need to add the following files to source control:

  • packages.config

  • *.psproj

  • *.pssln

Optionally, you can also include the packages folder in source control. Note that some people advise against this practice. If you choose not to include the packages folder in source control, read Restoring Packages at Build Time.

Once you have all of these files include in your source code repository any other developer getting that source code from the repository will have the required information to be able to build the application.


Deploying License Keys

Deploying License Keys

This section explains how to install PostSharp license keys.

Whether you are using a free or commercial edition, PostSharp requires you to enter a license key before being able to build a project.

This topic contains the following sections.

  • Registering a license key using the user interface
  • Installing the license key in source control
Registering a license key using the user interface

Registering a license key using the user interface is the prefered procedures for individual developers and small teams.

To register a license key using the user interface:

  1. Open Visual Studio.

  2. Click on menu PostSharp, then Options.

  3. Open the License option page.

  4. Click on the Register a license link.

  5. Click on Register a license.

    License Wizard 1

  6. Paste the license key and click Next .

    License Wizard 2

  7. Read the license agreement and check the option I agree. Click on Next.

    License Wizard 3
    Tip Tip

    If you are registering the license key on a build server, also check the option Register these settings for all accounts on this machine.

  8. Click Next on the notice regarding license metering.

Installing the license key in source control

It is possible to install the license key in source control, so that these settings are automatically applied during the build.

To install the license the in source control:

  1. Create a file named postsharp.config in the root directory of your source repository, or in any parent directory of the Visual Studio project file (*.csproj or *.vbproj).

  2. Add the following content to the postsharp.config file:

    Copy
    <Project xmlns="http://schemas.postsharp.org/1.0/configuration">
  <License Value="000-AAAAAAAAAAAAAAA"/>
</Project>

    In this code, 000-AAAAAAAAAAAAAAA must be replaced by the license key or the URL to the license server.

See Working with PostSharp Configuration Files for details about this configuration file.


License Audit

License Audit

Although most software packages are protected with a license activation mechanism, we think that the practice is not adequate for software development tools:

  • Source code is sometimes compiled several years after it has been written, and there is no guarantee that the license activation server will still be functional.

  • Development teams want their tools to be included in the source control repository together with source code, and want the license key to be deployed the same way.

Instead of license activation, PostSharp relies on asynchronous, fail-safe license audit. PostSharp audits the use of license keys on each client machine and periodically reports it to our license servers. The mechanism does not require a permanent network connection, and PostSharp will not fail if the license server is not available.

The licensing client will contact our licensing servers in the following cases:

  • When a license is registered on a computer with the user interface.

  • Once per week, for every user and every device using PostSharp.

No personally identifiable information is transmitted during this process except the license key. In case we suspect a rough violation of the License Agreement, we reserve the right to contact the legitimate owner of this license.

Tip Tip

If license audit is not acceptable in your industry, please contact us with a request to disable license audit. Our sales teams will evaluate your request and answer with a license key containing an audit waiver. Global licenses and site licenses are not subject to license audit by default. The use of the license server does not implicitly disable license audit. For more information, see Using PostSharp License Server.

See Also

Other Resources

Using PostSharp License Server


Using PostSharp License Server

Using PostSharp License Server

If the license audit is not acceptable in your company for regulatory or other reasons, you can consider using the PostSharp License Server.

PostSharp License Server is a server application that customers can install into on their own premises to measure the number of concurrent users of PostSharp. The application is based on ASP.NET and Microsoft SQL Server.

This topic contains the following sections.

  • Disclaimer
  • Design Principles
  • Subscribing to the license server
  • Installing the license settings in source control

If you are a system administrator or license administrator, see also Installing and Servicing PostSharp License Server.

Disclaimer

Using the license server is optional. Only a few enterprise customers chose to use it. Alternative approaches are:

  • To rely on the default license audit mechanism (see License Audit for details).

  • To acquire enough licenses for the whole team with some reserve margin.

  • To use a spreadsheet to keep track of who is using the software.

  • To use other software audit products, although this approach is imperfect because PostSharp is not installed on the developer's machine as a standalone and identificable application.

Design Principles

The license server manages leases of a license to a given user on a given machine (the “client”). Once the lease is provided to the client, it is cached on the client. Upon client request, the server will return a license key and two dates: the lease end date and the lease renewal date. The lengths of the lease and of the renewal period are configurable. The client will not contact the license server before the renewal date, so the client can go offline during the duration of the lease. Then, a new lease will be reserved for the client. If the client is not able to renew its lead from the server after the lease renewal date, the client will still be able to use PostSharp until the end of the lease. Then, the use of PostSharp will be prevented. To avoid loss of productivity due to lack of network connection or server outages, we recommend setting a large delay between the lease renewal period and the lease period.

If the number of concurrent users exceeds the licensed number, the license administrator will receive an email, and additional users will be allowed during a grace period. At the end of the grace period, only the licensed number of concurrent users will be allowed. The duration of the grace period and the number of excess users depend on the kind of license. By default, it is set to 30% of users and 30 days.

Important note Important

If you have subscribed to a license server, you will need periodic connections to the company network. The licensing client will automatically try to renew a lease when it comes close to expiration and if the license server is available. Lease duration and renewal settings can be configured by the administrator of the license server. A connection to the license server is not necessary while the lease is valid.

Subscribing to the license server

If your company use PostSharp License Server, you can register using a similar procedure as for registering a license key:

To subscribe to a license server using the user interface:

  1. Open Visual Studio.

  2. Click on menu PostSharp, then Options.

  3. Open the License option page.

  4. Click on the Subscribe to a license server link.

    License Server 5

  5. Paste the URL of the license server. You can click on the Open hyperlink to verify that the URL is correct and that you have access to it. Click Next.

    License Server 6

  6. Read the license agreement and check the option I accept. Click on Next.

    License Server 7
    Tip Tip

    If you are registering the license server on a build server, also check the option Register the license for all accounts on this machine.

  7. You are done.

    License Server 8
Installing the license settings in source control

It is possible to subscribe to the license server using a file stored in source control by using the exact same mechanism as to register a license key.

To install license settings in source control:

  1. Create a file named postsharp.config in the root directory of your source repository, or in any parent directory of the Visual Studio project file (*.csproj or *.vbproj).

  2. Add the following content to the postsharp.config file:

    Copy
    <Project xmlns="http://schemas.postsharp.org/1.0/configuration" x:xmlns="http://schemas.postsharp.org/1.0/configuration">
  <License Value="http://server/path"/>
</Project>

    In this code, http://server/path must be replaced by the URL to the license server.

See Working with PostSharp Configuration Files for details about this configuration file.

See Also

Other Resources

Installing and Servicing PostSharp License Server


Installing and Servicing PostSharp License Server

Installing and Servicing PostSharp License Server

This topic covers PostSharp License Server from the point of view of the system administrator and license administrator.

We designed our license server to help our customers, not to enforce our license agreements. The application is not obfuscated, it uses a clear SQL database and provides the ability to workaround issues by canceling leases or purging tables.

This topic contains the following sections.

  • System Requirements
  • Installing PostSharp License Server
  • Installing a license key
  • Testing the license server
  • Displaying license usage
  • Canceling leases
  • Maintenance
System Requirements

PostSharp License Server is an ASP.NET 4.0 application backed by a Microsoft SQL database.

It requires:

  • Windows Server 2003 or later with Internet Information Services installed.

  • Microsoft SQL Server 2005 or later (any edition, including the Express edition).

If the license server can be configured with a sufficiently long lease renewal period, there is no need to deploy the application and its database in high-availability conditions. You need to plan that the amount of time between the lease renewal and the lease end is larger than the longest expected outage. Frequent backups are not critical unless usage information is required for accounting purposes in case of pay-as-you-use licenses, where the Export Logs feature is required.

Caution note Caution

Deploying the ASP.NET application to several machines is not supported because the lease algorithm uses application locking instead of database locking.

Installing PostSharp License Server

The setup procedure is simple but must be performed manually.

To install PostSharp License Server, you will need administrative access on a Windows Server machine and the permission to create a new database.

To install PostSharp License Server:

  1. Download the latest version of PostSharp License Server from the PostSharp website. For version 3.1.44, the URL is http://www.postsharp.net/downloads/postsharp-3.1/v3.1.44/SharpCraftersLicenseServer-3.1.44.zip. You can open the download manager at http://www.postsharp.net/downloads/ and browse to the version you are interested in.

    Note Note

    It is not necessary that the version of PostSharp License Server exactly matches the version of PostSharp. You do not have to upgrade PostSharp License Server as long as the license keys you want to use are compatible with the server version.

  2. Using Internet Information Services (IIS) Manager, configure a new web application whose root is the folder containing the file web.config.

  3. The application pool should be configured to use ASP.NET 4.0.

  4. Configure the authentication mode of the web application: disable Anonymous Authentication, and enable Windows Authentication.

  5. Create an MS SQL database (the free MS SQL Express server is supported).

  6. Execute the script CreateTables.sql in the context of this database. The file is located in the zip archive of the license server.

  7. Set up security on this database so that the user account under which the ASP.NET application pool is running (typically NETWORK SERVICE) can access the database.

  8. Edit the file web.config:

    1. configuration/connectionStrings: Correct the connection string (server name and database name) to match your settings.

    2. configuration/system.net/mailSettings: Set the name of the SMTP server used to send warning emails.

    3. configuration/applicationSettings: this section contains several settings that are documented inside the web.config file. The most important settings are the email addresses for shortage notifications and the duration of leases duration and renewal delay.

    4. configuration/system.web/authorization: Set up security of the whole application to restrict the persons who are allowed to borrow a license. Optional.

    5. configuration/location[@path='Admin']/system.web/authorization: Specify who has access to the administrative interface of the application. Optional.

Installing a license key

Before developers can start using the license server, you need to install a license key.

To install a license key into the license server:

  1. Open the home page of the license server using a web browser.

  2. Click on the link Install a new license.

  3. Paste the license key and click on button Add.

    License Server 1
Testing the license server

If you have installed the license server at the address http://localhost/PostSharpLicenseServer, you can test it opening the URL http://localhost/PostSharpLicenseServer/Lease.ashx?product=PostSharp30&user=me&machine=other using Firefox or Chrome. If the license acquisition was successful, the browser will display the license key and the duration of the lease. You can also then see the resulting allocation on the home page http://localhost/PostSharpLicenseServer, and cancel the lease.

Displaying license usage

PostSharp License Server makes it easy to know how many people are currently using the product, and to display historical data.

Overview of installed license keys and current number of leases
License Server 2

Detail of leases
License Server 3

History of license usage. The figure demonstrates a 30-day, +30% grace period.
License Server 4
Canceling leases

You can cancel a lease from the lease list by clicking on the Cancel hyperlink. Note that canceling a lease on the server does not cancel the lease on the client. It is not possible to cancel leases on the client.

Maintenance

The license server is designed to keep a history of all leases. Therefore, it can grow indefinitely, depending on the number of users and lease duration. It is safe to delete all records from the Lease table at any time, unless these records are necessary for accounting purposes.

Using SQL Agent, you can schedule a job that purges old records of the Lease table:

Copy
DELETE FROM [dbo].[Leases] WHERE EndTime < DATEADD( day, -90, GETDATE() );


Using PostSharp on a Build Server

Using PostSharp on a Build Server

PostSharp has been designed for frictionless use on build servers. PostSharp build-time components are deployed as NuGet packages, and are integrated with MSBuild. No component needs to be installed or configured on the build server, and no extra build step is necessary. If you choose not to check in NuGet packages in your source control, read Restoring Packages at Build Time.

Installing a License on the Build Server

The License Agreement specifies that build servers don’t need their own license. PostSharp will not attempt to enforce licensing if it detects that it runs in unattended mode. PostSharp uses several heuristics to detect whether it is running unattended. These heuristics include the use of Environment.UserInteractive, checking Process.SessionId (from Windows Vista, all processes running in session 0 are unattended), or checking the parent process.

If this check does not work for any reason, you may use the license key of any licensed user for the build server. This will not be considered a license infringement. However, it is better to report the issue to our technical support so that we can fix the detection algorithms.

It is recommended to include the license key in the source control. See Deploying License Keys for details.

If you are using the license server, it is possible to configure it to provide license to build servers "for free", without holding a license from the pool. See the configuration options of the license server in Installing and Servicing PostSharp License Server for details.

See Also

Other Resources

Installing PostSharp Tools for Visual Studio
Deploying License Keys


Restoring Packages at Build Time

Restoring Packages at Build Time

NuGet Package Manager has the ability to restore packages from their repository during the build. This allows teams to avoid storing NuGet packages in source repository.

You can restore the PostSharp package at build time as long as the package is restored before MSBuild is invoked to build the project.

The reason is that PostSharp modifies the project file (csproj or vbproj, typically) to include the file PostSharp.targets. This file is required during the build, otherwise PostSharp is not inserted in the build process, and simply does not work. Because of the design of MSBuild, PostSharp.targets must be present when the build starts, so it cannot be restored from the package repository during the same build. The build that triggers the package restore will fail, and subsequent builds will succeed.

This behavior is acceptable on developer workstations. However, on build servers, you must ensure that the packages are restored before the project is built.

NuGet 2.7 and Later

To restore the PostSharp package at build time, add a preliminary step before building the Visual Studio solutions or projects. This step should execute the following command:

Copy
NuGet.exe restore MySolution.sln

In this command, where MySolution.sln is the solution for which packages have to be restored.

Please look at the NuGet Command-Line Reference for details.

NuGet 2.0 to 2.6

To restore the PostSharp package at build time, add a preliminary step before building the Visual Studio solutions or projects. This step should execute the following command for every packages.config file in your solution (typically, for every project):

Copy
NuGet.exe install packages.config -OutputDirectory SolutionDirectory\packages

In this command, where SolutionDirectory\packages is the directory where the NuGet packages should be installed.

Please look at the NuGet Command-Line Reference for details.

Tip Tip

You can use PowerShell or MSBuild to execute the nuget install command to all packages.config files in your source repository.

See Also

Other Resources

Package Restore on NuGet Reference Documentation


Using PostSharp with Visual Studio Online

Using PostSharp with Visual Studio Online

When hosting your source code on Visual Studio Online, adding PostSharp to the codebase is no different than for any other build server situation.

Visual Studio Online offers an online build server environment. Once configured the build server will retrieve your source code and compile the application for you. As part of this build process you will want any PostSharp aspects to be added in the same way that it occurs on your local development machine. To do this you will have to ensure that your codebase includes PostSharp as outlined in the Installing PostSharp Into a Project section. You will also need to configure a build definition as outlined in the Create or edit build definition article on MSDN.

Once you are able to successfully run the build you will want to review the build logs and verify the artifacts that were created by that build. Here's how you can verify that your build included your PostSharp aspects.

Verifying Visual Studio Online Builds

  1. To review the build logs, open the successful build.

  2. Select the Diagnostics tab.

  3. Ensure that the installation of PostSharp and any PostSharp patterns libraries that you used.

    If you see entries like these in your build log you know that the build process correctly downloaded the PostSharp components.

    If you do not see any entries for the downloading of the PostSharp components you will want to ensure that the packages.config file is correctly included in your source code repository and that the PostSharp dependencies are referenced in the appropriate projects.

See Also

Other Resources

MSDN: Create or edit Visual Studio Online build definition


Upgrading from a Previous Version of PostSharp

Upgrading from a Previous Version of PostSharp

This section explains how to upgrade from a previous version of PostSharp.

This topic contains the following sections.

  • Upgrading PostSharp Tools for Visual Studio
  • Upgrading solutions from PostSharp 3 or later
  • Upgrading large repositories
  • Upgrading solutions from PostSharp 2
Tip Tip

Other sections of this chapter, specifically Installing PostSharp Tools for Visual Studio, Deploying License Keys and Using PostSharp on a Build Server, are also useful if you need to upgrade from an earlier version of PostSharp.

Upgrading PostSharp Tools for Visual Studio

After you install PostSharp Tools for Visual Studio, you will still be able to open solutions that use older versions of PostSharp.

PostSharp Tools for Visual Studio are backward compatible with older versions of PostSharp. However, several versions of the extension cannot coexist. Therefore, installing a new version of PostSharp Tools will uninstall the previous version.

To upgrade PostSharp Tools for Visual Studio, simply download it from http://www.postsharp.net/download and execute the installation package.

Caution note Caution

Upgrading PostSharp Tools for Visual Studio does not implicitly upgrade your source code.

Upgrading solutions from PostSharp 3 or later
Caution note Caution

Before you upgrade your project to a different major release of PostSharp, check that the new version still supports your version Visual Studio and the target framework of your application. Check the release notes for an accurate compatibility list of the specific version you are installing.

You can use several versions of PostSharp side-by-side on the same machine. However, it is recommended that you use the same version in all projects of the same solution.

To upgrade a solution from PostSharp 3 or later:

  1. Open the Solution Explorer in Visual Studio.

  2. Right-click on the solution.

  3. Click on Manage NuGet Packages for Solution.

  4. Click on Updates.

  5. Find the PostSharp package and click on Update.

  6. Select all projects, click OK.

  7. Repeat the operation for all PostSharp.Patterns.* packages.

Upgrading large repositories

If your source contains a large number of solutions, upgrading manually using NuGet may be too labor intensive. In this situation, it is better to use our upgrade PowerShell script.

To upgrade a large number of solutions with the PowerShell script:

  1. Download the following Git repository: https://github.com/sharpcrafters/PostSharp.Utilities. You can download it manually from the web page or execute the following command:

    Copy
    git clone https://github.com/sharpcrafters/PostSharp.Utilities.git

  2. Follow instructions on in README.md.

Caution note Caution

This script does not support other platforms than the .NET Framework and does not support PostSharp Pattern Libraries.

Upgrading solutions from PostSharp 2

Every project can have only references to a single version of PostSharp. This applies both to direct and indirect references. The PostSharp 3 or later compiler is not backward compatible with PostSharp 2, and PostSharp 3 will refuse to compile projects that have a reference to PostSharp 2. Therefore, you will typically use a single version of PostSharp in every solution.

You can upgrade projects from PostSharp 2 to PostSharp 3 by adding the PostSharp NuGet package to these projects.

To upgrade a solution from PostSharp 2:

  1. Open the Solution Explorer in Visual Studio.

  2. Right-click on the solution.

  3. Click on Manage NuGet Packages for Solution.

  4. Click on Online.

  5. In the search box, type PostSharp. You may want to select the Select prereleases option (instead of the default Stable Only) to install a pre-release version of PostSharp.

  6. Find the PostSharp package and click on Install.

  7. Select all projects, click OK.

Although PostSharp 3 or later is mostly backward compatible with PostSharp 2 at source-code level, you may need to perform small adjustments to your source code:

  • Every occurrence of the _Assembly interface has been replaced by the Assembly classes. You may have to change the signatures of some methods derived from AssemblyLevelAspect.

  • Aspects that target Silverlight, Windows Phone or Windows Store must be annotated with the PSerializableAttribute custom attribute.

  • PostSharp Toolkits 2.1 need to be uninstalled using NuGet. Instead, you can install PostSharp Pattern Libraries 3 from NuGet. Namespaces and some type names have been changed.


Uninstalling PostSharp

Uninstalling PostSharp

If you make the decision to remove PostSharp from your project we are sorry to see you leave.

There are two scenarios you may want to consider: removing PostSharp from individual projects or solutions, and removing PostSharp from Visual Studio.

This topic contains the following sections.

  • Removing PostSharp from your projects and solutions
  • Removing PostSharp from Visual Studio
Removing PostSharp from your projects and solutions

Here are some steps to follow to remove PostSharp from your project.

Caution note Caution

As you'll see in these steps, removing the product from your project is not that difficult. However, replacing the aspects that you were using will be a much more arduous task that will require a great deal of planning.

You will need to replace the aspects by hand-written source code that implement the same behaviors. Depending on how intensively you used PostSharp, your codebase could significantly increase as a result of stopping using PostSharp. Other products and frameworks that pretend to implement aspect-oriented programming actually only provide a small subset of the features you are got used to with PostSharp.

Because every project will use aspects differently, and some will have custom aspects, we are unable to give procedural advise on how to replace specific aspects.

To remove PostSharp from a project, you simply have to remove all PostSharp packages from it. The following procedure demonstrates how to remove PostSharp for the whole solution.

Removing PostSharp with NuGet Packages Manager for Solution

  1. Open the Package Manager for Solution windows

  2. Select the All tab from the left side of the window.

  3. Find the PostSharp packages in the list and select one of the PostSharp Library packages. Click the Manage button.

    Note Note

    Start by selecting the PostSharp Library Packages and working in reverse dependency order. This will result in the main PostSharp package being the last one that you select to remove.

  4. Ensure that you uncheck all of the projects listed in the window and click OK.

  5. Repeat steps 3 and 4 for each of the PostSharp packages that show in the Packages Manager for Solution window.

  6. To verify that all of the PostSharp packages have been removed from your codebase, ensure that there are no PostSharp packages listed in the Packages Manager for Solution window.

Once you have removed all of the PostSharp packages from your codebase it is most probable that your application will no longer compile. Compilation errors will be registered where PostSharp aspect attributes exist in the codebase as well as where custom aspects were written. You will need to remove these entries from your codebase to get it to compile again.

Simply deleting the offending code can accomplish this. You must remember that in the process of removing PostSharp from your codebase these errors indicate locations where you are removing functionality from the codebase as well. If the functionality that is being removed is required by the application you will need to determine how to provide that functionality in the codebase going forward. This is the most difficult part of removing PostSharp from yoru codebase. Because aspects can be used in a multitude of different manners, and custom aspects can be created for any number of different uses, there is no practical way to tell you how to replace the functionality being lost.

Note Note

You now have removed PostSharp from your codebase. At this point you are able to continue on your development effort without making use of PostSharp.

If you would like to remove PostSharp from Visual Studio, proceed with the following steps.

Removing PostSharp from Visual Studio

Before you uninstall PostSharp Tools for Visual Studio, we suggest you remove the compiled images.

Removing Native Compiled Images

  1. Open the Visual Studio Options dialog.

  2. Expand the PostSharp node in the tree and select the Compiled Images node.

  3. Select an entry in the listbox and click Uninstall.

  4. Follow the wizard to uninstall the compiled images for the selection you made. There are no choices to be made, simply click Next and Finish until the wizard is completed.

    Note Note

    You will need to perform the previous steps for each of the versions listed in the PostSharp Compiled Image page in the Options dialog.

The next step is to remove PostSharp from Visual Studio.

Uninstalling the PostSharp Tools for Visual Studio

  1. Open the Extensions and Updates window.

  2. Select the All tab on the left of the window.

  3. Find the PostSharp entry in the middle of the window, select it and click the Uninstall button.

  4. Click 'Yes' to confirm that you want to uninstall the PostSharp extension.

    Note Note

    You will need to restart Visual Studio to complete uinstalling the PostSharp extension.

Finally, you can remove the temporary files created by PostSharp. These files would be recreated as necessary the next time you run PostSharp.

Other than occupying disk space, there is no impact of not removing these files.

Cleaning temporary files

  1. Open Windows Explorer and navigate to C:\ProgramData\PostSharp.

  2. Select the C:\ProgramData\PostSharp folder and delete it.


Deploying PostSharp to End-User Devices

Deploying PostSharp to End-User Devices

Although PostSharp is principally a compiler technology, it contains run-time libraries that need to be deployed along with your application to end-user devices. These libraries are the ones included in the lib sub-directory of the NuGet packages for the relevant target framework.

These run-time libraries can be distributed to end-users free of charge. However, the build-time parts of PostSharp cannot be redistributed under the terms of the standard license agreement.

Besides including these run-time libraries, no other action or configuration is required.


Configuration

Configuration

For most use cases, PostSharp does not require any custom configuration. PostSharp gets its default configuration from three sources:

  • MSBuild integration. PostSharp gets most of its configuration settings directly from the parent MSBuild project.

  • NuGet integration. Some PostSharp plug-ins delivered as NuGet packages may modify PostSharp configuration files during installation.

  • PostSharp Tools. When adding aspects and policies from Visual Studio, PostSharp may automatically modify some configuration files.

Even if most configuration is correct by default, you may want to understand the configuration system to troubleshoot configuration and installation issues, or simply to implement more advanced configuration scenarios.

PostSharp can be configured using the Visual Studio user interface, by editing MSBuild project files, or by editing PostSharp configuration files.


Configuring Projects in Visual Studio

Configuring Projects in Visual Studio

PostSharp accepts several configuration settings such as the version and processor architecture of the CLR that is used at build time, the search path of dependencies, and whether some features are enabled.

Although the default configuration is appropriate for most situations, you may have to fine-tune some of them to cope with particular cases.

Most common properties can be edited directly from Visual Studio using the PostSharp project property page.

This topic contains the following sections.

  • Opening PostSharp project properties tab
  • Understanding configuration settings
Opening PostSharp project properties tab

To open the PostSharp project property page in Visual Studio

  1. Open the Solution Explorer.

  2. Right-click on the project then select Properties at the bottom of the menu.

  3. Select the PostSharp tab.

The PostSharp property page in Visual Studio
Project Property Page
Understanding configuration settings

Note that all settings are dependent on the selected project configuration (for instance Debug) and platform (for instance Any CPU).

Setting | Description
Disable PostSharp | True if PostSharp should not execute in for the selected configuration and platform, otherwise False. This setting maps to the MSBuild property SkipPostSharp.
Additional search path | A semicolon-separated list of directories where plug-ins and libraries have to be searched for. This property can reference other MSBuild properties, for instance: ..\MyWeaver\bin\$(Configuration). All project references are already added to the search path by default. This setting maps to the MSBuild property PostSharpSearchPath.
Additional properties | A semicolon-separated list of property definition, for instance: Name1=Value1;Name2=Value2. This property can reference other MSBuild properties, for instance: RootNamespace=$(RootNamespace). Several properties are defined by default; for details, see Well-Known PostSharp Properties. This setting maps to the MSBuild property PostSharpProperties
Suppress warnings | A semicolon-separated list of warning identifiers that must be ignored, or * if all warnings have to be ignored. This setting maps to the MSBuild property PostSharpDisabledMessages.
Treat warnings as errors | A semicolon-separated list of warning identifiers that must be escalated into errors, or * if all warnings must be treated as errors. This setting maps to the MSBuild property PostSharpEscalatedMessages.
Architecture Validation | Enabled if constraints must be validated, otherwise Disabled. The default value is Enabled. For details regarding architecture validation, see Validating Architecture.
CLR Version | The version of the CLR that hosts PostSharp. PostSharp currently only supports the CLR 4.0 so this setting is disabled. This setting maps to the MSBuild property PostSharpTargetFrameworkVersion.
Processor Architecture | The processor architecture (x86 or x64) of the process hosting PostSharp. Since PostSharp needs to execute the current project during build, the processor architecture of the PostSharp process must be compatible with the target platform of the current project. The default value is x86, or x64 if the target platform of the current project is x64. This setting maps to the MSBuild property PostSharpTargetProcessor.
Build Host | The kind of process hosting PostSharp, which influences the assembly loading mechanism, compatibility and performance features. This setting maps to the MSBuild property PostSharpHost. For details, see Configuring Projects Using MSBuild.
Optimization Mode | When set to Build Time, PostSharp will use a faster algorithm to generate the final assembly. When set to Size, PostSharp will use a slower algorithm that generates smaller assemblies. The default value is Build Time by default, or Size when the C# or VB compiler is set to generate optimal code (typically, in release builds). This settings maps to the MSBuild property PostSharpOptimizationMode.


Configuring Projects Using MSBuild

Configuring Projects Using MSBuild

Most configuration settings of PostSharp can be set as MSBuild properties.

Note Note

The integration of PostSharp with MSBuild is implemented in files PostSharp.tasks and PostSharp.targets. These files define some properties and items that are not documented here. They are considered implementation details and may change without notice.

This topic contains the following sections.

  • Setting MSBuild properties with a text editor
  • Configuring several projects at a time
  • Setting MSBuild properties from the command line
  • List of properties
Setting MSBuild properties with a text editor

To set a property that persistently applies to a specific project, but not to the whole solution, the best solution is to define it directly inside the C# or VB project file (*.csproj or *.vbproj, respectively) using a text editor.

Adding a project-level MSBuild property using Visual Studio

  1. Open the Solution Explorer, right-click on the project name, click on Unload project, then right-click again on the same project and click on Edit.

  2. Insert the following XML fragment just before the <Import /> elements:

    Copy
    <PropertyGroup>
    <PropertyName>PropertyValue</PropertyName>
</PropertyGroup>

    See Configuring Projects Using MSBuild for the list of MSBuild properties used by PostSharp.

  3. Save the file. If the project was open in Visual Studio, go to the Solution Explorer, right-click on the project name, then click on Reload project.

Note Note

For more information regarding MSBuild properties, see MSDN Documentation.

Configuring several projects at a time

Instead of editing every project file, you can define shared settings in a file named PostSharp.Custom.targets and store in the same directory as the project file or in any parent directory of the parent file (up to 7 levels from the project directory).

Files PostSharp.Custom.targets are loaded from the root directory to the project directory, so that files that are closer to the project directory are loaded after and override files in parent directories.

Thanks to this mechanism, it is possible to define settings that apply to a large set of projects and control the grain of settings.

Files PostSharp.Custom.targets are normal MSBuild project or targets files; they should have the following content:

Copy
<? xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PropertyName>PropertyValue</PropertyName>
  </PropertyGroup>
</Project>

See Configuring Projects Using MSBuild for the list of MSBuild properties used by PostSharp.

Note Note

For more information regarding MSBuild project files, see MSDN Documentation.

Setting MSBuild properties from the command line

When an MSBuild property does not need to be set permanently, it is convenient to set is from the command prompt by appending the flag /p:PropertyName=PropertyValue to the command line of msbuild.exe, for instance:

Copy
msbuild.exe /p:PostSharpHost=Native
List of properties

General Properties

The following properties are most commonly overwritten. They can also be edited in Visual Studio using the PostSharp project property page.

Property Name | Description
PostSharpSearchPath | A semicolon-separated list of directories added to the PostSharp search path. PostSharp will probe these directories when looking for an assembly or an add-in. Note that several directories are automatically added to the search path: the .NET Framework reference directory, the directories containing the dependencies of your project and the directories added to the reference path of your project (tab Reference Path in the Visual Studio project properties dialog box).
SkipPostSharp | True if PostSharp should not be executed.
PostSharpOptimizationMode | When set to OptimizeForBuildTime, PostSharp will use a faster algorithm to generate the final assembly. The other possible value is OptimizeForSize. The default value of the PostSharpOptimizationMode property is OptimizeForBuildTime by default and OptimizeForSize when the C# or VB compiler is set to generate optimal code (typically, in release builds).
PostSharpDisabledMessages | Comma-separated list of warnings and messages that should be ignored.
PostSharpEscalatedMessages | Comma-separated list of warnings that should be escalated to errors. Use * to escalate all warnings.
PostSharpLicense | License key or URL of the license server.
PostSharpProperties | Additional properties passed to the PostSharp project, in format Name1=Value1;Name2=Value2. See Well-Known PostSharp Properties.
PostSharpConstraintVerificationEnabled | Determines whether verification of architecture constraints is enabled. The default value is True.

Hosting Properties

Because PostSharp not only reads, but also executes the assemblies it transforms, it must run under the proper version and processor architecture of the CLR. Additionally, for each version and processor architecture. The following properties allow to influence the choice of the PostSharp host process.

Property Name

Description

PostSharpTargetFrameworkVersion

Version of the CLR that hosts the PostSharp process. The only valid value is 4.0.

PostSharpTargetProcessor

Processor architecture of the PostSharp hosting process. Valid values are x86 and x64. Since PostSharp needs to execute the current project during build, the processor architecture of the PostSharp process must be compatible with the target platform of the current project. The default value is x86, or x64 if the target platform of the current project is x64.

PostSharpHost

Kind of process hosting PostSharp. This setting is usually changed for troubleshooting only. The following values are supported:

  • PipeServer means that PostSharp will run as a background process invoked synchronously from MSBuild. Using the pipe server results in lower build time, since PostSharp would otherwise have to be started every time a project is built. The pipe server uses native code and the CLR Hosting API to control the way assemblies are loaded in application domains; the assembly loading algorithm is generally more accurate and predictable than with the managed host.

  • Native uses the same native code as the pipe server, but the process runs synchronously and terminates immediately after an assembly has been processed. For this reason, it does not have the same build-time performance as the pipe server, but it has exactly the same assembly loading algorithm and is useful for diagnostics.

  • Managed is a purely managed application. The assembly loading algorithm may be less reliable in some situations because PostSharp has less control over it. Note that this host is no longer being tested and officially supported.

PostSharpBuild

Build configuration of PostSharp. Valid values are Release, Diag and Debug. Only the Release build is distributed in the normal PostSharp packages.

PostSharpHostConfigurationFile

A semicolon-separated list of configuration files containing assembly binding redirections that should be taken into account by the PostSharp hosting process, such as app.config or web.config.

Diagnostic Properties

Property Name | Description
PostSharpAttachDebugger | If this property is set to True, PostSharp will break before starting execution, allowing you to attach a debugger to the PostSharp process. The default value is False. For details, see Attaching a Debugger at Build Time.
PostSharpTrace | A semicolon-separated list of trace categories to be enabled. The property is effective only when PostSharp runs in diagnostic mode (see property PostSharpBuild here above). Additionally, the MSBuild verbosity should be set to detailed at least. For details, see Attaching a Debugger at Build Time.
PostSharpUpdateCheckDisabled | True if the periodic update check mechanism should be disabled, False otherwise.
PostSharpExpectedMessages | A semicolon-separated list of codes of expected messages. PostSharp will return a failure code if any expected message was not emitted. This property is used in unit tests of aspects, to ensure that the application of an aspect results in the expected error message.
PostSharpIgnoreError | If this property is set to True, the PostSharp MSBuild task will succeed even if PostSharp returns an error code, allowing the build process to continue. The project or targets file can check the value of the ExitCode output property of the PostSharp MSBuild task to take action.
PostSharpFailOnUnexpectedMessage | This property should be used jointly with PostSharpExpectedMessages. If it set to True, PostSharp will fail if any unexpected message was emitted, even if this message was not an error. This property is used in unit tests of aspects, to ensure that the application of an aspect did not result in other messages than expected.

Other Properties

Property Name | Description
PostSharpProject | Location of the PostSharp project (*.psproj) to be executed by PostSharp, or the string None to specify that PostSharp should not be invoked. If this property is defined, the standard detection mechanism based on references to the PostSharp.dll is disabled.
PostSharpUseHardLink | Use hard links instead of file copies when creating the snapshot for Visual Studio Code Analysis (FxCop). This property is True by default.
ExecuteCodeAnalysisOnPostSharpOutput | When set to True, executes Microsoft Code Analysis on the output of PostSharp. By default, the analysis is done on the input of PostSharp, i.e. on the output of the compiler. This property has no effect when Microsoft Code Analysis is disabled for the current build.
PostSharpCopyCodeAnalysisDependenciesDisabled | When set to True, PostSharp will not copy the all dependencies of the current project output into the obj\Debug\Before-PostSharp directory, which contains the copy of the assembly on which Microsoft Code Analysis is executed by default. This property has no effect when Microsoft Code Analysis is disabled for the current build or when the ExecuteCodeAnalysisOnPostSharpOutput property has been set to True.


Working with PostSharp Configuration Files

Working with PostSharp Configuration Files

PostSharp is designed as a modular post-compilation platform, whose functionality can be extended using plug-ins. For instance, the Diagnostics Pattern Library is implemented as a plug-in. Although writing custom plug-ins is out of scope of this documentation, you should be able, as a PostSharp user, to understand how plug-ins can be added to a project and how they can be configured.

This topic contains the following sections.

  • PostSharp configuration files
  • Sharing configuration between projects
  • Order of processing of configuration files
PostSharp configuration files

The configuration system of PostSharp is based on configuration files.

By default, if you have a project named MyProject.csproj, PostSharp will try to load, from the same directory, a configuration file, named MyProject.psproj. Configuration file is optional. Most projects don't need it.

See Configuration File Schema Reference for details about the format of this file.

For instance, the following code is the configuration file of a project using two plug-ins:

Copy
<Project xmlns="http://schemas.postsharp.org/1.0/configuration">

  <Property Name="LoggingBackend" Value="nlog" />

  <Using File="..\..\Build\bin\{$Configuration}\PostSharp.Patterns.Diagnostics.Weaver.dll"/>
  <Using File="..\..\Build\bin\{$Configuration}\PostSharp.Patterns.Diagnostics.Weaver.NLog.dll"/>

  <Multicast>
    <LogAttribute xmlns="clr-namespace:PostSharp.Patterns.Diagnostics;assembly:PostSharp.Patterns.Diagnostics"
                  AttributeTargetTypes="PostSharp.Patterns.Diagnostics.Tests.NLog.Person" />
  </Multicast>

</Project>

The principal use cases for end-users are the following:

  • Adding license keys. See the License configuration element for details.

  • Configuring properties. See the Property configuration element for details.

  • Including a plug-in. See the Using configuration element for details.

  • Adding aspects or constraints without modifying source code. See Adding Aspects Using XML for details.

  • Editing logging profiles. See Configuration File Schema Reference and Walkthrough: Customizing Logging for details.

Sharing configuration between projects

You will often want to share some configuration settings between several projects. A typical example is to add the license key to all projects of your source code repository.

This can be achieved by adding a well-known configuration file to your source tree, or thanks to the Using configuration element.

Well-known configuration files

PostSharp will automatically load a few well-known configuration files if they are present on the file system, in the following order:

  1. Any file named postsharp.config located in the directory containing the MSBuild project file (csproj or vbproj, typically), or in any parent directory, up to the root. These files are loaded in ascending order, i.e. up from the root directory to the project directory.

  2. Any file named MySolution.pssln located in the same directory as the solution file MySolution.sln .

  3. Any file named MyProject.psproj located in the same directory as the project file MyProject.csproj or MyProject.vbproj .

For instance, the files may be loaded in the following order:

  1. c:\src\BlueGray\postsharp.config

  2. c:\src\BlueGray\FrontEnd\postsharp.config

  3. c:\src\BlueGray\FrontEnd\BlueGray.FrontEnd.Web\postsharp.config

  4. c:\src\BlueGray\Solutions\BlueGray.pssln assuming that the current solution file is c:\src\BlueGray\Solutions\BlueGray.sln.

  5. c:\src\BlueGray\FrontEnd\BlueGray.FrontEnd.Web\BlueGray.FrontEnd.Web.psproj assuming that the current project file is c:\src\BlueGray\Solutions\BlueGray.sln.

Explicit configuration sharing

The second technique to share a configuration file among several projects is to use the Using configuration element to import a configuration file into another configuration file.

Order of processing of configuration files

Elements of configuration files are processed in the following order:

  1. License elements are loaded.

  2. Property elements are loaded. Properties are evaluated at this moment, unless they are marked for deferred evaluation.

  3. SearchPath elements are loaded.

  4. Using elements are loaded and referenced plug-ins and configuration files are immediately loaded.

  5. SectionType elements are loaded.

  6. Service elements are loaded, but they are not yet instantiated.

  7. Extension elements are loaded, but they are not evaluated at this moment.

  8. Finally, services and other tasks are instantiated and the project is executed.


Configuration File Schema Reference

Configuration File Schema Reference

The basic format of a PostSharp configuration file is as follows:

Copy
<Project xmlns="http://schemas.postsharp.org/1.0/configuration" xmlns:x="http://schemas.postsharp.org/1.0/configuration">

  <!-- The following elements must appear in the proper order. -->

  <License Value="[<license-key>|<url>](;[<license-key>|<url>])*"/>

  <SearchPath Directory="<expression:string>(;<expression:string>)*" ReferenceDirectory="<expression:string>" Condition="<expression:bool>" />
  <SearchPath File="<expression:string>(;<expression:string>)*" ReferenceDirectory="<expression:string>" Condition="<expression:bool>" />

  <Using File="<expression:string>" ProjectName="<expression:string>" Condition="<expression:bool>" />

  <SectionType LocalName="<string>" Namespace="<string>" />

  <Property Name="<string>" Value="<expression:string>" Overwrite="[true|false]" Sealed="[true|false]" Deferred="[true|false]" Condition="<expression:bool>" />

  <Service TypeName="<string>" AssemblyFile="<string>" Condition="<expression:bool>" />

  <!-- The rest of the file contains extension elements defined using <SectionType /> elements.
       PostSharp itself defines the following extension elements: -->

  <Multicast>
    <MyMulticastAspect MyAttributeName="<value>" xmlns="clr-namespace:<namespace>;assembly:<assembly>" x:Condition="<expression:bool>" />
  </Multicast>

  <LoggingProfiles xmlns="clr-namespace:PostSharp.Patterns.Diagnostics;assembly:PostSharp.Patterns.Diagnostics" x:Condition="<expression:bool>">
    <LoggingProfile
                Name="<string>"
                OnEntryLevel="<LogLevel>"
                OnSuccessLevel="<LogLevel>"
                OnExceptionLevel="<LogLevel>"
                OnEntryOptions="<LogOptions>"
                OnSuccessOptions="<LogOptions>"
                OnSuccessOptions="<LogOptions>"/>
  </LoggingProfiles>

</Project>
Schema elements

The configuration file includes these elements, described in detail in subsequent sections in this topic:

Project

License

SearchPath

Using

SectionType

Property

Service

Multicast

Project

This element is the root of the configuration file.

License

This element allows to load one or more license keys.

Attribute | Type | Description
Value | string | Required. A semicolon-separated list of license keys, or an URL to the license server.
SearchPath

This element adds a file or a directory to the list of paths in which PostSharp searches for assemblies and plug-ins.

Attribute | Type | Description
File | string expression | Optional (either File or Directory is required). A semicolon-separated list of files that must be added to the path.
Directory | string expression | Optional (either File or Directory is required). A semicolon-separated list of directories that must be added to the path.
ReferenceDirectory | string expression | Optional. The directory from which relative paths in File or Directory are resolved.
Condition | boolean expression | Optional. true if the element is considered, false if it must be ignored.
Using

This element imports another configuration file into the current project.

Attribute | Type | Description
File | string expression | Required. Name of the file to be imported. Unless the name is qualified by a relative or absolute path, the file will be searched for using the search path. In this case, a file with extension psplugin or dll will be searched.
ProjectName | string | Optional. In case that a single dll includes several configurations, specifies which configuration should be loaded.
Condition | boolean expression | Optional. true if the element is considered, false if it must be ignored.
SectionType

This element defines custom sections for the current project. Custom sections can appear under the Project element under all system-defined elements.

Attribute | Type | Description
LocalName | string | Required. The local name of the XML element representing the custom section.
Namespace | string | Required. The namespace of the XML element representing the custom section.
Property

This element defines a property for the current project.

Attribute | Type | Description
Name | string | Required. The property name.
Value | string expression | Required. The value that is assigned to the property.
Overwrite | boolean | Optional. true if the element will overwrite any previously-defined property of the same name, otherwise false. The default value is true.
Sealed | boolean | Optional. true if an attempt to overwrite this property should result in an error, otherwise false. The default value is false.
Deferred | boolean | Optional. true if the expression in the Value attribute should be dynamically evaluated every time the property value is requested, or false if the expression should be set at the time the property is defined. The default value is false.
Condition | boolean expression | Optional. true if the element is considered, false if it must be ignored.
Service

This element registers a service to the service locator for the current project.

Attribute | Type | Description
TypeName | string | Required. The full type name implementing the service. This class must have a public parameterless constructor and implement the IService interface.
AssemblyFile | string expression | Optional. The path of the assembly defining the service class. If the attribute is not provided, the type will be searched for in the assembly being currently processed by PostSharp.
Condition | boolean expression | Optional. true if the element is considered, false if it must be ignored.
Multicast

This element can be used to add aspects, policies or constraints to a project without adding the the C# project as custom attributes. Adding elements to this section is equivalent to adding them to source code at assembly level.

The Multicast section is convenient to add aspect to several projects from a single file.

For details regarding this section, see Including CLR Objects in Configuration.


Well-Known PostSharp Properties

Well-Known PostSharp Properties

The following table lists the PostSharp properties that may be set from the MSBuild project. The second column specifies the name of the MSBuild property that influences the value of the PostSharp property, if any.

Property Name | MSBuild Property Name | Description
Configuration | Configuration | Build configuration (typically Debug or Release).
Platform | Platform | Target processor architecture (typically AnyCPU, x86 or x64).
MSBuildProjectFullPath | MSBuildProjectFullPath | Full path of the C# or VB project being built.
IgnoredAssemblies |  | Comma-separated list of assembly short names (without extension) that should be ignored by the dependency scanning algorithm. Add an assembly to this list if it is obfuscated, or contains native code, and causes PostSharp to fail.
ReferenceDirectory | MSBuildProjectDirectory | Directory with respect to which relative paths are resolved.
SearchPath | PostSharpSearchPath | Comma-separated list of directories containing reference assemblies and plug-ins.
TargetFrameworkIdentifier | TargetFrameworkIdentifier | Identifier of the target framework of the current project (i.e. the framework on which the application will run). For instance .NETFramework or Silverlight.
TargetFrameworkVersion | TargetFrameworkVersion | Version of the target framework of the current project (i.e. the framework on which the application will run). For instance v4.0.
TargetFrameworkProfile | TargetFrameworkProfile | Profile of the target framework of the current project (i.e. the framework on which the application will run). For instance WindowsPhone.

Other properties are recognized but are of little interest for end-users. For a complete list of properties, see PostSharp.targets.

Using custom properties

By defining your own PostSharp properties, you can pass information from the build environment to aspects, or to any code running in PostSharp. Custom PostSharp properties behave exactly as other PostSharp properties, so they can be defined and read using the same procedures.


Including CLR Objects in Configuration

Including CLR Objects in Configuration

PostSharp includes a basic facility to describe CLR objects using XML. This facility is used to implement the Multicast and LoggingProfiles sections of the configuration file, and can be used to define custom sections.

The facility is consciously limited in features. It was only design to provide the same features as custom attributes in programming languages.

This topic contains the following sections.

  • Basic rules
  • Formatting of attributes
  • Specific rules for the Multicast section
Basic rules

The basic rules apply to XML serialized objects:

  • The local name of the XML element must exactly match the type name of the CLR type. An exception to this rule is that the Attribute prefix can be omitted.

  • The XML namespace of the element must be in the form clr-namespace:namespace;assembly:assembly where namespace is the namespace of the CLR type and assembly is the name of the assembly declaring the type.

  • The type must have a public parameterless constructor.

  • Names of XML attributes must exactly match the name of a public field or property of the CLR type.

Formatting of attributes

Values of XML attributes, mapping to CLR fields and properties, must be formatted according to the rule relevant for each type:

Type | Formatting
Intrinsics. | An intrinsic is any of the following types: bool, char, sbyte, byte, short, ushort, int, uint, long, ulong, float, double or string. Conversion is done using the Convert class.
Arrays | A semicolon-separated list of elements.
Enumerations | A list of enumeration member names separated by characters | or +. Names in the list are combined using the + operator.
Types | An assembly-qualified type name.
Object | Fields and properties of type Object are not supported.
Specific rules for the Multicast section

The following additional rules apply to the Multicast section of the configuration file:

  • The class must derive from MulticastAttribute.

  • The AttributePriority property may not be defined. This attribute is added automatically according to the order of the XML element in the section.


Using Expressions in Configuration Files

Using Expressions in Configuration Files

Many attributes of the configuration schema accept expressions, which are dynamically evaluated. Expressions in the PostSharp configuration system work similarly as in XSLT. Substrings enclosed by curled brackets, for instance {$property}, are interpreted as XPath expressions.

For instance, the following code contains two XPath expressions:

Copy
<Project xmlns="http://schemas.postsharp.org/1.0/configuration">
  <Property Name="LoggingEnabled" Value="{has-plugin('PostSharp.Patterns.Diagnostics')}" Deferred="true" />
  <Multicast>
    <When Condition="{$LoggingEnabled}">
      <d:Log  />
    </When>
  </Multicast>
</Project>

Please check the MSDN documentation for general information about XPath.

Note Note

In the context of PostSharp configuration files, XPath expressions cannot refer to XML elements or attributes, but only to variables, functions, operators and constants.

Accessing properties

PostSharp properties are mapped to XPath variables.

For instance, the expression {$LoggingEnabled} evaluates o the value of the LoggingEnabled property.

Using operators and functions

You can use any XPath function and operators.

Additionally to standard XPath 1.0 functions, PostSharp defines the following functions:

Function | Description
has-plugin(name) | Evaluates to true if the given plug-in is loaded, otherwise false.
environment(variable) | Returns the value of an environment variable.
Mixing expressions and literal strings

An attribute value can contain both text and expressions. This is illustrated in the following example:

Copy
<Project xmlns="http://schemas.postsharp.org/1.0/configuration">
  <Property Name="A" Value="A" />            <!-- Evaluates to A -->
  <Property Name="B" Value="B;{$A}" />       <!-- Evaluates to B;A -->
  <Property Name="C" Value="C;{$B};{$A}" />  <!-- Evaluates to C;B;A;A -->
</Project>


Accessing Configuration from Source Code

Accessing Configuration from Source Code

Even if most configuration settings are consumed by PostSharp or its add-in, it is sometimes useful to access configuration elements from user code. The PostSharp.dll library gives access to both configuration properties and extension configuration elements.

This topic contains the following sections.

  • Accessing properties
  • Accessing custom sections
Accessing properties

You can read the value of any PostSharp property by including it in an XPath expression and evaluating it using the EvaluateExpression(String) method of PostSharpEnvironmentCurrentProject:

C#
Copy
string value = PostSharpEnvironment.CurrentProject.EvaluateExpression("{$PropertyName}")

For details regarding expressions, see Using Expressions in Configuration Files.

Accessing custom sections

You can get a list of custom sections of a given name and namespace by calling the GetExtensionElements(String, String) method of PostSharpEnvironmentCurrentProject:

C#
Copy
IEnumerable<ProjectExtensionElement> elements =
     PostSharpEnvironment.CurrentProject.GetExtensionElements( "MyElement", "uri:MyNamespace" );

Extension elements must be declared using the SectionType element.

See Also

Other Resources

Using Expressions in Configuration Files
Working with PostSharp Configuration Files


Working with Errors, Warnings, and Messages

Working with Errors, Warnings, and Messages

As any compiler, PostSharp can emit messages, warnings, and errors, commonly referred to asmessage. Custom code running at build time (typically the implementation of CompileTimeValidate or of a custom constraint) can use PostSharp messaging facility to emit their own messages.

In this section:

  • Ignoring and Escalating Warnings

  • Emitting Errors, Warnings, and Messages.

Tip Tip

PostSharp 2.1 contains an experimental feature that adds file and line information to errors and warnings. The feature requires Visual Studio. In must be enabled manually in the PostSharp tab of Visual Studio options.


Ignoring and Escalating Warnings

Ignoring and Escalating Warnings

As with conventional compilers, warnings emitted by PostSharp, as well as those emitted by custom code running at build time in PostSharp, can be ignored (in that case they will not be displayed) or escalated into errors.

Warnings can be ignored either globally, using a project-wide setting, or locally for a given element of code. Warnings can be escalated only globally.

Ignoring or escalating warnings globally

There are several ways to ignore or escalate a warning for a complete project:

  • In Visual Studio, in the PostSharp tab of the project properties dialog. See Configuration for details.

  • By defining the PostSharpDisabledMessages or PostSharpEscalatedMessages MSBuild properties. See Configuration and Configuring Projects Using MSBuild for details.

  • By using the DisablePostSharpMessageAttribute or EscalatePostSharpMessageAttribute custom attribute at assembly level. This approach is considered obsolete.

Note Note

The value * can be used to escalate all warnings into errors.

Ignoring warnings locally

Most warnings are related to a specific element of code. To disable a specific warning for a specific element of code, add the IgnoreWarningAttribute custom attribute to that element of code, or to any enclosing element of code (for instance, adding the attribute to a type will make it effective for all members of this type).

To ignore warnings emitted by constraints, it is preferable to use the IgnoreConstraintWarningAttribute custom attribute. Indeed, this attribute is conditional to the compilation symbol POSTSHARP_CONSTRAINTS, so it will be ignored by the compiler unless constraint verification is enabled for the current project and build configuration.

You can create your own custom attribute derived from IgnoreWarningAttribute and make it conditional to a compilation symbol by using the ConditionalAttribute custom attribute.


Emitting Errors, Warnings, and Messages

Emitting Errors, Warnings, and Messages

Custom code running in PostSharp at build time can use the messaging facility to emit its own messages, warnings, and errors. These messages will appear in the MSBuild output and/or in Visual Studio. User-emitted warnings can be ignored or escalated using the same mechanism as for system messages.

Emitting messages

If you just have a few messages to emit, you may simply use one of the overloads of the Write method of the Message class.

All messages must have a severity SeverityType, a message number (used as a reference when ignoring or escalating messages), and a message text. Additionally, and preferably, messages may have a location (MessageLocation).

Note Note

To benefit from the possibility to ignore messages locally, you should always use provide a relevant location with your messages. Previous API overloads, which did not require a message location, are considered obsolete.

Tip Tip

Do not use string.Format to format your messages. Instead, pass message arguments to the messaging facility, which will format some argument types, for instance reflection objects, in a more readable way.

Emitting messages using a message source

If you want the text of all messages to be stored in a single location, you have to emit messages through a MessageSource. Typically, you would create a singleton instance of MessageSource for each component, and associate each instance with a message dispenser. A message dispenser is a custom-written class implementing the IMessageDispenser interface. The MessageDispenser provides a convenient abstract implementation.

Note Note

Although it is tempting to use a ResourceManager as the back-end of a message dispenser, comes with a non-negligible performance penalty because of the cost of instantiating the ResourceManager.


Standard Patterns

Standard Patterns

PostSharp offers ready-made implementation of several of the most common patterns.

You can read this part from start to end to learn about what PostSharp makes possible, or jump directly to the chapters that covers the patterns you are interested in.

This part includes the following chapters:

Chapter | Description
INotifyPropertyChanged | This chapter explains how to automatically implement the INotifyPropertyChanged interface.
Parent/Child Relationships | This chapter describes the Aggregatable pattern, which automatically implement parent/child relationships. This pattern is the foundation of the Recordable pattern (undo-redo) and threading models.
Undo/Redo | This chapter describes the Recordable pattern, implementing the undo/redo feature.
Contracts | This chapter shows how to add code contracts as custom attributes to fields, parameters and properties.
Logging | This chapter describes how to instrument your applications.
Adding Aspects to Code | This chapter shows advanced techniques to add aspects to your code.


INotifyPropertyChanged

INotifyPropertyChanged

Binding objects to the UI is a large and tedious task. You must implement INotifyPropertyChanged on every property that needs to be bound. You need to ensure that the underlying property setter correctly raises events so that the View knows that changes have occurred. The larger your codebase, the more work there is. You can partially eliminate all of this repetitive code by pushing some of the functionality to a base class that each Model class inherits from. It still doesn't eliminate all of the repetition though.

PostSharp can completely eliminate all of that repetition for you. All you have to do is make use of the Model Pattern Library's NotifyPropertyChangedAttribute aspect.

In this chapter
Topic | Description
Walkthrough: Automatically Implementing INotifyPropertyChanged | This section shows how to automatically implement the INotifyPropertyChanged aspect in a class thanks to the NotifyPropertyChangedAttribute aspect.
Walkthrough: Working with Properties that Depend on Other Objects | This section describes how to handle dependencies that cross several objects, as when a view-model object is dependent on properties of a model object.
Customizing the NotifyPropertyChanged Aspect | This section documents how to cope with the cases that cannot be automatically handled by the NotifyPropertyChangedAttribute aspect.
Understanding the NotifyPropertyChanged Aspect | This section describes the principles and concepts on which the NotifyPropertyChangedAttribute aspect relies.


Walkthrough: Automatically Implementing INotifyPropertyChanged

Walkthrough: Automatically Implementing INotifyPropertyChanged

This section shows how to make your class automatically implements the INotifyPropertyChanged interface NotifyPropertyChangedAttribute aspect.

Let's start with a simple class that has two simple properties and one composite property:

C#
Copy
public class CustomerForEditing
{
    public string FirstName { get; set; }
    public string LastName { get; set; }

    public string FullName
    {
        get { return string.Format("{0} {1}", this.FirstName, this.LastName);}
    }
}

This topic contains the following sections.

  • Adding the NotifyPropertyChanged aspect with the UI
  • Adding the NotifyPropertyChanged aspect manually
  • See Also
Adding the NotifyPropertyChanged aspect with the UI

To add INotifyPropertyChanged aspect with the UI:

  1. Put the caret on the class name and expand the Smart Tag. From the list select "Implement INotifyPropertyChanged".

    INotify Property Changed 1

  2. If you haven't previously added the Model Pattern Library to the current project, PostSharp will inform you that it will be doing this as well as adding an attribute to the target class.

    INotify Property Changed 2

  3. PostSharp will download the Model Pattern Library and add the attribute.

    INotify Property Changed 3

  4. Once the download, installation and configuration of the Model Pattern Library and the addition of the attribute has finished you can close the wizard and look at the changes that were made to your codebase.

    INotify Property Changed 4

  5. You'll notice that the code you added NotifyPropertyChangedAttribute to has only been slightly modified. PostSharp has added a NotifyPropertyChangedAttribute attribute to the class. This class level attribute will add the implementation of NotifyPropertyChangedAttribute to the class as well as the plumbing code in each property that makes it work.

    C#
    Copy
    [NotifyPropertyChanged]
public class CustomerForEditing
{
    public string FirstName { get; set; }
    public string LastName { get; set; }

    public string FullName
    {
        get { return string.Format("{0} {1}", this.FirstName, this.LastName); }
    }

}
    Note Note

    This example has added NotifyPropertyChangedAttribute to one class. If you need to implement NotifyPropertyChangedAttribute to many different classes in your codebase you will want to read about using aspect multicasting. See the section Adding Aspects to Multiple Declarations.

By using the Model Pattern Library to add NotifyPropertyChangedAttribute to your Model classes you are able to eliminate all of the repetitive boilerplate coding tasks and code from the codebase.

Adding the NotifyPropertyChanged aspect manually

The wizard does nothing more than installing a NuGet package and adding a custom attribute. You can achieve the same manually.

To add INotifyPropertyChanged aspect manually:

  1. Use NuGet Package Manager to add the PostSharp.Patterns.Model package to your project.

  2. Import the PostSharp.Patterns.Model namespace into your file.

  3. Add the [NotifyPropertyChanged] custom attribute to the class.

See Also

Reference

INotifyPropertyChanged
NotifyPropertyChangedAttribute

Other Resources

Adding Aspects to Multiple Declarations


Walkthrough: Working with Properties that Depend on Other Objects

Walkthrough: Working with Properties that Depend on Other Objects

It’s very common for the properties of one class to be dependent on the properties of another class. For example, a view-model layer will often contain a reference to a model object, and public properties which are in turn forwarded to the underlying properties of this referenced object. In this scenario the view-model component’s properties have a dependency on the referenced model’s properties. Subsequently the referenced model may also have properties which depend on the properties of other objects.

PostSharp’s Model Pattern Library easily handles transitive dependencies. Simply add the NotifyPropertyChangedAttribute class attribute to each class in the dependency chain. This will ensure that property change notifications are propagated up and down the dependency chain. The Model Pattern Library takes care of the rest and will even handle circular dependencies.

In the following set of steps, the CustomerModel class is used as a dependency of a CustomerViewModel class containing FirstName and LastName properties both of which directly map to properties of the CustomerModel class, and a public read only property called FullName, which is calculated based on the value of the underlying customer’s FirstName and LastName properties.

  1. Add the CustomerModel class to your project ensuring that the NotifyPropertyChangedAttribute attribute is included:

    C#
    Copy
    [NotifyPropertyChanged]
public class CustomerModel
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Phone { get; set; }
    public string Mobile { get; set; }
    public string Email { get; set; }
}

  2. Setup a view-model class which contains a reference to a CustomerModel object, add properties to get/set the name related fields. References to properties of the CustomersForEditing object should be in the form of this.field.Property (or this.Property.Property), otherwise PostSharp won’t be able to discover the dependencies from your source code.

    C#
    Copy
    class CustomerViewModel
{
    CustomerModel model;

    public CustomerViewModel(CustomerModel m)
    {
        this.model = m;
    }

    public string FirstName { get { return this.model.FirstName; } set { this.model.FirstName = value;}}

    public string LastName { get { return this.model.LastName; } set { this.model.LastName = value; }}

}

  3. Add the FullName property and use the same rule as described in the previous step to reference dependent properties:

    C#
    Copy
    class CustomerViewModel
{
    CustomerModel model;

    public CustomerViewModel(CustomerModel m)
    {
        this.model = m;
    }
    public string FirstName { get { return this.model.FirstName; } set { this.model.FirstName = value;}}
    public string LastName { get { return this.model.LastName; } set { this.model.LastName = value; }}

    public string FullName { get {
      return string.Format("{0} {1}", this.model.FirstName, this.model.LastName);
    } }

 }

  4. Add the NotifyPropertyChangedAttribute attribute to the class:

    C#
    Copy
    [NotifyPropertyChanged]
class CustomerViewModel
{
    CustomerModel model;

    public CustomerViewModel(CustomerModel m)
    {
        this.model = m;
    }

    public string FirstName { get { return this.model.FirstName; } set { this.model.FirstName = value;}}
    public string LastName { get { return this.model.LastName; } set { this.model.LastName = value; }}

    public string FullName { get {
      return string.Format("{0} {1}", this.model.FirstName, this.model.LastName);
    } }

}

You now have a view-model class which can be used to bridge a view (e.g. an application’s user interface) with the underlying data, and calls to get/set will be propagated across the chain of dependencies.

Note Note

Read the article Customizing the NotifyPropertyChanged Aspect to learn about referencing properties without using the this.field.Property form.

See Also

Reference

NotifyPropertyChangedAttribute

Other Resources

Customizing the NotifyPropertyChanged Aspect


Customizing the NotifyPropertyChanged Aspect

Customizing the NotifyPropertyChanged Aspect

Postsharp includes a number of attributes for customizing the Model Pattern’s behaviour and for handling special dependencies.

This topic contains the following sections.

  • Ignoring Changes to Properties
  • Handling Virtual Calls, References, and Delegates in a Get Accessor
  • Handling Local Variables
  • Handling Dependencies on Pure Methods
Ignoring Changes to Properties

Use the IgnoreAutoChangeNotificationAttribute class attribute to prevent an OnPropertyChanged event from being invoked when setting a property. For example, the CustomerModel class contains a Country property amongst others:

C#
Copy
[NotifyPropertyChanged]
public class CustomerModel
{
    public string FirstName { get; set; }
    public string LastName { get; set; }

    public string Phone { get; set; }
    public string Mobile { get; set; }
    public string Email { get; set; }
    public string Country { get; set;}
}

To prevent a property notification from being invoked when the Country’s value is set, simply place the IgnoreAutoChangeNotificationAttribute attribute above the property:

C#
Copy
[NotifyPropertyChanged]
public class CustomerModel
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Phone { get; set; }
    public string Mobile { get; set; }
    public string Email { get; set; }

    [IgnoreAutoChangeNotification]
    public string Country { get; set;}
}
Handling Virtual Calls, References, and Delegates in a Get Accessor

If a get accessor calls a virtual method from its class or a delegate, or references a property of another object (without using canonical form this.field.Property), PostSharp will generate an error because it cannot resolve such a dependency at build time. To suppress this error, you can add the [SafeForDependencyAnalysisAttribute] custom attribute to the property accessor (or in any method used by the property accessor). This custom attribute instructs PostSharp that the property accessor is “safe” – in other words, it contains only dependencies in the canonical form this.field.Property.

For example, say CustomerModel contains a virtual method called ValidateCountry() which is used by the get accessor of its Country property:

C#
Copy
[NotifyPropertyChanged]
public class CustomerModel
{
  // Details skipped.

protected virtual bool ValidateCountry(string s)
{
  if (s!=null)
    return true;
  else
    return false;
}

  public string Country
  {
    get
    {
      if(this.ValidateCountry(value))
        return value;
      else
       return null;
    }
    set;
  }
}

In this situation the property relies on a virtual method which PostSharp cannot resolve at build time, so the SafeForDependencyAnalysisAttribute attribute can be placed on the Country property suppress this error:

C#
Copy
[NotifyPropertyChanged]
public class CustomerModel
{
   // Details skipped.

  public virtual bool Test(string s)
  {
    if (s!=null)
      return true;
    else
      return false;
  }

  [SafeForDependencyAnalysisAttribute]
  public string Country
  {
    get
    {
      if(this.test(value) == true)
        return value;
      else
       return null;
    }
    set;
  }
}
Note Note

By using SafeForDependencyAnalysisAttribute, you are taking the responsibility that your code only has dependencies that are given either in the canonical form of this.field.Property either explicitly using the On construct (see the next section). If you are using this custom attribute but have non-canonical dependencies, some property changes may not be detected in which case no notification will be generated.

Handling Local Variables

Properties may depend on a property of another object, and sometimes this object must be stored in a local variable. PostSharp is not able to analyze chains of dependencies in properties that are dependent on a property of a local variable.

For example, consider the following version of CustomerModel which contains properties for primary and secondary contact phone numbers, each of which is of type Contact, as well a string property called ValidPhoneNumber which attempts to return a non-null phone number:

C#
Copy
public class Contact
{
  public string Phone {get; set;}
}

[NotifyPropertyChanged]
public class CustomerModel
{
  public Contact PrimaryContact{get; set;}
  public Contact SecondaryContact{get; set;}

  public string ValidPhoneNumber
  {
    Contact contact = null;
    if(PrimaryContact != null)
      contact = PrimaryContact;
    else
      contact = SecondaryContact;

    if(contact != null)
      return contact.Phone;
    else
      return null;
  }
}

In this situation the local variable contact cannot be analyzed, so the dependency must be explicitly specified using the DependsOn method:

C#
Copy
[NotifyPropertyChanged]
public class CustomerModel
{
  public Contact PrimaryContact{get; set;}
  public Contact SecondaryContact{get; set;}

  [SafeForDependencyAnalysis]
  public string ValidPhoneNumber
  {
    Depends.On(this.PrimaryContact.Phone, this.SecondaryContact.Phone);
    Contact contact = null;
    if(PrimaryContact != null)
      contact = PrimaryContact;
    else
      contact = SecondaryContact;

    if(contact != null)
      return contact.Phone;
    else
      return null;
  }
}
Note Note

The SafeForDependencyAnalysisAttribute attribute is still required in order to suppress the error about the dependency on a local variable.

Handling Dependencies on Pure Methods

Often times an object will depend on a method which is solely dependent on its input parameters to produce an output (e.g. a static method). Consider the following variation to CustomerModel where the ValidPhoneNumber property logic has been moved into a static method called GetValidPhoneNumber() which exists in a separate helper class called ContactHelper:

C#
Copy
public class ContactHelper
{
  [Pure]
  public static string GetValidPhoneNumber(string firstPhoneNumber, string secondPhoneNumber)
  {
    if(firstPhoneNumber != null)
      return firstPhoneNumber;
    else if (secondPhoneNumber != null)
      return secondPhoneNumber;
    else
      return null;
  }
}

[NotifyPropertyChanged]
public class CustomerModel
{
  public Contact PrimaryContact{get; set;}
  public Contact SecondaryContact{get; set;}

  public string ValidPhoneNumber
  {
    get {
      return ContactHelper.GetValidPhoneNumber(this.PrimaryContact.Phone, this.SecondaryContact.Phone);
    }
  }
}

Since GetValidPhoneNumber() is a standalone method of another class, it is not analyzed. Therefore the PureAttribute attribute needs to be applied to this method to acknowledge this dependency.

See Also

Reference

PureAttribute
IgnoreAutoChangeNotificationAttribute
SafeForDependencyAnalysisAttribute
DependsOn
Depends


Understanding the NotifyPropertyChanged Aspect

Understanding the NotifyPropertyChanged Aspect

This section describes the principles and algorithm on which the NotifyPropertyChangedAttribute aspect is based. It helps developers and architects to understand the behavior and limitation of the aspect.

This topic contains the following sections.

  • Implementation of the INotifyPropertyChanged interface
  • Instrumentation of fields
  • Analysis of field-property dependencies
  • Limitations
  • Raising notifications
  • Remarks
Implementation of the INotifyPropertyChanged interface

The NotifyPropertyChangedAttribute aspect introduces the INotifyPropertyChanged interface to the target class unless the target class already implements the interface. Additionally, the aspect also introduces the OnPropertyChanged(String) method. The aspect always introduces this method as protected and virtual, so it can be overridden in derived classes.

If the target class already implements the INotifyPropertyChanged interface, the aspect requires the class to expose the OnPropertyChanged(String) method.

The aspect uses the OnPropertyChanged(String) to raise the PropertyChanged event. Thanks to this method, the aspect is able to raise the event even when the INotifyPropertyChanged is not implemented by the aspect. This mechanism also allows user code to raise notifications that are not automatically handled by the NotifyPropertyChangedAttribute aspect.

Instrumentation of fields

Although most implementations the INotifyPropertyChanged interface rely on instrumenting the property setter, this strategy has severe limitations: it is unable to handle composite properties, which return a value based on several other fields or properties. Composite properties have no setter, rendering this strategy unusable.

Instead, the NotifyPropertyChangedAttribute aspect instruments all write operations to fields (for instance a FullName property appending FirstName and LastName). It analyzes dependencies between fields and properties and raises a change notification for any property affected by a change in this specific field.

All methods, and not just property setters, can make a change to a field and therefore cause the PropertyChanged event to be raised. Property setters do not have any specific status in the NotifyPropertyChangedAttribute implementation.

Analysis of field-property dependencies

In order to adequately raise the PropertyChanged event, the NotifyPropertyChangedAttribute aspect needs to know which properties are affected by a change of a class field. The field-property dependency map is created at build time by analyzing the source code: the analyzer reads the getter of all properties and check for field references. The map is then serialized inside the assembly and used at runtime to raise relevant events when a field has changed.

Dependencies on fields of the current object

Consider the following code snippet:

C#
Copy
[NotifyPropertyChanged]
class Invoice
{
  private decimal _amount;
  private decimal _tax;

  public decimal Amount { get { return this._amount; } set { this._amount = value; } }
  public decimal Tax { get { return this._tax; } set { this._tax = value; } }

  public void Set( decimal amount, decimal tax )
  {
     this._amount = amount;
     this._tax = tax;
  }

  public decimal Total { get { return this._amount + this._tax; } }
}

The result of the analysis for the code snippet above would be the map { _amount => ( Amount, Total ), _tax => ( Tax, Total ) }. Whenever the _amount field is changed, the PropertyChanged event will be raised for properties Amount and Total.

Automatic properties are processed as hand-written properties; in this case, the implicit backing field is taken into account for the dependency analysis.

Recursive analysis of the call graph

Field references are not only looked for in the getter, but in any method invoked from the getter, and recursively.

Consider the following code snippet:

C#
Copy
[NotifyPropertyChanged]
class Invoice
{
  private decimal _amount;
  private decimal _exchangeRate;

  public decimal Amount { get { return this._amount; } set { this._amount = value; } }
  public decimal ExchangeRate { get { return this._exchangeRate; } set { this._exchangeRate = value; } }

  private decimal Convert( decimal amount )
  {
    return amount * this.ExchangeRate;
  }

  public int AmountBase { get { return this.Convert( this.Amount ); } }

}

In the code snippet above, the analyzer starts from the getter of the AmountBase property, follows the call to the Amount property getter, then call to the AmountBase method and recursively follows the ExchangeRate property getter. Therefore, the resulting property map remains { _amount => ( Amount, AmountBase ), _exchangeRate => ( ExchangeRate, AmountBase ) }.

Dependencies on properties of external objects

The NotifyPropertyChangedAttribute aspect does not just handle dependencies between a property and a field of the same class. It also handles dependencies on properties of properties or properties of fields, and recursively. That is, it supports expressions of the form _f.P1.P2.P3 where _f is a field or property and P1, P2 and P3 are properties.

Consider the following code snippet:

C#
Copy
[NotifyPropertyChanged]
class InvoiceModel
{
  private decimal _amount;
  private decimal _tax;

  public decimal Amount { get { return this._amount; } set { this._amount = value; } }
  public decimal Tax { get { return this._tax; } set { this._tax = value; } }
}

[NotifyPropertyChanged]
class InvoiceViewModel
{
  InvoiceModel _model;

  public InvoiceModel Model { get { return this._model; } }

  public decimal Total { get { return this._model.Amount + this.Model.Tax; } }

}

In the example above, the InvoiceViewModel.Total property is dependent on properties Amount and Tax of the _model field. Therefore, changes in the InvoiceModel._amount field will trigger a change notification for the InvoiceModel.Amount and InvoiceViewModel.Total properties.

The NotifyPropertyChangedAttribute aspect automatically subscribes to the PropertyChanged event of the child object, and unsubscribes whenever the value of the field in the parent object (_model in our example) is modified. However, the parent object does not unsubscribe upon disposal because the NotifyPropertyChangedAttribute makes no assumption that the IDisposable interface has been implemented. Therefore, the implementation of the INotifyPropertyChanged of the external object must hold weak references to clients of the PropertyChanged event.

Recursive dependencies to external objects are handled thanks to an auxiliary interface named INotifyChildPropertyChanged. This interface is implemented by the NotifyPropertyChangedAttribute aspect. It is considered an implementation detail and cannot be implemented manually. Classes that do not implement the INotifyChildPropertyChanged interface can only participate as terminal dependencies, i.e. they can be leaves but not intermediate nodes.

Limitations

The design goal of the NotifyPropertyChangedAttribute aspect is to be able to handle the majority of use cases in real-world source code while requiring only an acceptable amount of compilation time. The dependency analysis algorithm imposes several limitations:

  • Calls to virtual methods (other than through the base keyword), abstract methods, interface methods or delegates are not supported.

  • Calls to static methods or methods of external classes are not supported unless they are decorated with the PureAttribute custom attribute, or unless the method is a property getter in a supported dependency chain.

  • Valuations of properties of local variables or method return values are not supported. Only properties of fields or properties are supported.

See Customizing the NotifyPropertyChanged Aspect to learn how to cope with these limitations.

Raising notifications

Simplistic implementations of the INotifyPropertyChanged interface signal a change notification immediately after a property has been changed. However, this strategy may cause subtle errors in client code.

Consider the following code:

C#
Copy
[NotifyPropertyChanged]
class Invoice
{
  public decimal Amount { get; private set; }
  public decimal Tax { get; private set; }
  public decimal Total { get; private set; }

  public void Set( decimal amount, decimal tax )
  {
    /* 1 */ this.Amount = amount;
    /* 2 */ this.Tax = tax;
    /* 3 */ this.Total = amount + tax;
  }

}

As a class invariant, the assumption Total == Amount + Tax should always be true.

However, suppose that the PropertyChanged event is raised immediately after the Amount property is set at line 1 of the Set method. Clearly, for a client subscribing to this event, the class invariant would be broken at this specific moment.

Therefore, it is not safe to raise change notifications immediately after a change has been achieved. It is necessary to wait until the object can be safely observed by external code, when all class invariants are valid again (i.e. when the object state is consistent). A common best practice in object-oriented programming is to ensure that class invariants are valid before the control flow goes back from the current object to the caller. Typically, it means that a private or protected method can exit with an inconsistent object state, but public and internal methods must guarantee that the object state is consistent upon exit.

The NotifyPropertyChangedAttribute aspect relies on this best practice and raises the property change notifications just before the control flow exists the current object, that is, just before the last public or internal method in the call stack for the current object exits.

Besides avoiding to expose invalid object state, this strategy also avoids the same property to be notified for change several times during the execution of a single public method, which a potentially great positive performance impact.

To solve this problem, NotifyPropertyChangedAttribute aspect uses the following strategy:

  1. Instead of causing immediate change notifications, field changes are buffered into a thread-local storage named the accumulator .

  2. Calls to public and methods are instrumented so the aspect can detect when the control flow exits the object. At this moment, the accumulator is flushed and all change notifications are triggered.

It is possible to flush the accumulator at any time by invoking the NotifyPropertyChangedServicesRaiseEventsImmediate(Object) method.

You can suspend and resume notifications using the NotifyPropertyChangedServicesSuspendEvents and NotifyPropertyChangedServicesResumeEvents methods.

Remarks

The NotifyPropertyChangedAttribute aspect never evaluates property getters at runtime. This decision is deliberate and aims at avoiding possible side-effects (lazy-initialization, logging, etc.). Therefore, it is possible that the algorithms emit false positives, i.e. change notifications for properties whose values did not actually change.

The algorithm heuristically detects dependency cycles. If a cycle is detected, an exception is thrown instead of allowing for an infinite update cycle.

All notifications are invoked on the thread on which the change is being made. The accumulator that buffers the changes is a thread-local storage.


Parent/Child Relationships

Parent/Child Relationships

The parent-child relationship is a foundational concept of object oriented design. There are three kinds of object relationships in the UML specification:

  • Aggregation is the parent-child (also named whole-part) relationship. It is implemented in PostSharp by the AggregatableAttribute aspect described in Walkthrough: Annotating an Object Model for Parent-Child Relationships.

  • Composition is an aggregation relationship where the parent controls the lifetime their children. It is implemented in PostSharp by the DisposableAttribute aspect pattern, which relies on the AggregatableAttribute aspect. For details, see Walkthrough: Automatically Disposing Children Objects.

  • Association is a simple reference between two objects.

Despite its importance, C# and VB have no keyword to represent aggregation. All C# and VB object references correspond to an association. Therefore, most applications and frameworks tend to re-implement the aggregation relationship, resulting in boilerplate code and defects. For instance, UI frameworks such as WinForms and WPF rely on a parent-child structure.

PostSharp implements the Aggregatable pattern thanks to the AggregatableAttribute aspect, together with the ChildAttribute, ReferenceAttribute and ParentAttribute custom attributes.

The Aggregatable pattern is used by other PostSharp aspects, including all threading models (ThreadAwareAttribute), DisposableAttribute and RecordableAttribute. You can also use the aspect to automatically implement a parent-child relationship in your own code.

In this chapter
Section | Description
Walkthrough: Annotating an Object Model for Parent-Child Relationships | This section shows how to prepare a class so that it can participate in a parent-child relationship.
Walkthrough: Enumerating Child Objects | This section describes how to enumerate the children of an object thanks to the visitor pattern.
Walkthrough: Automatically Disposing Children Objects | This section shows how to automatically implement the IDisposable interface so that children objects are disposed when the parent object is disposed.
Working With Collections | This section covers advanced topics related to collections in aggregatable object models.


Walkthrough: Annotating an Object Model for Parent-Child Relationships

Walkthrough: Annotating an Object Model for Parent-Child Relationships

PostSharp provides several custom attributes that you can apply to your object model to describe the parent-child relationships in a natural and concise way. The AggregatableAttribute aspect is applied to the object model classes, and the properties are marked with ChildAttribute, ReferenceAttribute and ParentAttribute custom attributes. You can also use AdvisableCollectionT and AdvisableDictionaryTKey, TValue classes to make your collection properties aware of the Aggregatable pattern.

Below you can find a detailed walkthrough on how to add parent-child relationships implementation into existing object models.

This topic contains the following sections.

  • Applying through the UI
  • Applying manually
Applying through the UI

When applying any of the threading model patterns using the wizard you may encounter the Relationships page.

This page provides you with the ability to establish the relationships between objects in an object tree. Simply select the option desired for each complex object and the wizard will add these attributes for you.

Note Note

The wizard process will not address or change collections in the object parent-child relationships. You will need to change collection types by hand.

Applying manually

To apply the Aggregatable to an object model:

  1. Add the AggregatableAttribute attribute to the parent and children classes. In the following examples, an Invoice object owns several instances of the InvoiceLine class, therefore both classes must be annotated with AggregatableAttribute. However, the Invoice does not own the Customer to which it is associated, so the Customer class does not need the custom attribute.

    Note Note

    It is not strictly necessary to add the AggregatableAttribute aspect to a class whose instances will be children but not parents, unless you want to track the relationship to the parent using the IAggregatableParent property or the ParentAttribute custom attribute in this class (see below).

    C#
    Copy
    [Aggregatable]
public class Invoice
{
  public Invoice()
  {
     this.Lines = new List<InvoiceLine>();
  }

    public Customer Customer { get; set; }
    public IList<InvoiceLine> Lines { get; set; }
  public Address DeliveryAddress { get; set; }
}

[Aggregatable]
public class InvoiceLine
{
  private Product product;
  public decimal Amount { get; set; }
}

[Aggregatable]
public class Address
{
}

  2. Annotate fields and automatic properties of all aggregatable classes with the ChildAttribute or ReferenceAttribute custom attribute. Fields or properties of a value type must not be annotated.

    C#
    Copy
    [Aggregatable]
public class Invoice
{
  public Invoice()
  {
     this.Lines = new List<InvoiceLine>();
  }

    [Reference]
    public Customer Customer { get; set; }

    [Child]
    public IList<InvoiceLine> Lines { get; private set; }

  [Child]
  public Address DeliveryAddress { get; set; }
}

[Aggregatable]
public class InvoiceLine
{
  [Reference]
  private Product product;

  public decimal Amount { get; set; }
}

[Aggregatable]
public class Address
{
}

  3. Modify the code to use AdvisableCollectionT and AdvisableDictionaryTKey, TValue instead of standard .NET collections for children fields. This change is necessary because all objects assigned to children fields/properties must be aware of the Aggregatable pattern.

    In our code example, we need to modify the constructor of the Invoice class and assign an AdvisableCollectionT to the Lines field instead of a List.

    C#
    Copy
    public Invoice()
{
   this.Lines = new AdvisableCollection<InvoiceLine>();
}

  4. Optionally, add a field or property to link back from the child object to the parent, and add the ParentAttribute to this field/property. PostSharp will automatically update this field or property to make sure it refers to the parent object.

    In this example, we are adding a ParentInvoice property to the InvoiceLine class to link back to the Invoice class.

    C#
    Copy
    [Aggregatable]
public class InvoiceLine
{
  [Reference]
  private Product product;

  public decimal Amount { get; set; }

  [Parent]
  public Invoice ParentInvoice { get; private set; }
}
    Tip Tip

    For better encapsulation, setters of parent properties should have private visibility. In case of parent fields, the private visibility is preferred. User code should not manually set a parent field or property.

See Also

Reference

AggregatableAttribute
ParentAttribute
ChildAttribute
ReferenceAttribute
AdvisableCollectionT
AdvisableDictionaryTKey, TValue


Walkthrough: Enumerating Child Objects

Walkthrough: Enumerating Child Objects

After you have declared the structure of your object graph, you will want to make use of it.

Both the ChildAttribute and ParentAttribute can be used to declare parent-child relationships for other patterns such as Undo/Redo (RecordableAttribute) or threading models (ImmutableAttribute, FreezableAttribute, ...).

You can also use the Aggregatable pattern from your own code. The functionalities of this pattern are exposed by the IAggregatable interface, which all aggregatable object automatically implement. This interface allows you to execute a Visitor method against all child objects of a parent.

In the following example, we see how to implement recursive validation for an object model. We will assume that the InvoiceLine and Address line implement an IValidatable interface.

To enumerate all child objects of a parent:

  1. Cast the parent object to the IAggregatable interface.

    C#
    Copy
    var invoice = new Invoice();
IAggregatable aggregatable = (IAggregatable) invoice;
    Note Note

    The IAggregatable interface will be injected into the Invoice class after compilation. Tools that are not aware of PostSharp may incorrectly report that the Invoice class does not implement the IAggregatable interface. Instead of using the cast operator, you can also use the CastSourceType, TargetType(SourceType) method. This method is faster and safer than the cast operator because it is verified and compiled by PostSharp at build time.

    Note Note

    If you are attempting to access IAggregatable members on either AdvisableCollectionT or AdvisableDictionaryTKey, TValue you will not be able to use the cast operator or the CastSourceType, TargetType(SourceType) method. Instead, you will have to use the QueryInterfaceT(Object, Boolean) extension method.

  2. Invoke the VisitChildren(ChildVisitor, ChildVisitorOptions) method and pass a delegate to the method to be executed.

    C#
    Copy
    var invoice = new Invoice();
IAggregatable aggregatable = invoice.QueryInterface<IAggregatable>();
int errors = 0;
bool isValid = aggregatable.VisitChildren( (child, childInfo) =>
        {
            var validatable = child as IValidatable;
            if (validatable != null)
            {
                if ( !validatable.Validate() )
              errors++;
            }
          return true;
        });
    Note Note

    The visitor must return a true to continue the enumeration and false to stop the enumeration.

See Also

Reference

AggregatableAttribute
ParentAttribute
ChildAttribute
IAggregatable
VisitChildren(ChildVisitor, ChildVisitorOptions)
CastSourceType, TargetType(SourceType)
QueryInterfaceT(Object, Boolean)


Walkthrough: Automatically Disposing Children Objects

Walkthrough: Automatically Disposing Children Objects

When you are working with hierarchies of objects, you sometimes run into situations where you need to properly dispose of an object. Not only will you need to dispose of that object, but you likely will need to walk the object tree and recursively dispose children of that object. To do this, we typically implement the IDisposable pattern and manually code the steps required to shut down the desired objects, and call the Dispose method on other children objects. This cascading of disposals takes a lot of effort and it is prone to mistakes and omissions.

The DisposableAttribute aspect relies on the AggregatableAttribue aspect and, as a result, is able to make use of the VisitChildren(ChildVisitor, ChildVisitorOptions) method to cascade disposals through child objects.

This topic contains the following sections.

  • Disposing of object graphs
  • Disposing of child collections
  • Customizing the Dispose logic
Disposing of object graphs

Adding Disposable to an object

  1. On the top level object add the DisposableAttribute.

    C#
    Copy
    [Disposable]
public class HomeMadeLogger
{
  private TextWriter _textWriter;
  private Stream _stream;
  private MessageFormatter _formatter;

  public HomeMadeLogger(MessageFormatter formatter)
  {
    _formatter = formatter;
    _stream = new FileStream("our.log", FileMode.Append);
    _textWriter = new StreamWriter(_stream);
  }

  public void Debug(string message)
  {
    _textWriter.WriteLine(_formatter.Format(message));
  }
}

    At this point the IDisposable interface will be implemented on the HomeMadeLogger class. Now any code making use of HomeMadeLogger is able to execute the HomeMadeLogger.Dispose() method.

  2. Identify the fields and properties that represents references to child objects. To do this, add the ChildAttribute to the fields and properties that expose those child objects, and the ParentAttribute to fields and properties that represent plain references. In the case of the HomeMadeLogger there are two objects, the _stream and the _textWriter fields, which should also be disposed when the HomeMadeLogger is disposed.

    C#
    Copy
    [Disposable]
public class HomeMadeLogger
{
  [Child]
  private TextWriter _textWriter;
  [Child]
  private Stream _stream;
  [Reference]
  private MessageFormatter _formatter;

  public HomeMadeLogger(MessageFormatter formatter)
  {
    _formatter = formatter;
    _stream = new FileStream("our.log", FileMode.Append);
    _textWriter = new StreamWriter(_stream);
  }

  public void Debug(string message)
  {
    _textWriter.WriteLine(_formatter.Format(message));
  }
}

    The _stream and _textWriter child objects will now have their Dispose() method called automatically when the HomeMadeLogger is disposed. Since both the _stream and _textWriter objects are framework types that already implement IDisposable, adding the DisposableAttribute aspect to those object types is not necessary.

Note Note

Fields that are marked as children but are assigned to a object that does not implement IDisposable (either manually or through DisposableAttribute) will simply be ignored during disposal.

Disposing of child collections

Child objects that need to be disposed of don’t always exist in a one-to-one relationship with the parent object. It’s common to see collections of child objects that need disposal as well. In that case you need to dispose of each entry in a collection.

Adding Disposable to collections

  1. Use a collection type that supports the IAggregatable interface. We do this by making use of AdvisableCollectionT or AdvisableDictionaryTKey, TValue class.

    C#
    Copy
    [Disposable]
public class HomeMadeLogger
{
    [Child]
    public AdvisableCollection<Context> LoggingContexts { get; set; }
}

  2. To make the LoggingContexts collection automatically dispose when the HomeMadeLogger object disposes you need to ensure that the Contexct class has the DisposableAttribute aspect on it.

    C#
    Copy
    [Disposable]
public class Context
{
    //...
}

With that, the HomeMadeLogging class and all of the child objects in the LoggingContexts collection are hooked together and they will all be disposed of in an orderly fashion when an instance of the HomeMadeLogging object is disposed.

Customizing the Dispose logic

There will be times when you have objects that need custom disposal logic. At the same time you may want to implement a parent child relationship and make use of the DisposableAttribute.

To add your own logic to the Dispose method:

  1. Create a method with exactly the following signature:

    C#
    Copy
    protected virtual void Dispose( bool disposing )

  2. Include a call to base.Dispose(disposing).

  3. Include your own logic.

In the following example, we are customizing the Dispose pattern to expose the IsDispose property:

C#
Copy
[Disposable]
public class MessageFormatter : Formatter
{

  [Child]
  MessageSink sink;

  public bool IsDisposed { get; private set; }

  protected virtual void Dispose( bool disposing )
  {
    base.Dispose( disposing );

    this.IsDisposed = true;
  }
}

Once you have done this, PostSharp will properly run your custom Dispose logic as well as running any of the parent and child implementations of the DisposableAttribute that exist for the object.

Caution note Caution

The DisposableAttribute aspect does not automatically dispose the object when it is garbage collected. That is, the aspect does not implement a destructor. If you need a destructor, you have to do it manually and invoke the Dispose.


Working With Collections

Working With Collections

It would not be possible to implement the Aggregatable pattern without support for collection classes. However, collections of the .NET base class libraries cannot be reliably extended to support the Aggregatable pattern. Therefore, code that implements the Aggregatable pattern must rely on collection classes defined by PostSharp, namely AdvisableCollectionT, AdvisableDictionaryTKey, TValue and AdvisableKeyedCollectionTKey, TItem.

This topic contains the following sections.

  • Understanding the need for specific collections
  • Replacing standard collections with advisable collections
  • Casting advisable collections
  • Controlling the status of collections in the parent-child relationship
  • Enumerating children and parent surrogates
  • Collections of references
Understanding the need for specific collections

In the following example, an Invoice entity is composed of one instance of the Invoice class and several instances of the InvoiceLine class. The relationship between the Invoice and InvoiceLine classes is implemented using a collection.

Copy
[Aggregatable]
public class Invoice
{
    public Invoice()
    {
        this.Lines = new List<InvoiceLine>();
    }

    [Child]
    public IList<InvoiceLine> Lines { get; private set; }
}

[Aggregatable]
public class InvoiceLine
{
}

When we add a new element to the Lines collection, we also need to update the parent-child relationship between the corresponding invoice and invoice line. It is not possible to do this with the standard ListT class, so we need to build a specialized aggregatable collection class instead. However, we may later decide to apply another pattern to our object model, such as a threading model or undo/redo. This new pattern would in turn require support from the collection class. Creating new collection classes for each pattern (and potentially for each pattern combination) is clearly unmanageable.

Instead of providing a new collection class for each specific behavior we need to inject, PostSharp introduces the concept of advisable collections. Advisable collections are collection classes into which PostSharp can inject behavior dynamically, at runtime, according to the field to which they are assigned. Advisable collections are a way to make the collection "inherit" the pattern of the parent class

Let's modify our previous example to work correctly with the Aggregatable aspect.

C#
Copy
[Aggregatable]
public class Invoice
{
    public Invoice()
    {
        this.Lines = new AdvisableCollection<InvoiceLine>();
    }

    [Child]
    public IList<InvoiceLine> Lines { get; private set; }

}

[Aggregatable]
public class InvoiceLine
{
}

As you can see, the only change we made is using AdvisableCollectionT class instead of ListT. The Aggregatable aspect applied to the Invoice class detects that the child property is an advisable collection and applies dynamic Aggregatable advice to the collection instance at runtime. This turns our collection of invoice lines into an aggregatable collection. If we apply another aspect to the Invoice class later, it can add new behaviors to this collection in the same way.

Replacing standard collections with advisable collections

The PostSharp.Patterns.Collections namespace defines advisable collection classes that are highly compatible with the collection types of the .NET base class libraries.

The following table shows how advisable collections map to standard collections.

Advisable collection | Replacement for
AdvisableCollectionT | Array, ListT, CollectionT, ObservableCollectionT
AdvisableDictionaryTKey, TValue | DictionaryTKey, TValue
AdvisableKeyedCollectionTKey, TItem | KeyedCollectionTKey, TItem
Caution note Caution

Interfaces IReadOnlyListT and IReadOnlyCollectionT are not implemented.

Casting advisable collections

Patterns such as Aggregatable, Recordable or Threading Models dynamically inject advices into advisable collections. These advice typically expose an interface, respectively IAggregatable, IRecordable and IThreadAware. Because interfaces are introduced at run-time and not at build-time, you cannot use the normal type casting constructs to access the interface members.

Instead of a normal cast, you can use the QueryInterfaceT(Object, Boolean) extension method to access interfaces implemented by the given instance. This method will return the proper interface implementation irrespective how the interface is implemented: directly in the source code, introduced by PostSharp aspect at build time, or added dynamically at run time.

The following code snippet gets the IAggregatable interface of the Lines collection in the example above:

C#
Copy
IAggregatable aggregatable = invoice.Lines.QueryInterface<IAggregatable>();

By default, the QueryInterfaceT(Object, Boolean) method throws InvalidCastException if the given instance doesn't implement the queried interface. You can also safely check whether the interface is implemented by passing false as a method argument.

C#
Copy
if ( collection.QueryInterface<IAggregatable>( false ) != null )
{
}
Controlling the status of collections in the parent-child relationship

Collections play a special role in implementing the parent-child relationships between classes. Collections are often instruments instead of first-class entities of the object model. When enumerating children of a class, one generally wants to avoid the collections themselves to be returned, but only items of these collections. Additionally, the Parent property of a child object should typically refer to the parent entity and not to the collection that contains the child.

Consider the following example:

C#
Copy
[Aggregatable]
public class Invoice
{
   public Invoice()
   {
     this.Lines = new AdvisableCollection<InvoiceLine>();
   }

   [Child]
   public IList<InvoiceLine> Lines { get; private set; }

}

[Aggregatable]
public class InvoiceLine
{
   [Parent]
   public Invoice Invoice { get; private set; }
}

The Invoice class contains a collection of InvoiceLine instances. We want each item of the Lines collection to be a child of the Invoice instance. However, the collection itself should not be considered a child of the Invoice. Additionally, we want the InvoiceLine.Invoice property to be set to the Invoice, not to the collection.

To implement this behavior, PostSharp needs to give a different status to collections than to other entities. This concept is named a parent surrogate, because the collection acts as a surrogate (or proxy) between the parent and its children.

Any aggregatable object can act as a parent surrogate, but only collections act as parent surrogates by default. You can override the default behavior by setting the ChildAttributeIsParentSurrogate property.

In the next example, the Lines collection will be treated as a first-class entity.

C#
Copy
[Aggregatable]
public class Invoice
{
   public Invoice()
   {
     this.Lines = new AdvisableCollection<InvoiceLine>();
   }

  [Child(IsParentSurrogate = false)]
   public IList<InvoiceLine> Lines { get; private set; }

}

[Aggregatable]
public class InvoiceLine
{
   [Parent]
   public IList<InvoiceLine> Parent { get; private set; }
}

To cause a custom class to behave like a parent surrogate by default, set the IsParentSurrogate property of the AggregatableAttribute applied on your class to true. In this case it's not allowed to override the value in the [Child] attributes applied to individual properties.

C#
Copy
[AggregatableAttribute(IsParentSurrogate = false)]
Enumerating children and parent surrogates

The default behavior of the VisitChildren(ChildVisitor, ChildVisitorOptions, Object) method is to skip the surrogate collection itself and invoke the ChildVisitor delegate on each item of the collection. In our first example, calling the VisitChildren(ChildVisitor, ChildVisitorOptions, Object) method on the Invoice instance will invoke the visitor on the items of the Lines collection, but not on the collection instance itself.

You can customize this behavior by providing one or more flags for the ChildVisitorOptions parameter of the method. The ChildVisitorOptions.IncludeParentSurrogates flag will cause the visitor to be additionally invoked on the instances of the surrogate collections, while the ChildVisitorOptions.ExcludeIndirectChildren flag will exclude the items of such collection from being visited.

Collections of references

As we showed earlier, when you annotate the collection property with the [Child] attribute, collection items become children of the class instance.

In certain situations, you may want to have a collection of references. The collection itself is still marked with the [Child] custom attribute because it would make sense from the point of view of other patterns (for instance, changes in the collection must be recorded by the Recordable pattern). However, the collection items themselves must not be considered children of the entity.

To implement this requirement, you can set the ChildAttributeItemsRelationship property to RelationshipKind.Reference.

In the example below, the RelatedOrders collection is a child and therefore its changes are being recorded by the Recordable aspect. However, collection items are not children of the parent entity, because related orders do not belong to the invoice.

C#
Copy
[Recordable]
public class Invoice
{
   public Invoice()
   {
     this.Lines = new AdvisableCollection<InvoiceLine>();
     this.RelatedOrders = new AdvisableCollection<Order>();
   }

   [Child]
   public IList<InvoiceLine> Lines { get; private set; }

   [Child(ItemsRelationship = RelationshipKind.Reference)]
   public IList<Order> RelatedOrders { get; private set; }

}


Undo/Redo

Undo/Redo

Most business application users are familiar with applications that have the ability to undo and redo changes that they have made. It’s not common to see this functionality in custom built applications because it is quite difficult to do. Despite this difficulty, undo/redo is consistently mentioned on the top of users' wish list.

The RecordableAttribute aspect makes it much easier to add undo/redo to your application by automatically appending changes done on your object model to a Recorder that you can them bind to your user interface. Unlike other approaches to undo/redo, the RecordableAttribute aspect only requires minimal changes to your source code.

In this chapter
Section | Description
Making Your Model Recordable | The first step is to make your model classes This section shows how to add the RecordableAttribute aspect to the model classes to enable the undo/redo functionality.
Adding Undo/Redo to the User Interface | This section describes how to expose the undo/redo functionality to the application's users.
Customizing Undo/Redo Operation Names | This section shows how to group changes into logical operations and give them a name that is meaningful to the application's users.
Assigning Recorders Manually | This section explains how to customize the assignment of recordable objects to recorders.
Adding Callbacks on Undo and Redo | This section shows how to execute custom logic when undo/redo operations occur in a recordable object.
Understanding the Recordable Aspect | This section describes the concepts and architecture of the RecordableAttribute aspect.


Making Your Model Recordable

Making Your Model Recordable

To make an object usable for undo/redo operations, you will need to add the RecordableAttribute aspect to the class. This aspect instruments changes to fields and record them into a Recorder. The aspect also instruments public methods to group field changes into logical operations.

This topic contains the following sections.

  • Making a class recordable using the UI
  • Making a class recordable manually
  • Working with object graphs and collections
Making a class recordable using the UI

To make a class recordable using the UI:

  1. First place the caret on the name of the object that you want to make recordable. The smart tag will appear below the object name. Expand it and select "Add another aspect..."

    Add Undo Redo

  2. In the Add Another Aspect wizard expand the Model section, select "Enable undo/redo", and click Next.

    Undo Redo Wizard

    If you have not added a reference to the threading model assembly the Apply Threading Model wizard will download it from Nuget and add the reference.

  3. Once the wizard has completed the object will now be flagged as recordable.

    C#
    Copy
    [NotifyPropertyChanged]
[Recordable]
public class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int Age { get; set; }
}

    By adding the RecordableAttribute aspect to the Person class all of the properties that are primitive types will be recorded when they change.

Making a class recordable manually

To make the class recordable manually:

  1. Install the PostSharp.Patterns.Model package using NuGet.

  2. Add the RecordableAttribute to the class.

Working with object graphs and collections

In the example above, the Invoice class just had a few fields of a primitive type (int, string, ...). In real-world application, objects are not isolated entities, but are parts of larger structures named object graphs.

The RecordableAttribute aspect needs to understand the parent-child structure of your object graphs. It relies on the AggregatableAttribute aspect for this purpose.

Therefore, when adding the RecordableAttribute aspect to a class, you need to complete a few more steps:

  • Annotate fields with the ChildAttribute, ReferenceAttribute or ParentAttribute custom attribute.

  • Replace arrays and collections with instances of the AdvisableCollectionT and AdvisableDictionaryTKey, TValue classes.

See Parent/Child Relationships for more information.


Adding Undo/Redo to the User Interface

Adding Undo/Redo to the User Interface

The Undo/Redo functionality that you added to your codebase needs to be made available to the users. Users will want to have the ability to move forwards and backwards through the operations that they too and have been recorded.

This topic contains the following sections.

  • Using the ready-made WPF controls
  • Clearing the initial history
  • Creating custom undo/redo controls
Using the ready-made WPF controls

PostSharp includes two button controls UndoButton and RedoButton that you can add to your application.

To add Undo/Redo to a WPF window:

  1. Install the PostSharp.Patterns.Model.Controls package using NuGet.

  2. Add the following namespace declaration to the root element of your XAML file:

    C#
    Copy
    xmlns:model="clr-namespace:PostSharp.Patterns.Model.Controls;assembly=PostSharp.Patterns.Model.Controls"

  3. To add Undo and Redo buttons to the user interface, include the following two lines of Xaml.

    C#
    Copy
    <model:UndoButton HorizontalAlignment="Left" Margin="22,24,0,0" VerticalAlignment="Top" />
<model:RedoButton HorizontalAlignment="Left" Margin="64,24,0,0" VerticalAlignment="Top"/>

    Your users are now able to make a changes in the user interface and Undo and/or Redo those changes at any point that they want.

Clearing the initial history

If we were to open the Customer management screen you would notice that the Undo button has a number of actions listed under it.

Those actions are listing the changes that were taken when the different Person instances were loaded and their properties were set. Most users will only want to see actions that they have manually taken in the screen. As such, you will need to manually interact with the Recorder to ensure that the Undo button list is empty when the window opens.

To provide an empty list of recorded actions when the windows is initially opened, open the ViewModelMain class and find the constructor. Add the following as the last line in the constructor:

C#
Copy
RecordingServices.DefaultRecorder.Clear();

The Recorder class is accessed through the RecordingServicesDefaultRecorder property. This property contains the current Recorder instance that is being used by the RecordableAttribute aspect. The Recorder class has two collections, UndoOperations and RedoOperations, which contain all of the past operations that can be undone and redone. The Clear method removes all operations from both of those collections.

Now when you open the Customer management screen both the Undo and Redo buttons will show no history. This is the simplest type of Undo/Redo implementation that you can do. It will record each property change operation separately in the Undo and Redo UI buttons which probably isn’t what you, or your users, will want to see. Read Customizing Undo/Redo Operation Names to learn how to record groupings of operations that make sense to your business users.

Creating custom undo/redo controls

If the buttons provided by PostSharp don't meet your requirements, you can create your own controls for WPF, Windows Phone or WinRT.

Custom controls will typically provide a front-end to the global Recorder exposed on the RecordingServicesDefaultRecorder property, and we provide a view for the UndoOperations and RedoOperations collections. Controls typically use the RecorderUndo and RecorderRedo methods.


Customizing Undo/Redo Operation Names

Customizing Undo/Redo Operation Names

The example of previous sections displays the list of operations appearing in the two UI buttons. That list of operations references the setters on the different individual properties in a very technical manner, for instance the operation of setting the first name is named set_FirstName, according to the name of the property in source code.

End users will want to see the operations described in meaningful business terms, not technical ones. This article will show you how to explicitly name the recording operations that will take place in your code.

This topic contains the following sections.

  • Understanding the default operation naming mechanism
  • Setting operation names declaratively
  • Setting operation names dynamically
  • Using the OperationFormatter class
Understanding the default operation naming mechanism

From the end user's perspective, the undo/redo feature exposes a flat list of operations that can be undone or redone. From a system perspective, an operation is composed of changes to individual fields and collections. For instance, moving a picture on a design surface is seen as a single operation Move by the user, but it is composed of two changes in fields x and y.

Let's see this in a code example:

C#
Copy
[Recordable]
public class Picture
{
   private double x, y;

   public double X
   {
      get { return x; }
      set { x = value; }
   }

   public double Y
   {
      get { return y; }
      set { y = value; }
   }

   public void Move( double x, double y )
   {
      this.X = x;
      this.Y = y;
   }

}

public static class Program
{
   public static void Main()
   {
      var picture = new Picture();

      picture.Move( 10, 10 );

      // 1 undo operation at this point: Move.

      picture.X = 20;

      // 2 undo operations at this point: set_X, Move.

      picture.Y = 20;

      // 3 undo operations at this point: set_Y, set_X, Move.
   }
}

By default, the RecordableAttribute aspect will automatically open a new operation for any public method, unless the current Recorder already has an open operation. Therefore, invoking the Move method results in a single operation, even if it modifies two fields. Note that the Move method invokes the setters of public properties X and Y, which are themselves public methods, but they do not open new operations since they run from within the Move method. However, when properties X and Y are accessed from outside of the Picture class, new operations are created for the set_X and set_Y methods.

Setting operation names declaratively

By default, the name of an operation is set to the name of the method. There are various ways to customize this name, and the easiest is to add a RecordingScopeAttribute custom attribute to the public method.

In the following example, we're declaring a different name for the Move method:

C#
Copy
[Recordable]
public class Picture
{
   private double x, y;

   [RecordingScope("Moving the picture")]
   public void Move( double x, double y )
   {
      this.x = x;
      this.y = y;
   }

}

With that RecordingScopeAttribute added, the recorded operation will now have a name of Moving the picture instead of just Move.

Setting operation names dynamically

Setting the operation name declaratively is convenient but relatively rigid. When more flexibility is needed, you can use the RecorderOpenScope(String, RecordingScopeOption) method to control the creation and naming of scopes.

In the following example, we will modify the Move method to include the target position in the operation description.

To dynamically name an operation:

  1. Add the [RecordingScope(RecordingScopeOption.Skip)] custom attribute to the method, so that the method does not automatically define a new operation. Exclude from the Recorder the method which contains the block of code that you wish to encapsulate in a recording.

    C#
    Copy
    [RecordingScope(RecordingScopeOption.Skip)]
public void Move( double x, double y )
    Note Note

    This step is not required if you are starting the operation from a non-recordable object.

  2. Invoke the OpenScope(String, RecordingScopeOption) method and wrap the code you want to record in a using block.

    C#
    Copy
    [Recordable]
public class Picture
{
   private double x, y;

   [RecordingScope(RecordingScopeOption.Skip)]
   public void Move( double x, double y )
   {
      string scopeName = string.Format( "Moving to ({0}, {1})", x, y );

      using (RecordingScope scope = RecordingServices.DefaultRecorder.OpenScope(scopeName))
      {
        this.x = x;
        this.y = y;
      }
   }
}
    Note Note

    If you do not to add this custom attribute to the method, the RecordableAttribute aspect will automatically create a new scope to execute the method, and your call of the OpenScope(String, RecordingScopeOption) method will be ignored.

Using the OperationFormatter class

Explicitly declaring the name for every operation would be a large and tedious task. It is possible to write your own naming engine and apply that set of naming rules across the entire application. To achieve this, derive your own implementation from the OperationFormatter class. to the

In the following example, we will create a custom formatter that reads the operation name from the DisplayNameAttribute custom attribute and display the value to which a property has been set.

To create and register a custom OperationFormatter:

  1. Create a new class and inherit from the OperationFormatter class.

    C#
    Copy
    public class MyOperationFormatter : OperationFormatter
{
}

  2. Create a constructor for the new formatter class.

    C#
    Copy
    public class MyOperationFormatter : OperationFormatter
{
    public MyOperationFormatter(OperationFormatter next) : base(next)
    {
    }
}

  3. Next you need to override the FormatOperationDescriptor(IOperationDescriptor) method and write your custom logic for generating a custom operation name.

    C#
    Copy
    class MyOperationFormatter : OperationFormatter
 {
     public MyOperationFormatter( OperationFormatter next ) : base( next )
     {
     }

     protected override string FormatOperationDescriptor( IOperationDescriptor operation )
     {
         if ( operation.OperationKind != OperationKind.Method )
             return null;

         var descriptor = (MethodExecutionOperationDescriptor) operation;

         if ( descriptor.Method.IsSpecialName && descriptor.Method.Name.StartsWith( "set_" ) )
         {
             // We have a property setter.

             var property = descriptor.Method.DeclaringType.GetProperty(
                    descriptor.Method.Name.Substring( 4 ),
                    BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic );

             var attributes =
                  (DisplayNameAttribute[]) property.GetCustomAttributes(typeof(DisplayNameAttribute), false);

             if ( attributes.Length > 0 )
                 return string.Format( "Set {0} to {1}", attributes[0].DisplayName, descriptor.Arguments[0] ?? "null" );
         }
         else
         {
             // We have another method.

             var attributes =  (DisplayNameAttribute[])
                descriptor.Method.GetCustomAttributes(typeof(DisplayNameAttribute), false);

             if ( attributes.Length > 0 )
                 return attributes[0].DisplayName;
         }

         return null;
     }
 }
    Note Note

    Formatters create a chain of responsibility. If one formatter is unable to provide a name it will ask the next formatter in the chain to attempt to provide a name. To make the hand-off occur the FormatOperationDescriptor(IOperationDescriptor) method needs to return null. If it returns anything else the chain is broken and the returned value is used as a name.

  4. Finally, you need to add your custom name formatter into the chain of responsibility.

    C#
    Copy
    RecordingServices.OperationFormatter = new MyOperationFormatter(RecordingServices.OperationFormatter);

    Because the RecordingServices is making use of a chain of responsibility, you are able to insert as many custom name formatters as you want. You are also able to determine their order of execution based on the order that you insert them into the chain of responsibility.


Assigning Recorders Manually

Assigning Recorders Manually

By default, all recordable objects are attached to the global Recorder exposed on the RecordingServicesDefaultRecorder property. There is nothing you have to do to make this happen. There may be circumstances where you want to create and assign your own recorder to the undo/redo process. There are two different ways that you can accomplish this.

This topic contains the following sections.

  • Overriding the default RecorderProvider
  • Attaching a recorder manually
Overriding the default RecorderProvider

By default, the RecordableAttribute aspect attaches an object to a Recorder as soon as its constructor exits. To determine which Recorder should be used, the aspect uses the RecordingServicesRecorderProvider service. By default, this service always serves the global instance that is also exposed on the RecordingServicesDefaultRecorder property.

You can override this automatic assignment to inject your own RecorderProvider to into the process.

To use a custom RecorderProvider:

  1. Create a class inherited from the RecorderProvider class.

    C#
    Copy
    public class MyProvider : RecorderProvider
{
}

  2. Implement the chaining constructor. The RecorderProvider that you inherited from requires a RecorderProvider as a constructor parameter. This constructor parameter facilitates the chain of responsibility for providers that can be run when a Recorder is requested. To keep the chain of responsibility intact your custom RecorderProvider will need to accept a RecorderProvider in it's constructor and pass that to the base constructor.

    C#
    Copy
    public class MyProvider : RecorderProvider
{
  public MyProvider(RecorderProvider next) : base (next)
  {
  }
}

  3. Override the GetRecorderImpl(Object) method.

    C#
    Copy
    public class MyProvider : RecorderProvider
{
  public MyProvider(RecorderProvider next) : base(next)
  {
  }

  public Recorder GetRecorderImpl(object obj)
  {
    //where you will write code to create a new Recorder instance
    throw new NotImplementedException();
  }
}

  4. Insert an instance of your custom RecorderProvider class into the chain of responsibility by assigning it to the RecordingServicesRecorderProvider.

    C#
    Copy
    RecordingServices.RecorderProvider = new MyProvider(RecordingServices.RecorderProvider);
Note Note

RecorderProvider is a chain of responsibility. As such, if a GetRecorderImpl(Object) method returns null then the chain will move on to the next RecorderProvider and attempt to get a Recorder to use.

By overriding the default RecorderProvider you are able to assign a custom Recorder across the entire application.

Attaching a recorder manually

The second way that you can add a Recorder to objects is to manually assign them when, and where, they are needed.

To manually assign a Recorder to an object:

  1. Set the RecordableAttributeAutoRecord property to false for that class.

    C#
    Copy
    [Recordable(AutoRecord = false)]
public class Invoice
{
}
    Note Note

    By disabling AutoRecord you are telling the RecordingServices that this object should not be included in recordings unless the recording is explicitly declared in your code.

  2. Create a new instance of a Recorder and attach the object to it using the Attach(Object) method.

    C#
    Copy
     var invoice = new Invoice();

var recorder = new Recorder();
recorder.Attach(invoice);

    You can then use the Detach(Object) method to remove the Recorder from the object in question.

Note Note

An object must always have the same Recorder as its parent has unless the parent has no Recorder assigned. Because of this, whenever a Recorder is assigned to an object, all of the child objects will have that same Recorder assigned to them. However, if you detatch a child object from it's parent the child object's assigned Recorder will not be detached. For more information about parent-child relationships, see Parent/Child Relationships.


Adding Callbacks on Undo and Redo

Adding Callbacks on Undo and Redo

You may run into situations where you will want to execute some code before or after an object is being modified by an Undo or Redo operation. This capability is provided through the IRecordableCallback interface.

In the following example, we will show how to integrate the RecordableAttribute aspect with a custom implementation of INotifyPropertyChanged (the standard NotifyPropertyChangedAttribute aspect is already integrated with the RecordableAttribute aspect so you don't need to worry).

C#
Copy
[Recordable]
public class Invoice : INotifyPropertyChanged, IRecordableCallback
{
  public void OnReplaying(ReplayKind kind, ReplayContext context)
  {
  }

  public void OnReplayed(ReplayKind kind, ReplayContext context)
  {
    OnPropertyChanged("ShippingDate");
  }

  private DateTime _shippingDate;
  public DateTime ShippingDate
  {
    get { return _shippingDate; }
    set
    {
      _shippingDate = value;
       OnPropertyChanged("ShippingDate");
    }
  }

  public event PropertyChangedEventHandler PropertyChanged;

  protected virtual void OnPropertyChanged(string propertyName = null)
  {
      var handler = PropertyChanged;
      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
  }
}

For more information, see the reference documentation for the IRecordableCallback interface.


Understanding the Recordable Aspect

Understanding the Recordable Aspect

This section describes how the RecordableAttribute aspect is implemented. It helps developers and architects to understand the behavior and limitations of the aspect.

This topic contains the following sections.

  • Overview
  • Scopes and Logical Operations
  • Atomic Operations
  • Primitive Operations
  • Restore Points
  • Implementing IEditableObject
  • Callback methods
  • Memory consumption
Overview

When the RecordableAttribute aspect is applied to a class, the aspect records changes performed on instances of this class. Changes are represented as instances of the Operation class. For instance the FieldOperationT class represents the operation of changing the value to a field. All operations implement the Undo(ReplayContext) and Redo(ReplayContext) methods. For instance, the FieldOperationT class stores both the new and old value so that the operation can be undone and redone.

The changes are recorded into the Recorder object. The Recorder maintains two collections of operations: UndoOperations and RedoOperations. The RecorderUndo method takes the last operation from the UndoOperations collection, invokes OperationUndo(ReplayContext) for this operation, and moves the operation to the RedoOperations collection. The RecorderUndo method works symmetrically.

It would not be safe, however, to allow users to undo changes in the object model back to any arbitrary point in history. Users don't want to undo primitive changes to an object model, but to undo whole operations understood from a user's perspective. This is why the UndoOperations and RedoOperations collections don't expose primitive changes on the object model but logical operations.

By default, logical operations are automatically opened when calling a public or internal method of a recordable object, and closed when the same method exits. The principal use case of scopes is to define user-friendly operation names.

There is typically a single instance of this class per application, but there could be many if needed (for instance in a multi-document application). The default single instance is accessible from the RecordingServicesDefaultRecorder property. By default, recordable objects are attached to the default recorder immediately after completion of the constructor. See Assigning Recorders Manually to learn how to customize this behavior.

Scopes and Logical Operations

Scopes are a mechanism to aggregate several primitive operations into logical operations that make sense for the end-user. Logical operations are represented by the CompositeOperation class.

In general, logical operations form a flat structure: the UndoOperations and RedoOperations collections are flat double linked lists, and each CompositeOperation typically contains primitive operations such as a field value change.

Scopes define boundaries of logical operations. Scopes can be opened using the RecorderOpenScope(RecordingScopeOption) method, which returns an object of type RecordingScope. This class implements the IDisposable interface, making it convenient to define scopes with the using statement.

By default, the RecordableAttribute aspect encloses all instance public and internal methods with an implicit scope. That is, by default, public and internal methods define boundaries of logical operations.

Unlike logical operations, scopes are generally nested. Scope nesting typically happens when a public method directly or indirectly invokes another public method. In general, only the outermost scope results in creating a logical operation. This is why, in general, logical operations form a flat structure.

Because they are visible to users, logical operations must be given a user-friendly name. PostSharp defines default names that are not user-friendly. The responsibility of generating operation names is implemented by the OperationFormatter class. You can provide your own OperationFormatter to generate operations names on demand, or you can set the name explicitly in source code for each operation.

Scope names can be declaratively defined using the RecordingScopeAttribute custom attribute, or programmatically using the RecorderOpenScope(String, RecordingScopeOption) method. To learn more about operation names, see Customizing Undo/Redo Operation Names.

Atomic Operations

Atomic scopes are scopes whose changes are automatically rolled back when it does not complete successfully, typically when an exception occurs. The rollback is implemented using the undo mechanism. Atomic scopes are a similar concept than transactions, but multi-threading is not taken into account. Therefore, other threads may see changes that have not been "committed", because the Recordable\ pattern does not have a notion of transaction isolation.

Atomic scopes cause composite operations to have a tree structure. However, the concept of atomic structure does not surface to the users. Therefore, from a user's perspective, the UndoOperations and RedoOperations collections still present linear lists of logical operations.

Scope defined declaratively using the RecordingScopeAttribute custom attribute, or programmatically using the RecorderOpenScope(RecordingScopeOption) method.

Primitive Operations

The following table lists the primitive operations that are automatically appended to the Recorder object by the RecordableAttribute aspect.

Class | Description
FieldOperationT | Represents the operation of setting a field to a different value.
CollectionOperationT | Represents operations on collections.
DictionaryOperationTKey, TValue | Represents operations on dictionaries.
RecorderOperation | Represents the operation of attaching or detaching an object to or from a Recorder.

Additionally to these system-defined operations, it is possible to implement custom operations by deriving from the Operation abstract class. You can then use the RecorderAddOperation(Operation) method to append the custom operation to the Recorder.

Logical operations, which are presented to the end user, are typically represented as instances of the CompositeOperation class.

Restore Points

Restore points act like bookmarks in the list of operations. They allow to undo or redo operations up to a specific point. You can use the RecorderAddRestorePoint(String) method to create a restore point. The method returns an instance of the RestorePoint class, which derives from the Operation class. Unlike other operations, you can safely remove a restore point from the history thanks to the Remove method.

Implementing IEditableObject

You can use the EditableObjectAttribute custom attribute to automatically implement the IEditableObject interface. The implementation is based on the RecordableAttribute aspect. It creates a RestorePoint when the BeginEdit method is invoked, removes the restore point upon EndEdit, and undoes changes up to the restore point when CancelEdit is called.

Because of this implementation strategy, it is possible than CancelEdit actually cancels changes done to other objects that share the same Recorder.

Callback methods

The Recorder will invoke the OnReplaying(ReplayKind, ReplayContext) and OnReplayed(ReplayKind, ReplayContext) methods of any recordable object implementing the IRecordableCallback interface, whenever the object is affected by an undo or redo operation.

The order in which these methods are ordered on several objects is non-deterministic; in particular, the aggregation structure is not respected.

It is not allowed, from a callback methods:

  • to perform a change that would be recorded, e.g. to set a field that has not been waived from recording with the NotRecordedAttribute custom attributes.

  • to invoke methods Undo, Redo or AddRestorePoint of the Recorder class.

Memory consumption

The UndoOperations and RedoOperations collections hold strong references to all objects that have changes that can be undone or redone. This means that these objects cannot be garbage-collected and will remain in memory.

You can define the maximal number of operations available for undo thanks to the RecorderMaximumOperationsCount property.


Contracts

Contracts

Throwing exceptions upon detecting a bad or unexpected value is good programming practice called precondition checking. However, writing the same checks over and over in different areas of the code base is tedious, error prone, and difficult to maintain.

PostSharp Code Contracts have the following features and benefits:

  • More readable. PostSharp Code Contracts are represented as custom attributes there is less code to read and understand.

  • Inherited. You can add a PostSharp Code Contract attribute to an interface method parameter and it will automatically be enforced in all implementations of this method.

  • Localizable. It's easy to display the error message in the user's language, even if you didn't design for this scenario upfront.

In this chapter
Section | Description
Walkthrough: Adding Contracts to Code | This section demonstrates how to add contracts to code and how inheritance works.
Creating Custom Contracts | This section explains how to create your own contract attributes.
Localizing Contract Errors | This section describes how to customize the texts of exceptions that are thrown when a contract is violated.
See Also

Reference

RequiredAttribute
PostSharp.Patterns.Model
PostSharp.Patterns.Contracts
PostSharp.Aspects
PostSharp.Reflection
LocationContractAttribute
ErrorMessage
ILocationValidationAspect
ValidateValue(T, String, LocationKind)


Walkthrough: Adding Contracts to Code

Walkthrough: Adding Contracts to Code

This section describes how to add a contract to a field, property, or parameter.

This topic contains the following sections.

  • Introduction
  • Adding contracts using the UI
  • Adding contracts manually
  • Contract Inheritance
Introduction

Consider the following method which checks if a valid string has been passed in:

C#
Copy
public class CustomerModel
{
  public void SetFullName(string firstName, string lastName)
  {
      if(firstName == null)
        throw NullReferenceException();

      if(lastName == null)
        throw NullReferenceException();

      this.FullName = firstName + lastName;
  }
}

In this example, checks have been added to ensure that both parameters contain a valid string. A better solution is to place the logic which performs this check into its own reusable class, especially such boilerplate logic is involved, and then reuse/invoke this class whenever the check needs to be performed.

PostSharp’s Contract attributes do just that by moving such checks out of code and into parameter attributes. For example, PostSharp’s RequiredAttribute contract could be used to simplify the example as follows:

C#
Copy
public class CustomerModel
{
    public void SetFullName([Required] string firstName, [Required] string lastName)
    {
        this.FullName = firstName + lastName;
    }
}

In this example the RequiredAttribute attribute performs the check for null, thus eliminating the need to write the boiler plate code for the check inline with other code.

A contract can also be used in a property as shown in the following example:

C#
Copy
public class CustomerModel
 {
    [Required]
    public FirstName
    {
        get;
        set;
    }
}

Using a contract in a property ensures that the value being passed into set is validated before the logic (if any) for set is executed.

Similarly, a contract can be used directly on a field which will validate the value being assigned to the field:

C#
Copy
public class CustomerModel
{
    [Required]
    private string mFirstName = “Not filled in yet”;

    public void SetFirstName(string firstName)
    {
        mFirstName = firstName;
    }
}

In this example, firstName will be validated by the Required contract before being assigned to mFirstName. Placing a contract on a field provides the added benefit of validating the field regardless of where it’s set from.

Note that PostSharp also includes a number of built-in contracts which range from checks for null values to testing for valid phone numbers. You can also develop your own contracts with custom logic for your own types as described below.

There are two ways to add contracts:

Adding contracts using the UI

PostSharp’s Visual Studio integration provides a smart tag popup which can be used to select and apply a contract to a parameter, field, or property.

To add contract using the UI:

  1. Click on the parameter, field, or property for which the contract is to be applied. While hovering the mouse over this item, a smart tag drop-down will appear:

    Adding Contracts 1

  2. Click on the smart tag drop-down to reveal the contracts available:

    Adding Contracts 2

  3. Select a contract from the list or select Add another aspect to display the aspect selection dialog:

    Adding Contracts 3

  4. Select a contract and click Next.

  5. Confirm the addition of the contract and click Next:

    Adding Contracts 4

  6. Click Finish when the dialog indicates that the operation completed:

    Adding Contracts 5

The aspect has now been added in code:

Adding Contracts 6
Adding contracts manually

To add contract manually:

  1. Add the assembly: PostSharp.Patterns.Model to your project.

  2. Add the namespace: PostSharp.Patterns.Contracts.

  3. Add the attribute before the parameter name for example:

    C#
    Copy
    public void SetFullName([Required] string firstName, [Required] string lastName)
Contract Inheritance

PostSharp ensures that any contracts which have been applied to an abstract, virtual, or interface method are inherited along with that method in derived classes, all without the need to re-specify the contract in the derived methods. This is shown in the following example:

C#
Copy
public interface ICustomerModel
{
  void SetFullName([Required] string firstName, [Required] string lastName);
}

public class CustomerModel : ICustomerModel
{
  public void SetFullName(string firstName, string lastName)
  {
     this.FullName = firstName + " " + lastName;
  }

}

Here ICustomerModel.SetFullName method specifies that the firstName and lastName parameters are required using the RequiredAttribute attribute. Since the CustomerModel.SetFullName method implements this method, these attributes will also be applied to its parameters.

Note Note

If the derived class exists in a separate assembly, that assembly must be processed by PostSharp and must reference PostSharp and PostSharp Model pattern assembly.


Creating Custom Contracts

Creating Custom Contracts

Given the benefits that contracts provide over manually checking values and throwing exceptions in code, you will likely want to implement your own contracts to perform your own custom checks and handle your own custom types.

The following steps show how to implement a contract which throws an exception if a numeric parameter is zero:

To implement a contract throwing an exception if a numeric parameter is zero:

  1. Use the following namespaces: PostSharp.Aspects and PostSharp.Reflection.

  2. Derive a class from LocationContractAttribute and override the GetErrorMessage method:

    C#
    Copy
    public class NonZeroAttribute : LocationContractAttribute
{
    public const string ErrorMessage = "NonZeroErrorMessage";

    public NonZeroAttribute()
      : base()
    {
    }

    protected override string GetErrorMessage()
    {
        return "Value {2} must have a non-zero value.";
    }
}
    Note Note

    The value returned by GetErrorMessage method can contain formatting placeholders. See the remarks section for the LocationContractAttribute class for more information.

  3. Implement the ILocationValidationAspect interface in the new contract class which exposes the ValidateValue(T, String, LocationKind) method. Note that this interface must be implemented for each type that is to be handled by the contract. In this example, the contract will handle both int and uint, so the interface is implemented for both integer types. If additional integer types were to be handled by this class (e.g. long), then additional implementations of ILocationValidationAspect would have to be added:

    C#
    Copy
    public class NonZeroAttribute : LocationContractAttribute, ILocationValidationAspect<int>, ILocationValidationAspect<uint>
{
    public const string ErrorMessage = "NonZeroErrorMessage";

    public NonZeroAttribute()
      : base()
    {
    }

    protected override string GetErrorMessage()
    {
       return "Value {2} must have a non-zero value.";
    }

    public Exception ValidateValue(int value, string name, LocationKind locationKind)
    {
       if (value == 0)
         return this.CreateArgumentOutOfRangeException(value, name, locationKind);
      else
         return null;
    }

    public Exception ValidateValue(uint value, string name, LocationKind locationKind)
    {
        if (value == 0)
          return this.CreateArgumentOutOfRangeException(value, name, locationKind);
        else
          return null;
    }
}

    The ValidateValue(T, String, LocationKind) method takes in the value to test, the name of the parameter, property or field, and the usage (i.e. whether it’s a parameter, property, or field). The method must return an exception if a check fails, or null or if no exception is to be raised.

With the contract now created it can be used. For example, the following methods which calculate the modulus between two numbers, can use the contract defined above to ensure that neither of their input parameters are zero:

C#
Copy
bool Mod([NonZero] int number, [NonZero] int dividend)
{
  return ((number % dividend) == 0);
}

bool Mod([NonZero] uint number, [NonZero] uint dividend)
{
  return ((number % dividend) == 0);
}


Localizing Contract Errors

Localizing Contract Errors

You can customize all texts of exceptions raised by built-in contract. This allows you to localize error messages into different languages.

Contracts use the ContractLocalizedTextProvider class to obtain the text of an error message. This class follows a simple chain of responsibilities pattern where each provider has a reference to the next provider in the chain. When a message is queried, the provider either returns a message or passes control to the next provider in the chain.

Each message is identified by a string identifier and can refer to 4 basic arguments and additional arguments specific to a message type. For general information about message arguments please see remarks section of LocationContractAttribute. For identifier of a particular message and its additional arguments, please see remarks section of contract classes in PostSharp.Patterns.Contracts.

This topic contains the following sections.

  • Localizing a built-in error message
  • Localizing custom contracts
Localizing a built-in error message

Following steps illustrate how to override an error message of a given contract:

To override a contract error message:

  1. Declare a class that derives from ContractLocalizedTextProvider and implement the chain constructor.

    C#
    Copy
    public class CzechContractLocalizedTextProvider : ContractLocalizedTextProvider
{
    public CzechContractLocalizedTextProvider(ContractLocalizedTextProvider next)
      : base(next)
    {
    }

}

  2. Implement the GetMessage(String) method. In the next code snippet, we show how to build a simple and efficient dictionary-based implementation.

    C#
    Copy
    public class CzechContractLocalizedTextProvider : ContractLocalizedTextProvider
{
      private readonly Dictionary<string, string> messages = new Dictionary<string, string>
                                    {
                                        {RegularExpressionErrorMessage, "Hodnota {2} neodpovídá regulárnímu výrazu '{4}'."},
                                    };

    public CzechContractLocalizedTextProvider(ContractLocalizedTextProvider next)
      : base(next)
    {
    }

    public override string GetMessage( string messageId )
    {
        if ( string.IsNullOrEmpty( messageId ))
            throw new ArgumentNullException("messageId");

        string message;
        if ( this.messages.TryGetValue( messageId, out message ) )
        {
            return message;
        }
        else
        {
            // Fall back to the default provider.
            return base.GetMessage( messageId );
        }
    }
}
    Note Note

    If you need to support several languages, you can make your implementation of the GetMessage(String) method dependent on the value of the CultureInfoCurrentCulture property. You can optionally store your error messages in a managed resource and use the ResourceManager class to access it and manage localization issues. The design of PostSharp Code Contracts is agnostic to these decisions.

  3. In the beginning of an application, create a new instance of the provider and set the current provider as it's successor.

    C#
    Copy
    public static void Main()
{
    ContractLocalizedTextProvider.Current = new CzechContractLocalizedTextProvider(ContractLocalizedTextProvider.Current);

    // ...
}
Localizing custom contracts

Once you have configured a text provider, you can use it to localize error messages of custom contracts. In the following procedure, we will localize the error message of the example contract described in Creating Custom Contracts.

To localize a custom contract:

  1. Edit the code contract class (NonZeroAttribute in our case) and replace the implementation of the GetErrorMessage method by a call to the GetMessage(String) method. Pass a unique message identifier to this method.

    Copy
    protected override string GetErrorMessage()
 {
     return ContractLocalizedTextProvider.Current.GetMessage("NonZeroErrorMessage");
 }

  2. Edit your implementation of the LocalizedTextProvider class and include the message for your custom contract:

    C#
    Copy
    private readonly Dictionary<string, string> messages = new Dictionary<string, string>
  {
     {RegularExpressionErrorMessage, "Hodnota {2} neodpovídá regulárnímu výrazu '{4}'."},
     {"NonZeroErrorMessage", "Value {2} must have a non-zero value."}
  };


Logging

Logging

The Diagnostics Pattern Library enables you to configure where logging should be performed and to keep your log entries in sync as you add, remove and refactor your codebase. Currently, the library provides a single aspect: LogAttribute.

In this chapter
Section | Description
Walkthrough: Adding Detailed Tracing to a Code Base | This article shows how to add detailed logging to your application.
Walkthrough: Tracing Parameter Values Upon Exception | This article describes how to log parameter values when a method fails with an exception.
Walkthrough: Customizing Logging | This article shows how to customize the logging settings, such as the severity level or whether parameter values should be included.
Walkthrough: Changing the Logging Back-End | This article shows how to switch to a different back-end after you have chosen a first one.
See Also

Reference

LogAttribute
LogExceptionAttribute


Walkthrough: Adding Detailed Tracing to a Code Base

Walkthrough: Adding Detailed Tracing to a Code Base

When you're working with your codebase it's common to need to add logging either as a non-functional requirement or simply to assist during the development process. In either situation you will want to include information about the parameters passed to the method when it was called as well as the parameter values once the method call has completed. This can be a tedious and brittle process. As you work and refactor methods the order and types of parameters may change, parameters may be added and some maybe removed. Along with performing these refactorings you have to remember to update the logging messages to keep them in sync. This is something that is easy to forget and once forgotten the output of the logging is much less useful.

PostSharp offers a solution to all of these problems. The logging pattern library allows you to configure where logging should be performed and the pattern library takes over the task of keeping your log entries in sync as you add, remove and refactor your codebase. Let's take a look at how you can add trace logging for the start and completion of method calls.

To add trace logging for the start and completion of method calls:

  1. Let's add logging to our Save method.

    C#
    Copy
    public void Save(string firstName, string lastName, string streetAddress, string city)
{
    var customerRepository = new CustomerRepository();
    customerRepository.Save(firstName, lastName, streetAddress, city);
}

  2. Put the caret on the Save method name and expand the Smart Tag. From the list select "Add logging".

    Detailed Tracing 1

  3. The first option that you need to select is the Logging Profile. For this example we will take the default provided: it logs the method enters and exits, and includes parameter values and return value. Select the "Default" profile and click Next.

    Detailed Tracing 2

  4. The next page of the wizard gives you the opportunity to choose the logging back-end that you want to use. For this example select "System.Diagnostics.Trace" and click Next.

    Detailed Tracing 3

  5. The summary page gives you the opportunity to review the selections that you have made. If you notice that the configuration is not what you wanted you can click the Previous button and adjust your selections. If the configuration meets your needs click Next.

    Detailed Tracing 4

  6. The progress page shows a progress bar and summary of what actions PostSharp is taking to add the selected logging configuration to your codebase. It's at this point that PostSharp and the logging pattern library will be downloaded from NuGet and added as references to your codebase.

    Detailed Tracing 5

  7. Once the download, installation and configuration of PostSharp and the logging pattern library has finished you can close the wizard and look at the changes that were made to your codebase.

    Detailed Tracing 6

  8. You'll notice that the code you added the logging to has changed slightly. PostSharp has added a LogAttribute attribute to the method. Since we chose the default logging profile, there is no argument to the LogAttribute attribute.

    C#
    Copy
    [Log]
public void Save(string firstName, string lastName, string streetAddress, string city)
{
    var customerRepository = new CustomerRepository();
    customerRepository.Save(firstName, lastName, streetAddress, city);
}
    Note Note

    This example has added a single attribute to one method. If you plan on adding this logging to many different locations in your codebase you will want to read about using the MulticastAttribute: Adding Aspects to Multiple Declarations.

  9. If you were to run this method the trace logging that you added would output a log message when entering the method and an entry when leaving the method. Note that the parameter values are automatically included in the log message.

    Detailed Tracing 7

Now that you have logging added to the Save method you are able to change the method's name as well as add and remove parameters with the confidence that your log entries will be kept in sync with each of those changes. In combination with attribute multicasting (the article Adding Aspects to Multiple Declarations), adding logging to your codebase and maintaining it becomes a very easy task.

See Also

Reference

LogAttribute

Other Resources

Adding Aspects to Multiple Declarations


Walkthrough: Customizing Logging

Walkthrough: Customizing Logging

When adding logging to your codebase, you may need to set up logging options differently for different areas or layers in your application. For example, exceptions in the service that cleans up old data in the database can be logged with a "Warning" level, while exceptions in the customer-facing web service must be logged with the "Error" level.

PostSharp enables you to organize your logging options using Logging Profiles. Logging profiles are stored in the solution-wide configuration file, and each profile specifies what information you want to be included in the log output. You apply a given logging profile by providing its name as an argument for the LogAttribute attribute's constructor. Let's take a look at how you can create your own logging profile and use it in your code.

To create a custom logging profile:

  1. Let's add customized logging to our Save method.

    C#
    Copy
    public void Save(string firstName, string lastName, string streetAddress, string city)
{
    var customerRepository = new CustomerRepository();
    customerRepository.Save(firstName, lastName, streetAddress, city);
}

  2. Put the caret on the Save method name and expand the Smart Tag. From the list select "Add logging".

    Detailed Tracing 1

  3. The first page of the wizard is the logging profile selection dialogue. In this dialogue you can select one of the predefined profiles, edit an existing profile or create a new one. For this example click on the "New logging profile..." link to create a new logging profile.

    Logging Profiles 1

  4. Provide a name for your newly created logging profile in the opened profile customization dialogue.

    Logging Profiles 2

  5. Choose when to write a new message to the log. You can select from one of these options: when entering and exiting the method, only when entering the method, only when exception is thrown inside the method.

  6. Choose what information to include in each log message. The available options are: parameter values, names, and types, and return value of the method.

  7. Finally, select the logging level to use for the exception log messages.

  8. When you're done with customizing your new logging profile, click Save button.

    Logging Profiles 3

  9. Back in the profile selection dialogue select your profile and click Next.

    Logging Profiles 4

  10. The next page of the wizard gives you the opportunity to choose the logging back-end that you want to use. For this example select "System.Diagnostics.Trace" and click Next.

    Detailed Tracing 3

  11. The summary page gives you the opportunity to review the selections that you have made. If you notice that the configuration is not what you wanted you can click the Previous button and adjust your selections. If the configuration meets your needs click Next.

    Logging Profiles 5

  12. The progress page shows a progress bar and summary of what actions PostSharp is taking to add the selected logging configuration to your codebase. It's at this point that PostSharp and the logging pattern library will be downloaded from NuGet and added as references to your codebase.

    Detailed Tracing 5

  13. Once the download, installation and configuration of PostSharp and the logging pattern library has finished you can close the wizard and look at the changes that were made to your codebase.

    Detailed Tracing 6

  14. First of all, the code window with SolutionName.pssln file will be shown. This file stores all your custom logging profiles and other solution-level information.

    Copy
    <?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.postsharp.org/1.0/configuration" xmlns:d="clr-namespace:PostSharp.Patterns.Diagnostics;assembly:PostSharp.Patterns.Diagnostics" xmlns:p="http://schemas.postsharp.org/1.0/configuration">
  <Property Name="LoggingEnabled" Value="{has-plugin('PostSharp.Patterns.Diagnostics')}" Deferred="true" />
  <d:LoggingProfiles p:Condition="{$LoggingEnabled}">
    <d:LoggingProfile Name="New profile" OnEntryOptions="IncludeParameterValue | IncludeReturnValue | IncludeThisArgument" OnExceptionLevel="None" OnSuccessLevel="None" />
  </d:LoggingProfiles>
</Project>

  15. You'll also notice that the code you added the logging to has changed slightly. PostSharp has added a LogAttribute attribute to the method and the attribute has the name of your logging profile specified as an argument.

    C#
    Copy
    [Log( "New profile" )]
public void Save(string firstName, string lastName, string streetAddress, string city)
{
    var customerRepository = new CustomerRepository();
    customerRepository.Save(firstName, lastName, streetAddress, city);
}
    Note Note

    This example has added a single attribute to one method. If you plan on adding this logging to many different locations in your codebase you will want to read about using the MulticastAttribute: Adding Aspects to Multiple Declarations.

  16. If you were to run this method the trace logging that you added would output a log message according to the options you've specified in your logging profile.

    Detailed Tracing 7

Now that you have logging added to the Save method you are able to change the method's name as well as add and remove parameters with the confidence that your log entries will be kept in sync with each of those changes. In combination with attribute multicasting (the article Adding Aspects to Multiple Declarations), adding logging to your codebase and maintaining it becomes a very easy task.

See Also

Reference

LogAttribute
ProfileName
OnEntryOptions
OnSuccessOptions
OnExceptionOptions
OnExceptionLevel
Error

Other Resources

Adding Aspects to Multiple Declarations
Working with PostSharp Configuration Files


Walkthrough: Tracing Parameter Values Upon Exception

Walkthrough: Tracing Parameter Values Upon Exception

When you're working with your codebase it's common to need to add logging of exceptions either as a non-functional requirement or simply to assist during the development process. In either situation you will want to include information about the parameters that were passed to the method where the exception is being caught and logged. This can be a tedious and brittle process. As you work and refactor methods the order and types of parameters may change, parameters may be added and some maybe removed. Along with performing these refactorings you have to remember to update the exception logging messages to keep them in sync. This is something that is easy to forget and once forgotten the output of the logging is much less useful.

PostSharp offers a solution to all of these problems. The logging pattern library allows you to configure where logging should be performed and the pattern library takes over the task of keeping your log entries in sync as you add, remove and refactor your codebase. Let's take a look at how you can add trace logging of exceptions that includes the parameter values that were passed to the method that is being logged.

To add trace logging of exceptions that includes the parameter values:

  1. Let's add logging to our DoStuff method.

    C#
    Copy
    public void DoStuff(int i, int x)
{
    Console.WriteLine(i/x);
}

  2. Put the caret on the DoStuff method name and expand the Smart Tag. From the list select "Add logging".

    Trace Parameters 1

  3. The first option that you need to select is the Logging Profile. Here we want to choose the "Exceptions" profile and accept its default values. Click Next.

    Trace Parameters 2

  4. The next page of the wizard gives you the opportunity to choose the logging back-end that you want to use. For this example select "System.Diagnostics.Trace" and click Next.

    Detailed Tracing 3

  5. The summary page gives you the opportunity to review the selections that you have made. If you notice that the configuration is not what you wanted you can click the Previous button and adjust your selections. If the configuration meets your needs click Next.

    Trace Parameters 3

  6. The progress page shows a progress bar and summary of what actions PostSharp is taking to add the selected logging configuration to your codebase. It's at this point that PostSharp and the logging pattern library will be downloaded from Nuget and added as references to your codebase.

    Trace Parameters 4

  7. Once the download, installation and configuration of PostSharp and the logging pattern library has finished you can close the wizard and look at the changes that were made to your codebase.

    Detailed Tracing 6

  8. You'll notice that the code you added the logging to has changed slightly - PostSharp has added a LogExceptionAttribute attribute to the method.

    C#
    Copy
    [LogException]
public void DoStuff(int i, int x)
{
    Console.WriteLine(i/x);
}
    Note Note

    This example has added a single attribute to one method. If you plan on adding this logging to many different locations in your codebase you will want to read about using attribute multicasting. See Adding Aspects Declaratively Using Attributes.

  9. If you were to run this method from a console application and pass in a value of zero for the second parameter it would generate a DivideByZeroException. The trace logging that you added would output a log message plus the exception's stack trace to the console. Note that the parameter values are automatically included in the log message.

    Trace Parameters 7

  10. For those of you interested in what is happening behind the scenes we can decompile the method and observe what PostSharp has done to our codebase. You'll notice two significant things when you look at the decompiled code. First, PostSharp added in a try...catch block that wraps the entirety of the original methods contents. The second thing you'll notice is that the catch block logs the exception and re-throws it. This ensures that your code execution paths will remain unchanged after you've added the logging.

    Trace Parameters 8

Now that you have logging added to the DoStuff method you are able to change the method's name as well as add and remove parameters with the confidence that your log entries will be kept in sync with each of those changes. In combination with the attribute multicasting (See the section Adding Aspects Declaratively Using Attributes), adding logging to your codebase and maintaining it becomes a very easy task.

See Also

Reference

LogExceptionAttribute
LogAttribute

Other Resources

Adding Aspects to Multiple Declarations


Walkthrough: Changing the Logging Back-End

Walkthrough: Changing the Logging Back-End

This section describes how to change the logging back-end for a project or solution.

To change the logging back-end:

  1. Remove the NuGet package containing the previous back-end implementation, if any.

  2. Add the NuGet package containing the new back-end implementation, if any.

    The following table shows the identifier of the back-ends and the package in which they are implemented:

    Name

    NuGet Package

    Description

    Console

    PostSharp.Patterns.Diagnostics

    Logging using ConsoleWriteLine(String)

    Trace

    PostSharp.Patterns.Diagnostics

    Logging using Trace

    Log4Net

    PostSharp.Patterns.Diagnostics.Log4Net

    NLog

    PostSharp.Patterns.Diagnostics.NLog

    EnterpriseLibrary

    PostSharp.Patterns.Diagnostics.EnterpriseLibrary

  3. If the new NuGet package contains several implementations, set the LoggingBackend property in the PostSharp project file (MyProject.psproj) to the name of the chosen logging back-end. Below is an example of PostSharp project file with the LoggingBackend set to "Trace".

    Copy
    <?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.postsharp.org/1.0/configuration" OverridesDefaultProject="false">
  <Property Name="LoggingBackend" Value="Trace" />
</Project>


Adding Aspects to Code

Adding Aspects to Code

An aspect has no effect until it is applied to some element of code. PostSharp provides multiple ways to add aspects to your code.

Applying Aspects to Multiple Elements of Code Declaratively

In many situations, you want to apply the same aspect to many elements of code. For instance, you may need to add tracing or performance monitoring to all public methods of a namespace. Since there may be hundreds of affected methods, you don't want to add a custom attribute to all of them.

Thanks to an extension of semantics of custom attributes named multicast custom attribute (MulticastAttribute), it is easy to apply an aspect to multiple elements of code using a single line of code.

For details, see Adding Aspects Declaratively Using Attributes and Understanding Aspect Inheritance.

Applying Aspects to Multiple Elements of Code Imperatively

If declarative features of MulticastAttribute are not sufficient for your case, you can select elements of code imperatively. For instance, you can develop complex filters based on System.Reflection or read information from an XML file.

There are two ways you can implement imperative selection aspect targets:

Filtering Out Using CompileTimeValidate

To filter out elements of codes that have been selected by MulticastAttribute, you can implement the method CompileTimeValidate(Object) of your aspect and silently return false if the candidate target is not appropriate. .

For instance, the following aspect will apply only on security-critical methods.

C#
Copy
using System;
using System.Reflection;
using PostSharp.Aspects;

namespace Samples2
{
    [Serializable]
    public sealed class TraceSecurityCriticalAttribute : OnMethodBoundaryAspect
    {
        // Select only security-critical methods.
        public override bool CompileTimeValidate(MethodBase method)
        {
            return method.IsSecurityCritical;
        }

        public override void OnEntry(MethodExecutionArgs args)
        {
            Console.WriteLine("On Entry");
        }
    }
}

See Validating Aspect Usage for details.

Adding Aspect Instances Using IAspectProvider

If you have to implement more complex rules to select the target of aspects, you can create another aspect that will do nothing else than adding aspect instances to your code. This aspect must implement the interface IAspectProvider and will typically derive from AssemblyLevelAspect or TypeLevelAspect.

Tip Tip

Use ReflectionSearch to perform complex queries over System.Reflection.


Adding Aspects Declaratively Using Attributes

Adding Aspects Declaratively Using Attributes

In .NET, you normally need to write one line of code for any application of a target attribute. If a custom attribute applies to all types of a namespace, you have to manually add the custom attribute to every single type.

By contrast, multicast custom attributes allow you to apply a custom attribute on multiple declarations from a single line of code by using wildcards or regular expressions, or by filtering on some attributes. It makes it easy to apply an aspect to, say, all public static methods of a namespace, with a single line of code.

Multicast attributes can be inherited: you can put it on an interface and ask it to apply to all classes implementing this interface. Attribute inheritance also works for classes, virtual or interface methods, and parameters of virtual or interface methods.

Custom attributes supporting multicasting needs to be derived from MulticastAttribute. All PostSharp aspects and constraints are derived from this class.

Note Note

Multicasting of custom attribute is a feature of PostSharp. If you do not transform your assembly using PostSharp, multicast attributes will behave as plain old custom attributes.

Note Note

This documentation often refers to this as aspect multicasting and inheritance. This is not totally accurate. Although this feature has been developed to support aspects, you can use it for your own custom attributes, even if they are not aspects. To use multicasting and inheritance for custom attributes that are not aspects, simply derive the attribute class from MulticastAttribute instead of Attribute.

Attribute multicasting supports the following scenarios:

  • Adding Aspects to a Single Declaration

  • Adding Aspects to Multiple Declarations

  • Adding Aspects to Derived Classes and Methods

  • Overriding and Removing Aspect Instances

  • Reflecting Aspect Instances at Runtime

For a conceptual overview of this feature, see:.

  • Understanding Attribute Multicasting

  • Understanding Aspect Inheritance

See Also

Reference

MulticastAttribute
MulticastAttributeUsageAttribute
IAspectProvider

Other Resources

Overriding and Removing Aspect Instances
Reflecting Aspect Instances at Runtime


Adding Aspects to a Single Declaration Using Attributes

Adding Aspects to a Single Declaration Using Attributes

Aspects in PostSharp are plain custom attributes. You can apply them to any element of code as usually.

In the following example, the Trace aspect is applied to two methods.

C#
Copy
public class CustomerService
 {
     [Trace]
     public Custom GetCustomer( int customerId )
     {
         // Details skipped.
     }

     [Trace]
     public void MergeCustomers( Customer customer1, Customer customer2 );
     {
         // Details skipped.
     }
 }


Adding Aspects to Multiple Declarations Using Attributes

Adding Aspects to Multiple Declarations Using Attributes

Once have written an aspect we have to apply it to the application code so that it will be used. There are a number of ways to do this so let's take a look at one of them: custom attribute multicasting. Other ways include XML Multicasting (see the section Adding Aspects Using XML) and dynamic aspect providers (see more in the section Adding Aspects Programmatically using IAspectProvider).

This topic contains the following sections.

  • Applying to all members of a class
  • Applying an aspect to all types in a namespace
  • Excluding an aspect from some members
  • Filtering by class visibility
  • Filtering by method modifiers
  • Programmatic filtering
Applying to all members of a class

When we are trying to apply a method level aspect we can place an attribute to each of the methods.

C#
Copy
[OurLoggingAspect]
public class CustomerServices

As our codebase grows this approach becomes tedious. We need to remember to add the attribute to all of the methods on the class. If you have hundreds of classes, you may have thousands of methods you need to manually add the aspect attribute to. It's an unsustainable proposition. Thankfully, there is a way to make this easier. Instead of applying your aspect on each method you can add that attribute to the class and PostSharp will ensure that the aspect is applied to all of the methods on that class.

Applying an aspect to all types in a namespace

Even though we don't have to apply an aspect to all methods in all classes in our application, adding the aspect attribute to every class could still be an overwhelming task. If we want to apply our aspect in a broad stroke we can make use of PostSharp's MulticastAttribute.

The MulticastAttribute is a special attribute that will apply other attributes throughout your codebase. Here's how we would use it.

  1. Open the AssemblyInfo.cs, or create a new file GlobalAspects.cs if you prefer to keep things separate (the name of this file does not matter).

  2. Add an [assembly:] attribute that references the aspect you want applied.

  3. Add the AttributeTargetTypes property to the aspects's constructor and define the namespace that you would like the aspect applied to.

    C#
    Copy
    [assembly: OurLoggingAspect(AttributeTargetTypes="OurCompany.OurApplication.Controllers.*")]

This one line of code is the equivalent of adding the aspect attribute to every class in the desired namespace.

Note Note

When setting the AttributeTargetTypes you can use wildcards (*) to indicate that all sub-namespaces should have the aspect applied to them. It is also possible to indicate the targets of the aspect using regex. Add "regex:" as a prefix to the pattern you wish to use for matching.

Excluding an aspect from some members

Multicasting an attribute can apply the aspect with a very broad brush. It is possible to use AttributeExclude to restrict where the aspect is attached.

C#
Copy
[assembly: OurLoggingAspect(AttributeTargetTypes="OurCompany.OurApplication.Controllers.*", AttributePriority = 1)]
[assembly: OurLoggingAsepct(AttributeTargetMembers="Dispose", AttributeExclude = true, AttributePriority = 2)]

In the example above, the first multicast line indicates that the OurLoggingAspect should be attached to all methods in the Controllers namespace. The second multicast line indicates that the OurLoggingAspect should not be applied to any method named Dispose.

Note Note

Notice the AttributePriority property that is set in both of the multicast lines. Since there is no guarantee that the compiler will apply the attributes in the order you have specified in the code, it is necessary to declare an order to ensure processing is completed as desired.

In this case, the OurLoggingAspect will be applied to all methods in the Controllers namespace first. After that is completed, the second multicast of OurLoggingAspect is performed which then excludes the aspect from methods named Dispose.

See Overriding and Removing Aspect Instances for more details about excluding and overriding aspects.

Filtering by class visibility

Now that you've been able to apply our aspect to all classes in a namespace and its sub-namespaces, you may be faced with the need to restrict that broad stroke. For example, you may want to apply your aspect only to classes defined as being public.

  1. Add the AttributeTargetTypeAttributes property to the MulticastAttribute's constructor.

  2. Set the AttributeTargetTypeAttributes value to Public.

    C#
    Copy
    [assembly: OurLoggingAspect(AttributeTargetTypes="OurCompany.OurApplication.Controllers.*",
                            AttributeTargetTypeAttributes = MulticastAttributes.Public)]

By combining AttributeTargetTypeAttributes values you are able to create many combinations that are appropriate for your needs.

Note Note

When specifying attributes of target members or types, do not forget to provide all categories of flags, not only the category on which you want to put a restriction.

Filtering by method modifiers

Filtering at a class level may not be granular enough for your needs. Aspects can be attached at the method level and you will want to control filtering on these aspects as well. Let's look at an example of how to apply aspects only to methods marked as virtual.

  1. Add the AttributeTargetTypeAttributes property to the MulticastAttribute's constructor.

  2. Set the AttributeTargetTypeAttributes value to VirtualVirtual.

    C#
    Copy
    [assembly: OurLoggingAspect(AttributeTargetTypes="OurCompany.OurApplication.Controllers.*", AttributeTargetMemberAttributes = MulticastAttributes.Virtual)]

Using this technique you can apply a method level aspect, or stop it from being applied, based on the existence or non-existence of things like the static, abstract, and virtual keywords.

Programmatic filtering

There are situations where you will want to filter in a way that isn't based on class or method declarations. You may want to apply an aspect only if a class inherits from a specific class or implements a certain interface. There needs to be a way for you to accomplish this.

The easiest way is to override the CompileTimeValidate(Object) method of your aspect class, where you can perform your custom filtering. This is the opt-out approach. Have the CompileTimeValidate(Object) method return false without emitting any error, and the candidate target will be ignored. See the section Validating Aspect Usage for details.

The second approach is opt-in. See the section Adding Aspects Programmatically using IAspectProvider for details.

See Also

Reference

MulticastAttribute
AttributeTargetTypes
AttributeExclude
AttributePriority
AttributeTargetTypeAttributes
CompileTimeValidate(Object)
PersistMetaData

Other Resources

[usage-validation]
Adding Aspects Programmatically using IAspectProvider
Adding Aspects Using XML


Adding Aspects to Derived Classes and Methods Using Attributes

Adding Aspects to Derived Classes and Methods Using Attributes

By default, aspects apply to the class or class member which your attribute has been applied to. However, PostSharp provides the ability to specify aspect inheritance which can allow your attributes to be inherited in derived classes. This feature, named aspect inheritance can be specified on types, methods, and parameters, but not on properties or events.

Note Note

PostSharp Professional or higher edition is required for aspect inheritance.

This topic contains the following sections.

  • Applying aspects to derived types
  • Setting inheritance on a per-usage basis
  • Applying aspects to overridden methods
  • Applying aspects to new methods of derived types
Applying aspects to derived types

One way to implement aspect inheritance is to add a MulticastAttributeUsageAttribute custom attribute to your aspect class. Aspects that apply to types are typically derived from TypeLevelAspect or InstanceLevelAspect.

The benefit of this approach is that the aspect will be automatically applied to all derived classes, eliminating the need to manually setup attributes in the derived classes. Moreover, this logic lives in one place.

The following steps describe how to enable aspect inheritance on existing aspect, derived from TypeLevelAspect, which applies a DataContractAttribute attribute to the base and all derived classes, and a DataMemberAttribute attribute to all properties of the base class and those of derived classes:

How to enable aspect inheritance on existing aspect:

  1. Create a TypeLevelAspect which implements IAspectProvider. In this example we start with the AutoDataContractAttribute class which was introduced in the section Example: Automatically Adding DataContract and DataMember Attributes

  2. Decorate AutoDataContractAttribute with the MulticastAttribute, and set the Inheritance to Strict. Note that MulticastInheritance.Strict and MulticastInheritance.Multicast have the same effect when applied to type-level aspects.

    C#
    Copy
    [MulticastAttributeUsage(Inheritance = MulticastInheritance.Strict)]
[Serializable]
public sealed class AutoDataContractAttribute : TypeLevelAspect, IAspectProvider
{
   // Details skipped.
}

  3. Decorate your base class with AutoDataContractAttribute. The following snippet shows a base customer class and a derived customer class:

    C#
    Copy
    [AutoDataContractAttribute]
class Document
{
    public string Title { get; set; }
    public string Author { get; set; }
    public DateTime PublishedOn { get; set; }

}

class MultiPageArticle : Document
{
    public List<ArticlePage> Pages { get; set; }
}

When the attribute is applied to the base class, the DataContractAttribute and DataMemberAttribute attributes will be applied at compile time to both classes. If other derived classes were added, then these would be decorated automatically as well.

Setting inheritance on a per-usage basis

Specifying targets and attribute inheritance can also be done on a per-usage basis rather that hard-coding it into the custom attribute. In the following snippet, we’ve removed the MulticastAttributeUsageAttribute attribute from AutoDataContractAttribute:

C#
Copy
// MulticastAttributeUsage(Inheritance = MulticastInheritance.Strict)]
[Serializable]
public sealed class AutoDataContractAttribute : TypeLevelAspect, IAspectProvider
{
    // Details skipped.
}

Now the inheritance mode can be specified directly on the AutoDataContractAttribute instance by setting the AttributeInheritance property as shown here:

C#
Copy
[TraceMethodAttribute(AttributeInheritance = MulticastInheritance.Strict)]
class Document
{
    // Details skipped.
}
Applying aspects to overridden methods

The following example shows a custom attribute which when applied to a class, writes a message to the console window whenever a method enters and exits:

C#
Copy
[Serializable]
public sealed class TraceMethodAttribute : OnMethodBoundaryAspect
{
    public override void OnEntry(MethodExecutionArgs args)
    {
        Console.WriteLine(string.Format("Entering {0}.{1}.", args.Method.DeclaringType.Name, args.Method.Name));
    }

    public override void OnExit(MethodExecutionArgs args)
    {
        Console.WriteLine(string.Format("Leaving {0}.{1}.", args.Method.DeclaringType.Name, args.Method.Name));
    }
}

Specifying inheritance is simply a matter of adding the MulticastAttributeUsageAttribute attribute and specifying the inheritance type, or to set the AttributeInheritance property on the custom attribute usage.

In the snippet below, we have added the TraceMethod aspect to a virtual method and used the AttributeInheritance property to require the aspect to be automatically applied to all overriding methods:

C#
Copy
class Document
{
    // Details skipped.

       // This method will be traced.
    [TraceMethodAttribute(AttributeInheritance = MulticastInheritance.Strict)]
    public virtual void RenderHtml(StringBuilder html)
    {
         html.AppendLine( this.Title );
       html.AppendLine( this.Author );
    }
}

class MultiPageArticle: Document
{

  // This method will be traced.
    public override void RenderHtml(StringBuilder html)
    {
      base.RenderHtml(html);
      foreach ( ArticlePage page in this.Pages )
      {
        page.RenderHtml( html );
      }
    }

  // This method will NOT be traced.
       public void RenderHtmlPage(StringBuilder html, int pageIndex )
       {
          html.AppendFormat ( “{0}, page {1}”, this.Title, pageIndex+1 );
          html.AppendLine();
          html.AppendLine( this.Author );

       }

   }

In this example, TraceMethodAttribute will output entry and exit messages for Document.RenderHtml method and MultiPageArcticle.RenderHtml method as shown here:

Copy
Entering MultiPageArcticle.RenderHtml
Entering Document.RenderHtml
Leaving Document.RenderHtml
Leaving MultiPageArcticle.RenderHtml
Note Note

Aspect inheritance works with virtual, abstract and interface methods and their parameters.

We would get the similar result by adding the TraceMethod attribute to the Document class. Indeed, by virtue of attribute multicasting (see section Adding Aspects to Multiple Declarations for more details), adding a method-level attribute to a class implicitly adds it to all method of this class.

C#
Copy
[TraceMethodAttribute(AttributeInheritance = MulticastInheritance.Strict)]
class Document
 {
     // All property getters and setters will be traced.
     public string Title { get; set; }
     public string Author { get; set; }
     public DateTime PublishedOn { get; set; }

        // This method will be traced.
     public virtual void RenderHtml(StringBuilder html)
     {
          html.AppendLine( this.Title );
        html.AppendLine( this.Author );
     }
 }

 class MultiPageArticle: Document
 {
    // Property getters and setters will NOT be traced.
    public List<ArticlePage> Pages { get; set; }

   // This method will be traced.
     public override void RenderHtml(StringBuilder html)
     {
       base.RenderHtml(html);
       foreach ( ArticlePage page in this.Pages )
       {
         page.RenderHtml( html );
       }
     }

   // This method will NOT be traced.
        public void RenderHtmlPage(StringBuilder html, int pageIndex )
        {
           html.AppendFormat ( “{0}, page {1}”, this.Title, pageIndex+1 );
           html.AppendLine();
           html.AppendLine( this.Author );

        }

    }

However, by adding the TraceMethod aspect to all methods of the Document type, we added it to property getters and setters, influencing the output:

C#
Copy
Entering MultiPageArcticle.RenderHtml
Entering Document.RenderHtml
Entering Document.get_Title
Leaving Document.get_Title
Entering Document.get_Author
Leaving Document.get_Author
Leaving Document.RenderHtml
Leaving MultiPageArcticle.RenderHtml
Applying aspects to new methods of derived types

In the previous section the TraceMethod attribute used Strict inheritance which means that if the base class is decorated with the attribute, it will only be applied to methods which are declared in the base class and overridden in the derived class.

By changing the inheritance mode to Multicast, we specify that the aspect should be also be applied to new methods of the derived class, i.e. not only methods that are overridden from the base class.

In the following snippet we’ve changed inheritance from Strict to Multicast:

C#
Copy
[TraceMethodAttribute(AttributeInheritance = MulticastInheritance.Multicast)]
class Document
 {
     // All property getters and setters will be traced.
     public string Title { get; set; }
     public string Author { get; set; }
     public DateTime PublishedOn { get; set; }

        // This method will be traced.
     public virtual void RenderHtml(StringBuilder html)
     {
          html.AppendLine( this.Title );
      html.AppendLine( this.Author );
     }
 }

 class MultiPageArticle: Document
 {
    // Property getters and setters will ALSO be traced.
    public List<ArticlePage> Pages { get; set; }

   // This method will be traced.
     public override void RenderHtml(StringBuilder html)
     {
       base.RenderHtml(html);
       foreach ( ArticlePage page in this.Pages )
       {
         page.RenderHtml( html );
       }
     }

   // This method will ALSO be traced.
        public void RenderHtmlPage(StringBuilder html, int pageIndex )
        {
           html.AppendFormat ( “{0}, page {1}”, this.Title, pageIndex+1 );
           html.AppendLine();
           html.AppendLine( this.Author );

        }

    }

With Strict inheritance in use, TraceMethodAttribute applied to Document was not applied to the RenderHtmlPage method and the Pages property. In other words, as the name suggests, Strict inheritance is strictly applying the attribute on base members and any derived members which are inherited. However, with Multicast inheritance, the aspect is also applied to the RenderHtmlPage method and the Pages property.

Strict inheritance evaluates multicasting and then inheritance, but Multicast inheritance evaluates inheritance and then multicasting.

See Also

Reference

MulticastAttributeUsageAttribute
TypeLevelAspect
InstanceLevelAspect
DataContractAttribute
DataMemberAttribute
IAspectProvider
MulticastAttribute
Inheritance

Other Resources

Example: Automatically Adding DataContract and DataMember Attributes
Adding Aspects to Multiple Declarations


Overriding and Removing Aspect Instances

Overriding and Removing Aspect Instances

Having multiple instances of the same aspect on the same element of code is sometimes a desired behavior. With multicasting custom attributes (MulticastAttribute), it is easy to end up with that situation. Indeed, many multicasting paths can lead to the same target.

However, most of the time, a different behavior is preferred. We could define a method-level aspect on the type (this aspect would apply to all methods) and override (or even exclude) the aspect on a specific method.

The multicasting engine has both the ability to apply multiple aspect instances on the same target, and the ability to replace or remove custom attributes.

Understanding the Multicasting Algorithm

Before going ahead, it is important to understand the multicasting algorithm. The algorithm relies on a notion of order of processing of aspect instances.

Important note Important

This section covers how PostSharp handles multiple instances of the same aspect type for the sole purpose of computing how aspect instances should be overridden or removed. See Coping with Several Aspects on the Same Target to understand how to cope with multiple instances of different aspects.

The following rules apply:

  1. Aspect instances defined on a container (for instance a type) have always precedence over instances defined on an item of that container (for instance a method). Elements of code are processed in the following order: assembly, module, type, field, property, event, method, parameter.

  2. When multiple aspect instances are defined on the same level, they are sorted by increasing of value of the AttributePriority.

The algorithm builds a list of aspect instances applied (directly and indirectly) on an element of code, sorts these instances, and processes overrides or removals as described below.

Applying Multiple Instances of the Same Aspect

The property MulticastAttributeUsageAttributeAllowMultiple determines whether multiple instances of the same aspect are allowed on an element of code. By default, this property is set to true for all aspects.

In the following example, the methods in type MyClass are enhanced by one, two and three instances of the Trace aspect (see code comments).

C#
Copy
using System;
using System.Diagnostics;
using PostSharp.Aspects;
using PostSharp.Extensibility;
using Samples3;

[assembly: Trace(AttributeTargetTypes = "Samples3.My*", Category = "A")]
[assembly: Trace(AttributeTargetTypes = "Samples3.My*",
    AttributeTargetMemberAttributes = MulticastAttributes.Public, Category = "B")]

namespace Samples3
{
    [Serializable]
    public sealed class TraceAttribute : OnMethodBoundaryAspect
    {
        public string Category { get; set; }

        public override void OnEntry(MethodExecutionArgs args)
        {
            Trace.WriteLine("Entering " +
                            args.Method.DeclaringType.FullName + "." + args.Method.Name, this.Category);
        }
    }

    public class MyClass
    {
        // This method will have 1 Trace aspect with Category set to A.
        private void Method1()
        {
        }

        // This method will have 2 Trace aspects with Category set to A, B
        public void Method2()
        {
        }

        // This method will have 3 Trace aspects with Category set to A, B, C.
        [Trace(Category = "C")]
        public void Method3()
        {
        }
    }
}
Overriding an Aspect Instance Manually

You can require an aspect instance to override any previous one by setting the aspect property AttributeReplace. This is equivalent to a deletion followed by an insertion (see below).

In the following examples, the first two methods of type MyClass are enhanced by aspects applied on assembly level, but these aspects are replaced by a different one on Method3.

C#
Copy
using System;
using System.Diagnostics;
using PostSharp.Aspects;
using PostSharp.Extensibility;
using Samples5;

[assembly: Trace(AttributeTargetTypes = "Samples5.My*", Category = "A")]
[assembly: Trace(AttributeTargetTypes = "Samples5.My*",
    AttributeTargetMemberAttributes = MulticastAttributes.Public, Category = "B")]

namespace Samples5
{
    [Serializable]
    public sealed class TraceAttribute : OnMethodBoundaryAspect
    {
        public string Category { get; set; }

        public override void OnEntry(MethodExecutionArgs args)
        {
            Trace.WriteLine("Entering " +
                            args.Method.DeclaringType.FullName + "." + args.Method.Name, this.Category);
        }
    }

    public class MyClass
    {
        // This method will have 1 Trace aspect with Category set to A.
        private void Method1()
        {
        }

        // This method will have 2 Trace aspect with Category set to A, B.
        public void Method2()
        {
        }

        // This method will have 1 Trace aspects with Category set to C.
        [Trace(Category = "C", AttributeReplace = true)]
        public void Method3()
        {
        }
    }
}
Overriding an Aspect Instance Automatically

To cause a new aspect instance to automatically override any previous one, the aspect developer must disallow multiple instances by annotating the aspect class with the custom attribute MulticastAttributeUsageAttribute and setting the property AllowMultiple to false.

In the following example, the methods in type MyClass are enhanced by a single Trace aspect:

C#
Copy
using System;
using System.Diagnostics;
using PostSharp.Aspects;
using PostSharp.Extensibility;
using Samples4;

[assembly: Trace(AttributeTargetTypes = "Samples4.My*", AttributePriority = 1, Category = "A")]
[assembly: Trace(AttributeTargetTypes = "Samples4.My*",
    AttributeTargetMemberAttributes = MulticastAttributes.Public, AttributePriority = 2, Category = "B")]

namespace Samples4
{
    [MulticastAttributeUsage(MulticastTargets.Method, AllowMultiple = false)]
    [Serializable]
    public sealed class TraceAttribute : OnMethodBoundaryAspect
    {
        public string Category { get; set; }

        public override void OnEntry(MethodExecutionArgs args)
        {
            Trace.WriteLine("Entering " +
                            args.Method.DeclaringType.FullName + "." + args.Method.Name, this.Category);
        }
    }

    public class MyClass
    {
        // This method will have 1 Trace aspect with Category set to A.
        private void Method1()
        {
        }

        // This method will have 1 Trace aspects with Category set to B.
        public void Method2()
        {
        }

        // This method will have 1 Trace aspects with Category set to C.
        [Trace(Category = "C")]
        public void Method3()
        {
        }
    }
}
Deleting an Aspect Instance

The MulticastAttributeAttributeExclude property removes any previous instance of the same aspect on a target.

This is useful, for instance, when you need to exclude a target from the matching set of a wildcard expression. For instance:

C#
Copy
[assembly: Configurable( AttributeTypes = "BusinessLayer.*" )]

          namespace BusinessLayer
          {
            [Configurable( AttributeExclude = true )]
            public static class Helpers
            {

            }
          }


Reflecting Aspect Instances at Runtime

Reflecting Aspect Instances at Runtime

Attribute multicasting has been primarily designed as a mechanism to add aspects to a program. Most of the time, the custom attribute representing an aspect can be removed after the aspect has been applied.

By default, if you add an aspect to a program and look at the resulting program using a disassembler or System.Reflection, you will not find these corresponding custom attributes.

If you need your aspect (or any other multicast attribute) to be reflected by System.Reflection or any other tool, you have to set the MulticastAttributeUsageAttributePersistMetaData property to true.

For instance:

C#
Copy
[MulticastAttributeUsage( MulticastTargets.Class, PersistMetaData = true )]
  public class TagAttribute : MulticastAttribute
  {
    public string Tag;
  }
Note Note

Multicasting of attributes is not limited only to PostSharp aspects. You can multicast any custom attribute in your codebase in the same way as shown here. If a custom attribute is multicast with the PersistMetaData property set to true, when reflected on the compiled code will look as if you had manually added the custom attribute in all of the locations.


Understanding Attribute Multicasting

Understanding Attribute Multicasting

This topic contains the following sections.

  • Overview of the Multicasting Algorithm
  • Filtering Target Elements of Code
  • Filtering Properties
  • Overriding Filtering Attributes
Overview of the Multicasting Algorithm

Every multicast attribute class must be assigned a set of legitimate targets using the MulticastAttributeUsageAttribute custom attribute, which is the equivalent and complement of AttributeUsageAttribute for multicast attributes. Multicast attributes can be applied to types, methods, fields, properties, events, or/or parameters. For instance, a caching aspect targets methods. A field validation aspect targets fields.

When a field-level multicast attribute is applied to a type, the attribute is implicitly applied to all fields of that type. When it is applied on an assembly, it is implicitly applied to all fields of that assembly.

The general rule is: when a multicast attribute is applied on a container, it is implicitly (and recursively) applied to all elements of that container.

The next table illustrates how this rule translates for different kinds of targets.

Directly applied to | Implicitly applied to
Assembly or Module | Types, methods, fields, properties, parameters, and events contained in this assembly or module.
Type | Methods, fields, properties, parameters, and events contained in this type.
Property or Event | Accessors of this property or event.
Method | This method and the parameters of this method.
Field | This field.
Parameter | This parameter.
Filtering Target Elements of Code

Note that the default behavior is maximalistic: we apply the attribute to all contained elements. However, PostSharp provides a way to restrict the set of elements to which the attribute is multicast: filtering.

Both the attribute developer and the user of the aspect can specify filters.

Developer-Specified Filtering

Just like normal custom attributes should be decorated with the [AttributeUsage] custom attribute, multicast custom attributes must be decorated by the [MulticastAttributeUsage] attribute (see MulticastAttributeUsageAttribute). It specifies which are the valid targets of the multicast attributes.

For instance, the following piece of code specifies that the attribute GuiThreadAttribute can be applied on instance methods. Aspect users experience a build-time error when trying to use this aspect on a constructor or static method.

C#
Copy
[MulticastAttributeUsage(MulticastTargets.Method, TargetMemberAttributes = MulticastAttributes.Instance)]
[AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = true)]
[Serializable]
public class GuiThreadAttribute : MethodInterceptionAspect
{
// Details skipped.
}

Note the presence of the AttributeUsageAttribute attribute in the sample above. It tells the C# or VB compiler that the attribute can be directly applied to assemblies, classes, constructors, or methods. But this aspect will never be eventually applied to an assembly or a class. Indeed, the MulticastAttributeUsageAttribute attribute specifies that the sole valid targets are methods. Furthermore, the TargetMemberAttributes property establishes a filter that includes only instance methods.

Therefore, if the aspect is applied on a type containing an abstract method, the aspect will not be multicast to this method, neither to its constructors.

Tip Tip

Additionally to multicast filtering, consider using programmatic validation of aspect usage. Any custom attribute can implement IValidableAnnotation to implement build-time validation of targets. Aspects that derive from Aspect already implement these interfaces: your aspect can override the method CompileTimeValidate(Object).

Tip Tip

As an aspect developer, you should enforce as many restrictions as necessary to ensure that your aspect is only used in the way you intended, and raise errors in other cases. Using an aspect in an unexpected way may result in runtime errors that are difficult to debug.

User-Specified Filtering

The attribute user can specify multicasting filters using specific properties of the MulticastAttribute class. To make it clear that these properties only impact the multicasting process, they have the prefix Attribute.

As an aspect user, it is important to understand that you can only apply aspects to elements of codes that have been allowed by the developer of the aspect.

For instance, the following element of code adds a tracing aspect to all public methods of a namespace:

C#
Copy
[assembly: Trace( AttributeTargetTypes="AdventureWorks.BusinessLayer.*", AttributeTargetMemberAttributes = MulticastAttributes.Public )]
Filtering Properties

The following table lists the filters available to users and developers of aspects:

MulticastAttribute Property | MulticastAttributeUsageAttribute Property | Description
AttributeTargetElements | ValidOn | Restricts the kinds of targets (assemblies, classes, value types, delegates, interfaces, properties, events, properties, methods, constructors, parameters) to which the attribute can be indirectly applied.
AttributeTargetAssemblies |  | Wildcard expression or regular expression specifying to which assemblies the attribute is multicast.
 | AllowExternalAssemblies | Determines whether the aspect can be applied to elements defined in a different assembly than the current one.
AttributeTargetTypes |  | Wildcard expression or regular expression filtering by name the type to which the attribute is applied, or the declaring type of the member to which the attribute is applied.
AttributeTargetTypeAttributes | TargetTypeAttributes | Restricts the visibility of the type to which the aspect is applied, or of the type declaring the member to which the aspect is applied.
AttributeTargetMembers |  | Wildcard expression or regular expression filtering by name the member to which the attribute is applied.
AttributeTargetMemberAttributes | TargetMemberAttributes | Restricts the attributes (visibility, virtuality, abstraction, literality, ...) of the member to which the aspect is applied.
AttributeTargetParameters |  | Wildcard expression or regular expression specifying to which parameter the attribute is multicast.
AttributeTargetParameterAttributes | TargetParameterAttributes | Restricts the attributes (in/out/ref) of the parameter to which the aspect is applied.
AttributeInheritance | Inheritance | Specifies whether the aspect is propagated along the lines of inheritance of the target interface, class, method, or parameter (see Understanding Aspect Inheritance).
Caution note Caution

Whenever possible, do not rely on naming conventions to apply aspects (properties AttributeTargetTypes, AttributeTargetMembers and AttributeTargetParameters). This may work perfectly today, and break tomorrow if someone renames an element of code without being aware of the aspect.

Overriding Filtering Attributes

Suppose we have two classes A and B, B being derived from A. Both A and B can be decorated with MulticastAttributeUsageAttribute. However, since B is derived from A, filters on B cannot be more permissive than filters on A.

In other words, the MulticastAttributeUsageAttribute custom attribute is inherited. It can be overwritten in derived classes, but derived class cannot enlarge the set of possible targets. They can only restrict it.

Similarly (and hopefully predictably), the aspect user is subject to the same rule: she can restrict the set of possible targets supported by the aspect, but cannot enlarge it.


Understanding Aspect Inheritance

Understanding Aspect Inheritance

This topic contains the following sections.

  • Lines of Inheritance
  • Strict and Multicast Inheritance
Lines of Inheritance

Aspect inheritance is supported on the following elements.

Aspect Applied On | Aspect Propagated To
Interface | Any class implementing this interface or any other interface deriving this interface.
Class | Any class derived from this class.
Virtual or Abstract Methods | Any method implementing or overriding this method.
Interface Methods | Any method implementing that interface semantic.
Parameter or Return Value of an abstract, virtual or interface method | The corresponding parameter or to the return value of derived methods using the method-level rules described above.
Assembly | All assemblies referencing (directly or not) this assembly.
Note Note

Aspect inheritance is not supported on events and properties, but it is supported on event and property accessors. The reason of this limitation is that there is actually nothing like event inheritance or property inheritance in MSIL (events and properties have nearly no existence for the CLR: these are pure metadata intended for compilers). Obviously, aspect inheritance is not supported on fields.

Strict and Multicast Inheritance

To understand the difference between strict and multicast inheritance, remember the original role of MulticastAttribute: to propagate custom attributes along the lines of containment. So, if you apply a method-level attribute to a type, the attribute will be propagated to all the methods of this type (some methods can be filtered out using specific properties of MulticastAttribute, or MulticastAttributeUsageAttribute; see Adding Aspects Declaratively Using Attributes for details).

The difference between strict and multicasting inheritance is that, with multicasting inheritance (but not with strict inheritance), even inherited attributes are propagated along the lines of containment.

Consider the following piece of code, where A and B are both method-level aspects.

C#
Copy
[A(AttributeInheritance = MulticastInheritance.Strict)]
[B(AttributeInheritance = MulticastInheritance.Multicast)]
public class BaseClass
{
  // Aspect A, B.
  public virtual void Method1();
}

public class DerivedClass : BaseClass
{
  // Aspects A, B.
  public override void Method1() {}

  // Aspect B.
  public void Method2();
}

If you just look at BaseClass, there is no difference between strict and multicasting inheritance. However, if you look at DerivedClass, you see the difference: only aspect B is applied to MethodB.

The multicasting mechanism for aspect A is the following:

  1. Propagation along the lines of containment from BaseClass to BaseClass.Method1.

  2. Propagation along the lines of inheritance from BaseClass.Method1 to DerivedClass.Method.

For aspect B, the mechanism is the following:

  1. Propagation along the lines of containment from BaseClass to BaseClass.Method1.

  2. Propagation along the lines of inheritance from BaseClass.Method1 to DerivedClass.Method1.

  3. Propagation along the lines of inheritance from BaseClass to DerivedClass.

  4. Propagation along the lines of containment from DerivedClass to DerivedClass.Method1and DerivedClass.Method2.

In other words, the difference between strict and multicasting inheritance is that multicasting inheritance applies containment propagation rules to inherited aspects; strict inheritance does not.

Avoiding Duplicate Aspects

If you read again the multicasting mechanism for aspect B, you will notice that the aspect B is actually applied twice to DerivedClass.Method1: one instance comes from the inheritance propagation from BaseClass.Method1, the other instance comes from containment propagation from DerivedClass.

To avoid surprises, PostSharp implements a mechanism to avoid duplicate aspect instances. The rule: if many paths lead from the same custom attribute usage to the same target element, only one instance of this custom attribute is applied to the target element.

Caution note Caution

Attention: you can still have many instances of the same custom attribute on the same target element if they have different origins (i.e. they originate from different lines of code, typically). You can enforce uniqueness of custom attribute instances by using AllowMultiple. See the section Overriding and Removing Aspect Instances for details.

See Also

Reference

MulticastAttribute
MulticastAttributeUsageAttribute


Adding Aspects Using XML

Adding Aspects Using XML

PostSharp not only allows aspects to be applied in code, but also through XML. This is accomplished by adding them to your project’s .psproj file.

Adding aspects through XML gives the advantage of applying aspects without modifying the source code, which could be an advantage in some legacy projects.

Specifying an attribute in XML

This example is based on the AutoDataContractAttribute explained in the section Example: Automatically Adding DataContract and DataMember Attributes.

C#
Copy
 namespace MyCustomAttributes
{
    // We set up multicast inheritance so  the aspect is automatically added to children types.
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
    [Serializable]
    public sealed class AutoDataContractAttribute : TypeLevelAspect, IAspectProvider
    {
        // Details skipped.
    }
}

Normally AutoDataContractAttribute would be applied to Customer in code as follows:

C#
Copy
 namespace MyNamespace
{
    [AutoDataContractAttribute]
    class Customer
    {
        public string FirstName {get; set;}
        public string LastName { get; set; }
    }
}

Using XML instead, we can remove the custom attribute from source code and instead specify a Multicast element in the PostSharp project file, a file that has the same name as your project file (csproj or vbproj), but with the .psproj extension:

Copy
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.postsharp.org/1.0/configuration">
    <Multicast xmlns:my="clr-namespace:MyCustomAttributes;assembly:MyAssembly">
        <my:AutoDataContractAttribute  AttributeTargetTypes=" MyNamespace.Customer" />
    </Multicast>

</Project>

In this snippet, the xmlns:my attribute associates a prefix to an XML namespace, which must be mapped to the .NET namespace and assembly where custom attributes classes are defined:

Copy
<Multicast xmlns:my="clr-namespace:MyCustomAttributes;assembly:MyAssembly">

The next line then specifies the custom attribute to apply and the target attributes to apply the custom attributes to:

Copy
<my:AutoDataContractAttribute  AttributeTargetTypes="MyNamespace.Customer" />

The XML element name must be the name of a class inside the .NET namespace and assembly as defined by the XML namespace. Attributes of this XML element map to public properties or fields of this class.

Note that any property inherited from MulticastAttribute can be used here in order to apply the aspect to several classes at a time. See the section Adding Aspects to Multiple Declarations for details about these properties.

See Also

Other Resources

Example: Automatically Adding DataContract and DataMember Attributes
Adding Aspects to Multiple Declarations


Adding Aspects Programmatically using IAspectProvider

Adding Aspects Programmatically using IAspectProvider

You may have situations where you are looking to implement an aspect as part of a larger pattern. Perhaps you want to add an aspect, implement an interface and dynamically inject some logic into the target code. In those situations you will want to apply an aspect to the target code and have that aspect then add other aspects to other elements of code.

The theoretical concept can cause some mental gymnastics, so let's take a look at the implementation.

  1. Create an aspect that implements that IAspectProvider interface.

    C#
    Copy
     public class ProviderAspect : IAspectProvider
{
   public IEnumerable<AspectInstance> ProvideAspects(object targetElement)
   {
       throw new System.NotImplementedException();
   }
}

  2. Cast the target object parameter to the type that will be targeted by this aspect: Assembly, Type, MethodInfo, ConstructorInfo or LocationInfo.

    C#
    Copy
     public IEnumerable<AspectInstance> ProvideAspects(object targetElement)
{
   Type type = (Type) targetElement;

   throw new NotImplementedException();
}

  3. In the ProvideAspects(Object) method returns an AspectInstance of the aspect type you want, for every target element of code.

    C#
    Copy
     public IEnumerable<AspectInstance> ProvideAspects(object targetElement)
{
    Type type = (Type)targetElement;

    return type.GetMethods().Select(
       m => return new AspectInstance(targetElement, new LoggingAspect()) );

}

This aspect will now add aspects dynamically at compile time. Use of the IAspectProvider interface and technique is usually reserved for situations where you are trying to implement a larger design pattern. For example, it would be used when implementing an aspect that created the NotifyPropertyChangedAttribute pattern across a large number of locations in your codebase. It is overkill for many of the situations that you will encounter. Use it only for complicated pattern implementation aspects that you will create.

Note Note

To read more about NotifyPropertyChangedAttribute, see Customizing the NotifyPropertyChanged Aspect.

Note Note

PostSharp does not automatically initialize the aspects provided by IAspectProvider, even if the method CompileTimeInitialize is defined. Any initialization, if necessary, should be done in the ProvideAspects method or in the constructor of provided aspects.

However, these aspects are initialized at runtime just like normal aspects using the RunTimeInitialize method.

Creating Graphs of Aspects

It is common that aspects provided by IAspectProvider (children aspects) form an object graph. For instance, children aspects may contain a reference to the parent aspect.

An interesting feature of PostSharp is that object graphs instantiated at compile-time are serialized, and can be used at run-time. In other words, if you store in a child aspect a reference to another aspect, you will be able to use this reference at runtime.

See Also

Reference

IAspectProvider
NotifyPropertyChangedAttribute
ProvideAspects(Object)
AspectInstance

Other Resources

INotifyPropertyChanged
Customizing the NotifyPropertyChanged Aspect


Threading Patterns

Threading Patterns

The Threading Pattern Library helps building multi-threaded applications with fewer lines of code and fewer defects. The library implements locking models (thread unsafe, reader-writer synchronized, actor), thread synchronization aspects (to background thread, to UI thread), and a deadlock detection facility.

It provides the following features:

  • Threading Models. A threading model is a design pattern that gives guarantees that your code executes safely on a multi-threaded computer. Three models are implemented: Thread Exclusive (thread unsafe), Reader-Writer Synchronized, and Actor. See Writing Thread-Safe Code with Threading Models for details.

  • Thread Dispatching. Custom attributes DispatchedAttribute and BackgroundAttribute cause the execution of a method to be dispatched to the UI thread or to a background thread, respectively. For details, read Dispatching a Method to the UI Thread and Dispatching a Method to Background.

  • Deadlock Detection. Detects deadlocks at runtime and throws an exception instead of allowing your application to freeze. For details, see Detecting Deadlocks at Runtime.


Writing Thread-Safe Code with Threading Models

Writing Thread-Safe Code with Threading Models

A threading model is a design pattern that gives guarantees that your code executes safely on a multi-threaded computer. Threading models both define coding rules (for instance: all fields must be private) and add new behaviors to existing code (for instance: acquiring a lock before method execution). Coding rules are typically enforced at build time or at run time; violations result in build-time errors or run-time exceptions. Threading models may also require the use of custom attributes in source code, for instance to indicate that a method requires read access to the object.

Tip Tip

We recommend to assign a threading model to every class whose instances can be shared between different threads.

Threading models raise the level of abstraction at which multi threading is addressed. Compared to working directly with locks and other low-level threading primitives, using threading models has the following benefits:

  • Threading models are named solutions to a recurring problem. Threading models are specific types of design patterns, and have the same benefits. When team members discuss the multi-threaded behavior of a class, they just need to know which threading model this class uses. They don't need to know the very details of its implementation. Since the human short-term memory seems to be limited to 5-9 elements, it is important to think in terms of larger conceptual blocks whenever we can.

  • Much of the code required to implement the threading model can be automatically generated, which decreases the number of lines of code, and therefore the number of defects. It also reduces development and maintenance costs.

  • Your source code can be automatically verified against the selected threading model, both at build time and at run time. This makes the discovery of defect much more deterministic. Without verifications, threading defects usually show up randomly and provoke data structure corruption instead of immediate exceptions. Run-time verification would be too labor-intensive to implement without compiler support, so would be most likely omitted.

Available threading models

PostSharp Threading Library provides an implementation for the following threading models:

Threading Model | Aspect Type | Description
Thread-Unsafe Threading Model | ThreadUnsafeAttribute | These objects may never be accessed concurrently by several threads.
Thread Affine Threading Model | ThreadAffineAttribute | These objects must be accessed from a the thread that instantiated them.
Synchronized Threading Model | SynchronizedAttribute | Synchronized objects can be accessed by a single thread at a time. Other threads will wait until the object is available.
Reader/Writer Synchronized Threading Model | ReaderWriterSynchronizedAttribute | These objects that can be read concurrently by several threads, but write access requires exclusivity. Public methods of this object must specify which kind of access they require (read or write, typically).
Actor Threading Model | ActorAttribute | These objects communicate with their clients using an asynchronous communication pattern. All accesses to the object are queued and then processed in a single thread. However, queuing is transparent to clients, which just call standard void or methods.
Freezable Threading Model | FreezableAttribute | These objects can be set to a state where their property values can no longer be changed. Unlike immutable objects, the developer dictates the time and place in their code where changes to the object's state will no longer be accepted.
Immutable Threading Model | ImmutableAttribute | These objects cannot have their state changed after their constructor has finished executing.
Other topics
Article | Description
Opting In and Out From Thread Safety | This article shows how to disable the enforcement of the threading model for specific fields or methods.
Compatibility of Threading Models | This article lists compatibility of threading models when they are applied to objects that are in a parent-child relationship.
Enabling and Disabling Runtime Verification | This article explains when runtime verification is enabled or disabled and how to customize the default behavior.
Conceptual documentation

Please read this technical white paper for details about the concepts and architecture of PostSharp Threading Models.


Freezable Threading Model

Freezable Threading Model

When you need to prevent changes to an instance of an object most of the time, but not all of the time, the Immutable pattern (implemented by the ImmutableAttribute aspect) will be too aggressive for you. In these situations you need a pattern that allows you to define the point in time where immutability begins. To accomplish this you can make use of the FreezableAttribute aspect.

This topic contains the following sections.

  • Making an object freezable using the UI
  • Making an object freezable manually
  • Freezing an object
  • Determining whether an object is in frozen state
  • Freezable object trees
Making an object freezable using the UI

To make an object freezable all you need to do is add the FreezableAttribute attribute to the class in question.

Note Note

This example shows freezing a class that only has primitive data types. Information on working with complex objects can be found the Freezable Object Trees section later in this article.

  1. First place the caret on the name of the object that you want to make freezable. The smart tag will appear below the object name. Expand it and select "Apply Threading Model...".

    Apply Threading Model Smart Tag

  2. In the Apply Threading Model wizard select "Apply freezable threading model" and click Next.

    If you have not added a reference to the threading model assembly the Apply Threading Model wizard will download it from NuGet and add the reference.

  3. Once the wizard has completed the object will now be flagged as freezable and the Customer and Item properties have had Parent-Child relationships established on them.

    C#
    Copy
    using PostSharp.Patterns.Threading;

[Freezable]
public class Invoice
{
  public long Id { get; set; }
}
Making an object freezable manually
Note Note

This example shows freezing a class that only has primitive data types. To see how to work with complex objects see the [] section later in this article.

  1. Add the PostSharp.Patterns.Threading package to your project using NuGet.

  2. Add the FreezableAttribute custom attribute to your class.

    C#
    Copy
    using PostSharp.Patterns.Threading;

[Freezable]
public class Invoice
{
  public long Id { get; set; }
}
Freezing an object

To freeze an object, use will first have to case the object to the IFreezable interface. After that you are able to call the Freeze method.

C#
Copy
var invoice = new Invoice();
invoice.Id = 123456;

((IFreezable)invoice).Freeze();
Note Note

The IFreezable interface will be injected into the Invoice class after compilation. Tools that are not aware of PostSharp may incorrectly report that the Invoice class does not implement the IFreezable interface.

Instead of using the cast operator, you can also use the CastSourceType, TargetType(SourceType) method. This method is faster and safer than the cast operator because it is verified and compiled by PostSharp at build time.

Note Note

If you are attempting to freeze either AdvisableCollectionT or AdvisableDictionaryTKey, TValue you will not be able to use the cast operator or the CastSourceType, TargetType(SourceType) method. Instead, you will have to use the QueryInterfaceT(Object, Boolean) extension method.

Once you’ve called the Freeze method on an object instance the code will no longer be able to change the property values on that instance. If a value change is attempted the code will throw an ObjectReadOnlyException.

C#
Copy
var invoice = new Invoice();
invoice.Id = 123456;

((IFreezable)invoice).Freeze();

// This will throw an exception.
invoice.Id = 345678;
Determining whether an object is in frozen state

To determine whether an object has been frozen, cast it to IThreadAware and get the readonly value from IsReadOnly via the ConcurrencyController property.

C#
Copy
var invoice = new Invoice();
invoice.Id = 123456;

((IFreezable)invoice).Freeze();

// The 'frozen' property will be set to 'true'.
bool frozen = ((IThreadAware)invoice).ConcurrencyController.IsReadOnly;
Freezable object trees

The Freezable pattern relies on the Aggregatable pattern. The AggregatableAttribute aspect will be implicitly added to the target class. Therefore, you can not only create freezable classes, but also freezable object trees. Read the Parent/Child Relationships for more information on how to establish object trees.

Important note Important

Children of freezable objects must be either freezable either immutable. Therefore, children classes must be annotated with the FreezableAttribute or ImmutableAttribute custom attribute. Collection types must be derived from AdvisableCollectionT or AdvisableDictionaryTKey, TValue.

See Also

Reference

FreezableAttribute
AggregatableAttribute
ChildAttribute
ParentAttribute
ImmutableAttribute
AdvisableDictionaryTKey, TValue
AdvisableCollectionT

Other Resources

Immutable Threading Model
Parent/Child Relationships
Walkthrough: Annotating an Object Model for Parent-Child Relationships
Working With Collections


Immutable Threading Model

Immutable Threading Model

There are times when you want certain objects in your codebase to retain their post creation state without possibility of it ever changing. These objects are said to be immutable. Immutable objects are useful in multi-threaded applications because they can be safely accessed by several threads concurrently, without need for locking or other synchronization. PostSharp offers the ImmutableAttribute aspect that allows you enforce this pattern on your objects.

Changes in an object with the ImmutableAttribute aspect will be forbidden as soon as the object constructor exits. Any further attempt to modify the object will result in an ObjectReadOnlyException.

Note Note

The Immutable pattern can be too strong for some common object-oriented scenarios, for instance with serializable classes. In some cases, the Freezable object is a better choice. For details, see Freezable Threading Model.

This topic contains the following sections.

  • Making a class immutable
  • Immutable object trees
  • Immutable vs readonly
  • Constructor Execution
Making a class immutable

To make an object immutable all you need to do is add the ImmutableAttribute attribute to the class in question.

Note Note

This example shows freezing a class that only has primitive data types. Information on working with complex objects can be found the Working With Immutable Object Trees section later in this article.

To add the Immutable pattern using the UI:

  1. First place the caret on the name of the class that you want to make immutable. The smart tag will appear below the object name. Expand it and select Apply Threading Model.

    Apply Threading Model Smart Tag

  2. In the Apply Threading Model wizard select Apply immutable threading model and click Next.

    If you have not yet added the PostSharp.Patterns.Threading package to your project, the Apply Threading Model wizard will download it from NuGet and install it into your project.

  3. Once the wizard has completed the class will now be flagged as immutable.

    C#
    Copy
    using PostSharp.Patterns.Threading;

[Immutable]
public class Invoice
{
  public Invoice(long id)
  {
    Id = id;
  }
  public long Id { get; set; }
}

    Now, once you’ve created an instance of the immutable object your code will no longer be able to change the property values on that instance. If a value change is attempted the code will throw an ObjectReadOnlyException.

    C#
    Copy
    var invoice = new Invoice(12345);

// This will throw an exception.
invoice.Id = 345678;

To add the Immutable pattern manually:

  1. Add the PostSharp.Patterns.Threading package to your project using NuGet.

  2. Add the ImmutableAttribute custom attribute to your class.

Immutable object trees

Because the Immutable pattern is an implementation of the Aggregatable pattern, all of the same behaviors of the AggregatableAttribute are available. As a result you can create both immutable classes and immutable object trees. For more information regarding object trees, read Parent/Child Relationships.

Note Note

Children of immutable objects must be marked as immutable themselves. Adding the ImmutableAttribute to the child classes will accomplish this. Additionally, collection types must be derived from AdvisableCollectionT or AdvisableDictionaryTKey, TValue.

Immutable vs readonly

Many C# developers make use of the readonly keyword in an attempt to make their objects immutable. The readonly keyword doesn't guarantee immutability though. Using readonly only ensures that no method other than the object's constructor can alter the variable's value. It doesn't, however, prevent you from altering values on complex objects outside of the constructor.

In the following code sample the _id variable is a primitive type and can't be altered outside the constructor. This is enforced at compile time and an error would be displayed where the SetIdentifier method attempts to change the _id field's value.

C#
Copy
public class Invoice
{
  public readonly long _id;
  public Invoice(long id)
  {
    SetIdentifier(id);
  }
  public void SetIdentifier(long id)
  {
    _id = id
  }
}

If you were to mark a complex object as readonly the same rule holds true as it does for primitive types. You are not able to change the complex object instance outside of the constructor. In the following example, initializing the Customer in the constructor is valid, but reinitializing it in the Refresh method will cause a compilation error.

C#
Copy
public class Invoice
{
  public readonly Customer _customer;
  public Invoice()
  {
    _customer = new Customer();
  }

  public void Refresh()
  {
    //will cause a compilation error
    _customer = new Customer();
  }
}

What you can do when a complex object is marked as readonly is alter the values within that complex object. In the case of the Customer object you cannot reinitialize the instance but you can change the properties on the already created instance. What you see in the following Refresh methd is perfectly valid.

C#
Copy
public class Invoice
{
  public readonly Customer _customer;
  public Invoice()
  {
    _customer = new Customer();
  }

  public void Refresh()
  {
    //valid but not immutable
    _customer.Name = "Jim";
    _customer.Phone = "555-123-9876";
  }
}

The same type of change to object state can happen with collections. You can not reinitializee a readonly collection, but you can freely Add, Remove, Clear and do other operations that the collection itself exposes. Additionally if the collection contains complex types you are able to change values on each instance that the collection contains.

C#
Copy
public class Invoice
{
  public readonly IList<Item> _items;
  public Invoice()
  {
    _items = new List<Item>();
  }

  public void Refresh()
  {
    //will cause a compilation error
    _items = new List<Item>();

    //valid but not immutable
    _items.Add(new Item);
    _items[0].Price = 3.50;
    _items.RemoveAt(0);
  }
}

As you can see there is no way to use the readonly keyword to make complex object graphs immutable. Combining the ImmutableAttribute, ChildAttribute, AdvisableCollectionT and the AdvisableDictionaryTKey, TValue types allows you to make immutable objects that guarantee no changes to primitive or complex objects after constructor execution has completed.

Constructor Execution

Objects are not frozen until the last constructor has finished executing. Because of this you can use the constructor to set up the state of the parent instance through its own constructor as well as chained, or inherited object, constructors. You're also able to make changes to child object instances through their constructors at this time.

Copy
[Immutable]
public class Invoice : Document
{
  public Inovice(long id) : base(id)
  {
    Id = id;
    Items = new AdvisableCollection<Item>();
    Items.Add(new Item("widget"));
  }

  [Child]
  public AdvisableCollection<Item> Items { get; set; }
}

[Immutable]
public class Document
{
  private long _id;
  public Document (long id)
  {
    _id = id;
  }
}

[Immutable]
public class Item
{
  public Item (string name)
  {
    Name = name;
  }
  public string Name { get; set; }
}

In this example the constructors finish executing in the order of Document, Item and finally Invoice. It is not until after the Invoice constructor finishes executing that the object graph is made immutable.

See Also

Reference

ImmutableAttribute
AggregatableAttribute
AdvisableDictionaryTKey, TValue
AdvisableCollectionT


Actor Threading Model

Actor Threading Model

Given the complexity of trying to coordinate accesses to an object from several threads, sometimes it makes more sense to avoid multi threading altogether. The Actor model avoids the need for thread safety on class instances by routing method calls from each instance to a single message queue which is processed, in order, by a single thread.

Since the processing for each instance takes place in a single thread, multi-threading is avoided altogether and the object is guaranteed to be free of data races. Calls are processed asynchronously in the order in which they were added to the message queue. Because all calls to an actor are asynchronous, it is recommended that the async/await feature of C# 5.0 be used.

Additionally to provide a race-free programming model, the Actor pattern has the benefit of transparently distributing the computing load to all available CPUs without additional logic. Note that PostSharp’s implementation does not assign a new thread to each actor instance but uses a thread pool instead, so it is possible to have a very large number of actors with relatively low overhead.

This topic contains the following sections.

  • A single-threaded example
  • Applying the Actor model using the UI
  • Applying the Actor manually
  • Working with complex state
  • Dealing with constraints of the Actor model
A single-threaded example

Consider the following example of an AverageCalculator class. The code is not thread because incrementing the count has four operations (read and write) that must all be performed atomically.

C#
Copy
class AverageCalculator
{
    float sum;
    int count;

    public void AddSample(float n)
    {
        this.count++;
        this.sum += n;
    }

    public float GetAverage()
    {
        return this.sum / this.count;
    }
}

We could use the Synchronized or Reader-Writer Synchronized threading model to make sure that the calling thread will wait if the object is currently being accessed by another thread. Another solution in this situation is to avoid concurrency altogether using the Actor pattern and asynchronous methods.

Applying the Actor model using the UI

To apply the Actor threading model to your class with the UI:

  1. Place the mouse cursor over your class name and select “Apply threading model…” from the drop-down.

  2. Select “Apply actor threading model” and click Next.

  3. Verify the actions on the Summary screen and click Next.

  4. Click Finish after the installation completes:

    Your class will now have the ActorAttribute and all dependencies will have been added to the project.

  5. Finally, you need to change all methods that have a return value to asynchronous methods, and modify the code that calls them.

Applying the Actor manually

To apply the Actor threading model manually:

  1. Add the PostSharp.Patterns.Threading NuGet package to your project.

  2. Add the ActorAttribute to the class.

  3. Finally, you need to change all methods that have a return value to asynchronous methods, and modify the code that calls them.

In the reworked example below, the AverageCalculator class has had the ActorAttribute added and the GetAverage methods has been changed into asynchronous an methods. The AddSample method was not changed because it does not have a return value.

C#
Copy
[Actor]
class AverageCalculator
{
    float sum;
    int count;

    public void AddSample(float n)
    {
        this.count++;
        this.sum += n;
    }

    public async Task<float> GetAverage()
    {
        return this.sum / this.count;
    }
}

You can now use the same AverageCalculator from two concurrent threads.

C#
Copy
class Program
{
    static void Main(string[] args)
    {
        MainAsync().GetAwaiter().GetResult();
    }

    static async Task MainAsync()
    {
        AverageCalculator averageCalculator = new AverageCalculator();

        SampleObserver observer = new SampleObserver(averageCalculator);
        DataSources.Source1.Subscribe(observer);
        DataSources.Source2.Subscribe(observer);

        Console.ReadKey();

        float average = await averageCalculator.GetAverage();

        Console.WriteLine("Average: {0}", average);
    }
}

class SampleObserver : IObserver<float>
{
    AverageCalculator calculator;

    public void OnNext( float value )
    {
      // Each of the data sources can call us from a different thread and concurrently.
      // But we don't have to care since our calculator will enqueue method calls.
      this.calculator.AddSample( value );
    }

    // Details skipped.
}

Behind the scenes, each invocation of AverageCalculator.AddSample is added to the message queue by the ActorAttribute, which then processes each call sequentially in the order it was added to the queue. This gives us the guarantee that an instance of the AverageCalculator class is never being accessed concurrently by two threads, and eliminates the need to make take multi-threading into account.

Working with complex state

PostSharp generates code that prevents the fields of an actor class to be accessed from an invalid context. For instance, trying to read an actor field from a background task would result in a ThreadAccessException. However, very often, state is more complex than fields of simple type like [int] or [string]. State can be composed of several objects and collections.

To prevent state corruption, it is important that PostSharp generates code that enforces the Actor model at runtime even for child objects of the actor.

To add complex state to actor classes:

  1. Declare the Parent-Child relationship on the property using the ChildAttribute custom attribute:

    C#
    Copy
    [Actor]
class AverageCalculator
{
    float sum;
    int count;

    [Child]
    private CounterInfo counterInfo;

    // Other details skipped for brevity
}

  2. Add the PrivateThreadAwareAttribute attribute to the child class.

    C#
    Copy
    [PrivateThreadAware]
public class CounterInfo
{
    public string Name { get; set; }
}

For more information regarding parent-child relationships in threading models, see also Parent/Child Relationships.

Dealing with constraints of the Actor model

Per definition of the Actor model, all methods are executed asynchronously. Methods that have no return value (void methods) can be executed asynchronously without syntactic changes. However, methods that do have a return value need to be made asynchronous using the async keyword.

In some situations, the application of the async keyword and the corresponding dispatching of the method may be unnecessary. For instance, a method that returns immutable information is always thread-safe and does not need to be dispatched. For more information on excluding methods from dispatching, see Opting In and Out From Thread Safety.

See Also

Reference

ActorAttribute
ChildAttribute
ParentAttribute
PrivateThreadAwareAttribute
ReferenceAttribute
ThreadAccessException

Other Resources

Opting In and Out From Thread Safety


Reader/Writer Synchronized Threading Model

Reader/Writer Synchronized Threading Model

When a class instance is concurrently used by multiple threads, accesses must be synchronized to prevent data races, which typically result in data inconsistencies and corruption of data structures.

Consider the following example of an Order class which stores an amount and a discount:

C#
Copy
class Order
{
    int Amount { get; private set; }
    int Discount { get; private set; }

    public int AmountAfterDiscount
    {
        get { return this.Amount - this.Discount; }
    }

    public void Set(int amount, int discount)
    {
        if (amount < discount)
            throw new InvalidOperationException();

        this.Amount = amount;
        this.Discount = discount;
    }
}

In this example, the Set method writes to the Amount and Discount members, while the AmountAfterDiscount property reads these members. In a single-threaded program, the AmountAfterDiscount property is guaranteed to be positive or zero. However, in a multi-threaded program, the AmountAfterDiscount property could be evaluated in the middle of the Set operation, and return an inconsistent result.

This topic contains the following sections.

  • Problems of the lock keyword
  • Reader-writer locks
  • Making a class reader-writer synchronized
  • Executing long-running write methods
  • Working with object trees
Problems of the lock keyword

The easiest way to synchronize accesses to a class in C# is to use the lock keyword. However, this practice cannot be generalized for two reasons:

  • The use of exclusive locks often results in high contention and therefore low performance because many threads queue to access the same resource;

  • Applications relying on exclusive locks are prone to deadlocks because of cyclic waiting dependencies.

Reader-writer locks

Reader-writer locks take advantage of the fact that most applications involve much fewer writes than reads, and that concurrent reads are always safe. Reader-writer locks ensure that no other thread is accessing the object when it is being written. Reader-writer locks are normally implemented by the .NET classes ReaderWriterLock or ReaderWriterLockSlim. The following example shows how ReaderWriterLockSlim would be used to control reads and writes in the Order class:

C#
Copy
class Order
{
    private ReaderWriterLockSlim orderLock = new ReaderWriterLockSlim();

    public decimal Amount { get; private set; }
    public decimal Discount { get; private set; }

    public decimal AmountAfterDiscount
    {
        get
        {
            orderLock.EnterReadLock();
            decimal result = this.Amount - this.Discount;
            orderLock.ExitReadLock();
            return result;
        }
    }

    public void Set(decimal amount, decimal discount)
    {

        if (amount < discount)
        {
            throw new InvalidOperationException();
        }

        orderLock.EnterWriteLock();
        this.Amount = amount;
        this.Discount = discount;
        orderLock.ExitWriteLock();
    }
}

However, working directly with the ReaderWriterLock and ReaderWriterLockSlim classes has disadvantages:

  • It is cumbersome because a lot of code is required.

  • It is unreliable because it is too easy to forget to acquire the right type of lock, and these errors are not detectable by the compiler or by unit tests.

So, not only the direct use of locks results in more lines of code, but it won’t reliably prevent non-deterministic data structure corruptions.

Making a class reader-writer synchronized

PostSharp Threading Pattern Library has been designed to eliminate non-deterministic data corruptions while reducing the size of thread synchronization code to the absolute minimum (but not less).

The ReaderWriterSynchronizedAttribute aspect implements the threading model (or threading pattern) based on the reader-writer lock, with the following principles:

  • At any time, the object can be open for reading or closed for reading.

  • Methods define their required access level using [ReaderAttribute] and [WriterAttribute] custom attributes (other access levels exist for advanced scenarios)

  • An error will be emitted at build-time or runtime, but deterministically, whenever an object field is being accessed by a method that does not have the required access level on the object.

There are two ways to add the reader-writer-synchronized pattern to your class:

  1. using the user interface

  2. manually

To apply the Reader-Writer Synchronized pattern using the user interface:

  1. Hover the mouse over the class name. This displays the smart tag dropdown.

  2. Click the smart tag dropdown and click Apply threading model:

    Reader Writer 1

  3. Select Apply reader-writer-synchronized threading model and click Next:

    Reader Writer 2

  4. Click Next on the summary screen and the click on Finished to complete the process. The ReaderWriterSynchronizedAttribute attribute is now applied to the class.

  5. Once ReaderWriterSynchronizedAttribute is applied to the class, each method or property which accesses member data must then be marked as a reader or a writer. Position the caret on the name of the method or on the get or set keyword and choose "Acquire reader lock" or "Acquire writer lock" from the smart tag dropdown.

To apply ReaderWriterSynchronizedAttribute to a class manually:

  1. Add NuGet Package PostSharp.Patterns.Threading.

  2. Add using PostSharp.Patterns.Threading.

  3. Add the custom attribute [ReaderWriterSynchronizedAttribute] to the class.

  4. Add the custom attribute [ReaderAttribute] or [WriterAttribute] to the public and internal methods. Note that it is not necessary to put these attributes on property getters and setters or on events.

The following code shows the Order class , synchronized with the reader-writer threading pattern:

C#
Copy
[ReaderWriterSynchronized]
class Order
{
    decimal Amount { get; private set; }
    decimal Discount { get; private set; }

    public decimal AmountAfterDiscount
    {
        get { return this.Amount - this.Discount; }
    }

    [Writer]
    public void Set(decimal amount, decimal discount)
    {
        if (amount < discount)
            throw new InvalidOperationException();

        this.Amount = amount;
        this.Discount = discount;
    }
}

ReaderAttribute places a lock on the instance whenever the property or method is invoked. While this lock is held, other threads can also invoke a property or method of that instance which reads, but calls to properties or methods marked with WriterAttribute will be blocked until all reads are complete.

Likewise, invoking properties or methods marked with WriterAttribute will lock the instance causing reads to block until the write has completed and the write lock has been released.

Since ReaderWriterSynchronizedAttribute requires that all properties and methods which access member data be marked with ReaderAttribute or WriterAttribute, ReaderWriterSynchronizedAttribute throws an exception when an accessor does not have one of these attributes. This ensures that unsynchronized reads and writes are caught the instant they occur.

Note Note

Property getters are intrinsically thread-safe and don’t need to be marked with a [ReaderAttribute] custom attribute.

Executing long-running write methods

Since write methods require exclusive access to the object, they should complete as quickly as possible. However, this is not always possible. Some long-running write methods really do a lot of write operations (or rely on slow external services) which make them inappropriate for the reader-writer-synchronized model. However, many write methods are actually composed of a lot of read operations but just a few write operations at the end. In this case, it is possible to use a combination of the UpgradeableReaderAttribute and WriterAttribute attributes. The UpgradeableReaderAttribute attribute ensures that no other thread than the current one will be able to acquire a writer lock on the object, so it gives the guarantee that the object is not going to be modified during the method’s execution. A method that holds an upgradeable reader lock can then invoke a method with the WriterAttribute attributes custom attribute. Note that it is important that the writer methods leave the object in a consistent state before exiting, because other threads will be allowed to read the object.

The following example builds on that in the section where the Order class contains a collection of Line objects which make up the order. In the example below, a new method called Recalculate() has been added to Order which iterates through each Line in the collection, tallies up the amount from each, and then stores the total in Amount.

Since the Recalculate method performs a series of reads followed by a write operation (to store the total in Amount), it is marked with the UpgradeableReaderAttribute attribute which ensures that all of the orders that it reads remain locked so that it calculates and writes out the correct total. In addition to this, the set accessor of the Order’s Amount property as been marked with WriterAttribute:

C#
Copy
[ReaderWriterSynchronized]
class Order
{
    // Other details skipped for brevity.

    public decimal Amount
    {
       // The [Reader] attribute optional here is optional because the method is a public getter.
       get;

       // The [Writer] attribute is required because, although the method is a setter, this setter is private,
       // therefore is does not acquire write access by default.
       [Writer] private set;
    }

    [UpgradeableReader]
    public void Recalculate()
    {
        decimal total = 0;

        for (int i = 0; i < lines.Count; ++i)
        {
            total += lines[i].Amount;
        }

        this.Amount = total;
    }
}
Working with object trees

Because the Reader/Writer Synchronized model is an implementation of the Aggregatable pattern, all of the same behaviors of the AggregatableAttribute are available. For more information regarding object trees, read Parent/Child Relationships.

Note Note

Once you have established your parent-child relationships you will need to apply compatible threading models to the child classes. You will want to refer to the Compatibility of Threading Models article to determine which threading model will work for the children of the Read/Writer Synchronized object.

See Also

Reference

ReaderWriterSynchronizedAttribute
WriterAttribute
ReaderAttribute
UpgradeableReaderAttribute
YielderAttribute
ExplicitlySynchronizedAttribute

Other Resources

Compatibility of Threading Models


Synchronized Threading Model

Synchronized Threading Model

A common way to avoid data races is to enclose all public instance methods of a class with a lock(this) statement. This is basically what the Synchronized model does

This article describes how to use the Synchronized model and how it differs from the use of lock(this) statement.

This topic contains the following sections.

  • Comparing with lock(this)
  • Applying the Synchronized Model using the UI
  • Applying Synchronized manually
  • Working with object trees
Comparing with lock(this)

Traditionally, the C# keyword lock(this) statement has been used to synchronize access of several threads to a single object. When an object is locked by one thread, any other object that attempts to access that object will have its execution blocked.

C#
Copy
private object myLockingObject = new Object();

public void DoSomething()
{
    lock(myLockingObject)
    {
        //some code that does something in one thread at a time
    }
}

In this example the myLockingObject member variable is used as a locking object. Once a thread runs the lock(myLockingObject) line, all other threads that enter the DoSomething method will stop executing, or be blocked, until the original thread has exited the lock(myLockingObject) code block.

The Synchronized model is similar to using the lock statement around every single public method, but it has the following differences:

  • It is not technically equivalent to locking the current instance (this). Another object is actually being locked.

  • Locking is automatic for all public and internal instance methods. You cannot forget it.

  • If a thread attempts to access a field without having first acquired access to the object (by invoking a public or internal method), an exception will be thrown.

  • The pattern also works with entities composed of several objects organized in a tree.

Applying the Synchronized Model using the UI

To apply the Synchronized threading model to your class with the UI:

  1. Place the cursor over your class name and select "Apply threading model..." from the drop down

  2. Select "Apply Synchronized threading model" from the Select Model tab and select "Next".

  3. Confirm the actions on the Summary tab and select "Next".

  4. Click Finish after the installation completes.

    Your class will now have the SynchronizedAttribute and any previously missing PostSharp related references will have been added to the project.

Applying Synchronized manually

To apply the Synchronized threading model manually:

  1. Add the PostSharp.Patterns.Threading NuGet package to your project.

  2. Add the SynchronizedAttribute to the class.

In the example below the SynchronizedAttribute has been added to the class.

C#
Copy
[Synchronized]
public class OrderService
{
    public void Process(int sequence)
    {
        Console.WriteLine("sequence {0}", sequence);
        Console.WriteLine("sleeping for 10s");

        Thread.Sleep(new TimeSpan(0,0,10));
    }
}

To test this we can run the following code.

Copy
public void Main(string args[])
{
    var orderService = new OrderService();

    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (sender, args) => orderService.Process(1);
    backgroundWorker.RunWorkerAsync();

    orderService.Process(2);
}

The code above will attempt to execute the Process method on two different threads; the main thread and a background worker thread. Because these two threads are trying to access the same instance of the OrderService the first thread to access it will block the second. As a result, when you run the program you will first see the follwing.

Because the OrderService.Process method has a Thread.Sleep call, the first thread accessing that method will block the second for 10 seconds. After those 10 seconds have passed the second thread will no longer be blocked and it will be able to continue its execution.

Working with object trees

Because the Synchronized model is an implementation of the Aggregatable pattern, all of the same behaviors of the AggregatableAttribute are available. For more information regarding object trees, read Parent/Child Relationships.

Note Note

Once you have established your parent-child relationships you will need to apply compatible threading models to the child classes. You will want to refer to the Compatibility of Threading Models article to determine which threading model will work for the children of the Synchronized object.

See Also

Reference

SynchronizedAttribute
ChildAttribute
PrivateThreadAwareAttribute

Other Resources

Compatibility of Threading Models


Thread-Unsafe Threading Model

Thread-Unsafe Threading Model

When you are dealing with multi-threaded code you will run into situations where some objects are not safe for concurrent use by several threads. Although these objects should theoretically not be accessed concurrently, it is very hard to proof that it never happens. And when it does happen, thread-unsafe data structures get corrupted, and symptoms may appear much later. These issues are typically very difficult to debug. So instead of relying on hope, it would be nice if the object threw an exception whenever it is accessed simultaneously by several threads. This is why we have the thread-unsafe threading model.

This topic contains the following sections.

  • Marking an object as thread-unsafe
Marking an object as thread-unsafe

To mark an object as thread-unsafe:

  1. When you don't want multiple threads to access a single instance of a given class you will want to configure InstanceLevelAspect thread safety. To do this, select "Apply threading model" from the smart tag on the class.

  2. Choose the "Apply thread-unsafe threading model" option.

    Concurrent Access Instance 2

  3. You will be prompted with a summary of the changes that will be made based on the configuration you selected in the wizard.

    Concurrent Access Instance 4

  4. PostSharp will download the Threading Pattern Library and add it to your project if that hasn't been done yet.

    Concurrent Access Instance 5

  5. Once the process has completed successfully you'll be presented with the final page of the wizard.

    Concurrent Access Instance 6

  6. You'll notice that only one change was made to your codebase. The [ThreadUnsafeAttribute] attribute was added to the class you were targeting.

    C#
    Copy
    [ThreadUnsafe]
class AverageCalculator
{
    float sum;
    int count;

    public void AddSample(float n)
    {
        this.count++;
        this.sum += n;
    }

    public float GetAverage()
    {
        return this.sum / this.count;
    }
}

Now when your application executes no two threads will be able to access a single instance of the AverageCalculator class at the same time. If two threads attempt to do this, the second thread will receive a ConcurrentAccessException. Without the exception, there would be a slight chance that internal sum or count fields would have invalid values because the increment operations would not be atomic.

See Also

Reference

InstanceLevelAspect
ThreadUnsafeAttribute
ExplicitlySynchronizedAttribute
VerifyCallingThreadAttribute
ExplicitlySynchronizedAttribute

Other Resources

Opting In and Out From Thread Safety
Dispatching a Method to the UI Thread


Thread Affine Threading Model

Thread Affine Threading Model

One of the simplest ways to consider threading is to limit object instance access to the thread that created the instance. This is how the Thread Affine threading model works.

This topic contains the following sections.

  • Adding the Thread Affine model using the UI
  • Adding Thread Affine manually
  • Understanding runtime enforcement
  • Working with object trees
Adding the Thread Affine model using the UI

To apply the Thread Affine threading model to your class with the UI:

  1. Place the cursor over your class name and select "Apply threading model..." from the drop down

  2. Select "Apply thread-affine threading model" from the Select Model tab and select "Next".

  3. Confirm the actions on the Summary tab and select "Next".

  4. Click Finish after the installation completes.

    Your class will now have the ThreadAffineAttribute aspect and any previously missing PostSharp related references will have been added to the project.

Adding Thread Affine manually

To apply the Thread-Affine threading model manually:

  1. Add the PostSharp.Patterns.Threading NuGet package to your project.

  2. Add the ThreadAffineAttribute to the class.

In the example below the ThreadAffineAttribute has been added to the class.

C#
Copy
[ThreadAffine]
public class OrderService
{
    public void Process(int sequence)
    {
        Console.WriteLine("sequence {0}", sequence);
        Console.WriteLine("sleeping for 10s");

        Thread.Sleep(new TimeSpan(0,0,10));
    }
}
Understanding runtime enforcement

The ThreadAffineAttribute does not verify your code at build-time. Instead, it injects code that enforces the model at runtime. If it detects that the object is being accessed from a different thread than the one that created it, the aspect will throw a ThreadMismatchException exception.

To test this the thread-affine OrderService class, we can run the following code:

C#
Copy
public void Main(string args[])
{
    var orderService = new OrderService();

    orderService.Process(1);

    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (sender, args) =>
    {
        try
        {
            orderService.Process(2);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    };
    backgroundWorker.RunWorkerAsync();
}

The above code will execute the orderService.Process(1) method and output the following to the console.

That code successfully executed because the orderService instance was both created (via the new keyword) and executed on the same thread.

After the 10 second sleep period a BackgroundWorker thread is opened and it is set to execute the orderService.Process(2) method. If an exception is thrown that will be output to the console. When this piece of code executes you will see the following console output.

As you can see that a ThreadMismatchException exception was thrown. This happened because the orderService instance was created on the main thread and the BackgroundWorker thread attempted to execute it. Because the OrderService class has been marked with the ThreadAffineAttribute attribute only the thread that creates an instance of it can access that instance.

Working with object trees

Because the Thread-Affine model is an implementation of the Aggregatable pattern, all of the same behaviors of the AggregatableAttribute are available. For more information regarding object trees, read Parent/Child Relationships.

Note Note

Once you have established your parent-child relationships you will need to apply compatible threading models to the child classes. You will want to refer to the Compatibility of Threading Models article to determine which threading model will work for the children of the Thread-Affine object.

See Also

Reference

ThreadAffineAttribute
ThreadMismatchException
PrivateThreadAwareAttribute
ChildAttribute

Other Resources

Compatibility of Threading Models


Opting In and Out From Thread Safety

Opting In and Out From Thread Safety

By default, PostSharp enforces thread safety for all instance fields and all public and internal methods of any class to which you applied a threading model.

However, there are times when you want to opt-out from this mechanism for a specific field or method. A typical reason is that access to the field is synchronized manually using a different mechanism.

This section shows how to override the default thread safety implemented by PostSharp.

This topic contains the following sections.

  • Opting out from thread-safety verification for a method
  • Opting out from thread-safety for a field
  • Opting in for thread safety for callback methods
Opting out from thread-safety verification for a method

To disable enforcement of the class-level threading model for a specific method, add the ExplicitlySynchronizedAttribute attribute to that method.

In the following example, this custom attribute allows us to implement the ToString in a class that respects the Actor model. Without the custom attribute, this would not have been possible because non-void public methods must have the async keyword.

C#
Copy
[Actor]
class Player
{
   private readonly string name;

   [ExplicitlySynchronized]
   public override string ToString()
   {
      return this.name;
   }
}

When used on a method, the ExplicitlySynchronizedAttribute attribute has several effects:

  1. Lock-based aspects such as SynchronizedAttribute or ReaderWriterSynchronizedAttribute will not attempt to acquire a lock before executing this method.

  2. Accesses to fields are not verified during the whole execution of the method (for the current thread).

  3. All build-time verifications are disabled for this method.

Caution note Caution

By using the ExplicitlySynchronizedAttribute custom attribute, you are significantly increasing the risk that multithreading defects in user code go undetected by PostSharp. Code using ExplicitlySynchronizedAttribute should be more carefully covered by reviews and tests.

Opting out from thread-safety for a field

To disable enforcement of the class-level threading model for a specific field, add the ExplicitlySynchronizedAttribute attribute to the field:

C#
Copy
[Actor]
class MyActor
{

  [ExplicitlySynchronized]
  int counter;

  public void FooBar()
  {
    // This line would throw an exception without [ExplicitlySynchronized].
    Task.Factory.StartNew(() => Interlocked.Increment( ref this.counter ));
  }

}

When used on a field, the ExplicitlySynchronizedAttribute attribute has several effects:

  1. Accesses to the field are never verified

  2. All build-time verifications are disabled for this method.

Opting in for thread safety for callback methods

By default, thread safety is ensured when a thread first invokes a public or internal method of an object. The underlying motivation is that public and internal methods are the primary way how a thread can enter an object. Another way is to enter an object through a delegate call to a private method. By default, PostSharp does not ensure thread safety for private methods. If you register a callback method, you need to add the EntryPointAttribute custom attribute on this method.

In the following code snippet, the OnCreated method is invoked from a background thread by the FileSystemWatcher class. The InputQueueWatcher is thread-safe thanks to the SynchronizedAttribute aspect.

C#
Copy
[Synchronized]
class InputQueueWatcher
{
  FileSystemWatcher watcher;

  [Child]
  AdvisableCollection<string> files = new AdvisableCollection<string>();

  public InputQueueWatcher(string path)
  {
    this.watcher = new FileSystemWatcher();
    this.watcher.Path = path;
    this.watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
    this.watcher.Filter = "*.xml";
    this.watcher.Created += new FileSystemEventHandler(OnCreated);
  }

  [EntryPoint]
  private void OnCreated(object source, FileSystemEventArgs e)
  {
     // Without [EntryPoint], the following line would throw ThreadAccessException.
     this.files.Add(e.FullPath);
  }

   public ICollection Files { get { return this.files; } }

 }
See Also

Reference

ExplicitlySynchronizedAttribute
EntryPointAttribute

Other Resources

Thread-Unsafe Threading Model
Reader/Writer Synchronized Threading Model
Dispatching a Method to the UI Thread
Actor Threading Model


Compatibility of Threading Models

Compatibility of Threading Models

Required introduction

Compatibility Matrix
Parent | Actor | Freezable | Immutable | Private | Reader-Writer Synchronized | Synchronized | Thread Affine | Thread Unsafe
Actor | No | Yes | Yes | Yes | No | No | No | Yes
Freezable | No | Yes | Yes | Yes | No | No | No | No
Immutable | No | Yes | Yes | Yes | No | No | No | No
Reader-Writer Synchronized | Yes (Own) | Yes | Yes | Yes | Yes (Shared) | No | No | No
Synchronized | Yes (Own) | Yes | Yes | Yes | Yes (Shared) | Yes (Shared) | No | No
Thread Affine | Yes (Own) | Yes | Yes | Yes | No | No | Yes | Yes (Shared)
Thread Unsafe | Yes (Own) | Yes | Yes | Yes | No | No | Yes | Yes (Shared)
Private |  |  |  |  |  |  |  |


Enabling and Disabling Runtime Verification

Enabling and Disabling Runtime Verification

When you apply a threading model to a class, PostSharp adds two kinds of behaviors: behaviors that are necessary to implement the semantic of the threading model (for instance acquiring a lock or dispatching a method call) and behaviors that validate that the source code is valid against the chosen threading model (for instance that no field is written if the current method does not have write access). The second set of behaviors are called runtime verifications. By default, runtime verifications are enabled in the Debug build and disabled in the Release build.

This section explains how to enable or disable runtime verification.

This topic contains the following sections.

  • Understanding the default configuration
  • Enabling or disabling runtime verification for a whole project
  • Enabling and disabling runtime verification for a specific class
Understanding the default configuration

By default, runtime verification is disabled if the Optimize Code compiler flag is enabled. Therefore, runtime verification is enabled by default in the Debug build and disabled in the Release build.

Enabling or disabling runtime verification for a whole project

Perform the following steps to enable runtime verification by using the Project Settings dialog

Enabling Runtime Verification in Project Properties

  1. Open the project's Properties window.

  2. Select the build configuration that you want to enable runtime verification on.

    Note Note

    By default, projects have two different build configurations: Debug and Release. Each build configuration can, and by default does, have a different behavior for runtime verification.

  3. Open the PostSharp tab.

  4. In the Optional Features section there is a Runtime Verification dropdown. The dropdown has three options in it; Default, Disabled, and Enabled.

    The Default option will include either (Enabled) or (Disabled) after it. This value will change based on the Optimize Code compiler flag setting. If the compiler flag is disabled the dropdown option will read Default (Enabled) and if the Optimize Code flag is enabled the dropdown option will read Default (Disabled).

Enabling and disabling runtime verification for a specific class

You can override the project-level configuration of the runtime verification setting by setting the RuntimeVerificationEnabled property of the threading model custom attribute. This property is defined by the ThreadAwareAttribute class, from which all threading model attributes derive.

C#
Copy
[ThreadAffine(RuntimeVerificationEnabled = true)]

If the property is not manually set it derives its value from the setting on the project properties page. If you want to override the default value all you need to do is set the value of the RuntimeVerificationEnabled to true or false.

See Also

Reference

ThreadAwareAttribute
RuntimeVerificationEnabled


Dispatching a Method to Background

Dispatching a Method to Background

Long running processes will block the further execution of code while the system waits for them to complete. When you are building applications it's common to push long running processes to the background so that other processes can continue without waiting. Two common ways of doing this are with asyncronous processing and the BackgroundWorker. Both require a lot of boiler plate code to push execution to another thread.

PostSharp provides you with the ability to push execution of a method to a background thread without having to worry about all of the boiler plate code.

To add [Background] attribute:

  1. Find the method that you want to push to the background for execution.

    C#
    Copy
    public class CustomerRepository
{
    public void DoStuff()
    {
        Console.WriteLine("Things are getting done");
    }
}

  2. Select "Execute method in the background" from the Smart Tag available under the method name.

  3. You'll notice that only one change was made to your codebase. The [Background] attribute was added to the class you were targeting. Now when this method executes in your application it will occur in another thread and will allow for the calling code to continue executing.

    C#
    Copy
    public class CustomerRepository
{
    [Background]
    public void DoStuff()
    {
        Console.WriteLine("Things are getting done");
    }
}

Those simple steps are all that is required for you to declare that a method should be executed in a background thread.

See Also

Reference

BackgroundWorker

Other Resources

Restricting Interface Implementation


Dispatching a Method to the UI Thread

Dispatching a Method to the UI Thread

When you are building desktop or mobile user interfaces, parts of your code may execute on background threads. However, the user interface itself can be accessed only from the UI thread. Therefore, it is often necessary to dispatch execution of code from a background thread to the foreground thread.

Traditionally, thread dispatching has been implemented using the Invoke(Delegate) method in WinForms or the Dispatcher class in XAML. However, this results in a large amount of boilerplate, making the code unreadable.

The DispatchedAttribute aspect addresses the issue of thread dispatching by forcing a method to execute on the thread that created the object (typically the foreground thread).

This topic contains the following sections.

  • Forcing a method to execute on the foreground thread
  • Executing a method asynchronously
  • Executing async methods in the foreground thread
Forcing a method to execute on the foreground thread

Once you've added background processing to the button click, you will need a way to have the SaveCompleted method run on the UI thread. If you don't do this you will get an InvalidOperationException because setting the lblStatus.Text property is a cross threading operation.

Ui Threading Error

Here's how you can fix this:

  1. Your code has encapsulated the UI thread interaction in the SaveCompleted method. Open the smart tag on that method and choose to "execute the method in the object thread". This tells PostSharp to configure this method to execute in the thread that the class containing the method is executing in.

    Ui Object Thread Add

  2. After selecting the smart tag option you will be returned to your code and you'll notice that the only change was the addition of the [DispatchedAttribute] attribute to the SaveCompleted method.

    C#
    Copy
    [Dispatched]
private void SaveCompleted()
{
    lblStatus.Text = "Finished Saving";
}
    Note Note

    Note, that [Dispatched] attribute can be applied only to instance methods of UI controls (WinForms or WPF), or to any class implementing the IDispatcherObject interface manually.

Now if you run your code you will no longer receive the InvalidOperationException and instead will see the label on the UI update. All of the Save functionality will occur in a separate thread which prevents the user interface from locking up while that is happening.

Executing a method asynchronously

By default, the DispatchedAttribute forces the target method to execute synchronously on the foreground thread, which means that the background thread will wait until the method execution has completed. This waiting causes some performance overhead. Additionally, synchronous execution is not always useful. If the method has no return value and no side effect of interest for the calling thread, the method could be safely executed asynchronously, which means the calling thread would not need to wait for the method execution to complete on the foreground thread, so that the calling thread would continue its execution immediately after having enqueued the call to the foreground thread.

You can enable asynchronous execution of a dispatched method by passing the true value to the parameter of the DispatchedAttribute(Boolean) constructor, for instance:

C#
Copy
[Dispatched(true)]
private void SaveCompleted()
{
    lblStatus.Text = "Finished Saving";
}
Executing async methods in the foreground thread

When you use the DispatchedAttribute aspect on asynchronous methods (async keyword in C#), the method is guaranteed to execute on the foreground thread even when it is invoked from a background thread.

See Also

Reference

DispatchedAttribute
BackgroundAttribute
BackgroundWorker

Other Resources

Dispatching a Method to Background


Detecting Deadlocks at Runtime

Detecting Deadlocks at Runtime

A common problem that is found in multi-threaded code is that multiple threads enter a situation where they are waiting for each other to finish. This is a deadlock situation and neither thread will complete executing in this situation. Because the threads are waiting on each other, neither is capable of providing diagnostic information to aid in debugging the situation. The DeadlockDetectionPolicy helps provide this information.

This topic contains the following sections.

  • Adding deadlock detection using the UI
  • Manually adding deadlock detection to a project
  • Manually adding deadlock detection to the pssln file
  • Deadlock detection
Adding deadlock detection using the UI

To apply the deadlock detection to your application with the UI:

  1. Right click on your solution in Solution Explorer, select Add followed by Postsharp Policy...

  2. In the Add Postsharp policy wizard, expand Threading and select Deadlock detection.

  3. Select the projects that you would like to add Deadlock detection to.

    Note Note

    You will need to add this to every project in your application. Excluding projects could cause your application to fail.

  4. Review the configuration that you have selected and click Next.

  5. Close the wizard when the process had completed by clicking Finish.

The result of running this wizard is that a pssln file has been added to your project.

The pssln file contains an entry that enables deadlock detection across all projects in your solution.

Copy
<Project xmlns="http://schemas.postsharp.org/1.0/configuration" xmlns:t="clr-namespace:PostSharp.Patterns.Threading;assembly:PostSharp.Patterns.Threading">
  <Multicast>
    <t:DeadlockDetectionPolicy />
  </Multicast>
</Project>
Manually adding deadlock detection to a project

To manually add deadlock detection you will need to add an assembly level attribute to the project. This can be added anywhere in the project but it is most commonly added to the AssemblyInfo file.

C#
Copy
[assembly: DeadlockDetectionPolicy]
Note Note

You will need to add this to every project in your application. Excluding projects could cause your application to fail.

Manually adding deadlock detection to the pssln file

Adding deadlock detection at a solution level can also be done manually. This can be done by adding an entry to the pssln file in the solution.

To manually add deadlock detection to a solution:

  1. Open the solution's pssln file. This can be found under the Solution Items folder in Visual Studio's Solution Explorer.

    If the pssln file doesn't exist manually add the file at the solution level. Name the file with the same name as your solution and the pssln file extension.

  2. If you had to create the pssln file and add it to your solution add the following XML to it. If the pssln file already existed in your project procede to the next step.

    Copy
    <?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.postsharp.org/1.0/configuration" xmlns:t="clr-namespace:PostSharp.Patterns.Threading;assembly:PostSharp.Patterns.Threading">
</Project>

  3. Add a multicast attribute to the Project element that will add DeadlockDetectionPolicy to all the projects in the solution.

    Copy
    <?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.postsharp.org/1.0/configuration" xmlns:t="clr-namespace:PostSharp.Patterns.Threading;assembly:PostSharp.Patterns.Threading">
  <Multicast>
    <t:DeadlockDetectionPolicy />
  </Multicast>
</Project>

Once you save the pssln file you will have added deadlock detection to all projects in your solution.

Deadlock detection

When a deadlock is detected a DeadlockException is thrown. The exception will include a detailed report of all the threads and locks involved in the deadlock. Here is an example of that.

See Also

Reference

DeadlockDetectionPolicy
DeadlockException


Custom Patterns

Custom Patterns

Ready-made patterns implementation described in parts Standard Patterns and Threading Patterns are only the tip of the iceberg. There are a lot more design patterns that are not available off-the-shelf in PostSharp. There are even more patterns that are not general enough to be recognized as design patterns because they are specific to your application, However, even custom patterns deserve automation for exactly the same reason as standard patterns.

There are two ways you can automate custom patterns:

  • Automate their implementation using one or more aspects.

  • Automate the validation of their hand-written implementation to make code reviews lighter.

This is what this part is about. It is composed of the following chapters:

Chapter | Description
Developing Custom Aspects | This chapter describes how to build custom aspects with PostSharp to automate the implementation of patterns.
Testing and Debugging Aspects | This topic discusses how to test aspects, how to work with dependency injection and inversion-of-control containers, and how to attach the debugger to PostSharp at build time.
Validating Architecture | This chapter explains how to automate the validation of your code against pattern implementation guidelines and architecture rules.


Developing Custom Aspects

Developing Custom Aspects

This chapter describes how to build your own aspect. It includes the following topics:

Section | Description
Developing Simple Aspects | This topic describes how to create aspects that contain a single transformation (named simple aspects). It describes all kinds of simple aspects.
Understanding Aspect Lifetime and Scope | This topic explains the lifetime of aspects, which are instantiated at build time, serialized, then deserialized at runtime and executed.
Initializing Aspects | This topic discusses different techniques to initialize aspects.
Validating Aspect Usage | This topic shows how to validate that an aspect has been applied to a valid target declaration.
Developing Composite Aspects | This topic describes how to create aspects that are composed of several primitive transformations, using advices and pointcuts.
Coping with Several Aspects on the Same Target | This topic explains how to express aspect dependencies to prevent issues that would otherwise happen if several aspects are added to the same declaration.
Understanding Interception Aspects | This topic explains some details about the implementation of interception aspects.
Understanding Aspect Serialization | This topic explains aspect serialization and how to customize it.
Advanced | This topic discusses some advanced questions.
Examples | This topic provides a few examples of custom aspects.


Developing Simple Aspects

Developing Simple Aspects

In PostSharp, developing an aspect is as simple as deriving a primitive aspect class and overriding some special methods named advice. Aspects encapsulate a transformation of an element of code (such as a method or a property), and advices are the methods that are executed at runtime.

For instance, the effect of the aspect OnMethodBoundaryAspect is to wrap the target method into a try/catch/finally construct, and the advices of this aspect are OnEntry(MethodExecutionArgs), OnSuccess(MethodExecutionArgs), OnException(MethodExecutionArgs) and OnExit(MethodExecutionArgs)

By default, advices of primitive aspect types have an empty implementation, so the aspect has no effect until you override at least one advice.

To develop a simple aspect:

  1. Add PostSharp to your project. See Installing PostSharp Tools for Visual Studio for details.

  2. Create a new class and make it derive from one of the primitive aspect classes (see below).

  3. Annotate the class with the custom attribute SerializableAttribute, or PSerializableAttribute if your project targets anything else than the full .NET Framework. See Understanding Aspect Lifetime and Scope to understand why.

  4. Override one of the aspect advice methods.

Aspect Classes

The following table gives a list of available primitive aspect classes. Every aspect class is described in greater detailed in the class reference documentation.

Aspect Type | Targets | Description
OnMethodBoundaryAspect | Methods | Methods enhanced with an OnMethodBoundaryAspect are wrapped by a try/catch/finally construct. This aspect provides the advices OnEntry(MethodExecutionArgs), OnSuccess(MethodExecutionArgs), OnException(MethodExecutionArgs) and OnExit(MethodExecutionArgs); these advices are invoked directly from the transformed method, the return value, and the exception (if applicable). This aspect is useful to implement tracing or transaction handling, for instance. For details, see Injecting Behaviors Before and After Method Execution.
OnExceptionAspect | Methods | Methods enhanced with an OnExceptionAspect are wrapped by a try/catch construct. This aspect provides the advice OnException(MethodExecutionArgs); this advice is invoked from the catch block. This aspect is useful to implement exception handling policies. Contrarily to OnMethodBoundaryAspect, this aspect lets you define the type of caught exceptions by overriding the method GetExceptionType(MethodBase) For details, see Handling Exceptions.
MethodInterceptionAspect | Methods | When a method is enhanced by a MethodInterceptionAspect, all calls to this method are replaced by calls to OnInvoke(MethodInterceptionArgs), the only advice of this aspect type. This aspect is useful when the execution of target method can be deferred (asynchronous calls), must be dispatched on a different thread. For details, see Intercepting Methods.
LocationInterceptionAspect | Fields, Properties | When a field or a property is enhanced by a LocationInterceptionAspect, all calls to its accessors are replaced by calls to advices OnGetValue(LocationInterceptionArgs) and OnSetValue(LocationInterceptionArgs). Fields are transparently replaced by properties. This aspect is useful to implement functionalities that need to get or set the location value, such as the observability design pattern (INotifyPropertyChanged). For details, see Intercepting Properties and Fields.
EventInterceptionAspect | Events | When an event is enhanced by an EventInterceptionAspect, all calls to its add and remove semantics are replaced by calls to advices OnAddHandler(EventInterceptionArgs) and OnRemoveHandler(EventInterceptionArgs). Additionally, when the event is fired, even of invoking directly the handlers that were added to the event, the advice OnInvokeHandler(EventInterceptionArgs) is called instead. This aspect is useful to add functionalities to events, such as implementing asynchronous events or materialized list of subscribers. For details, see Intercepting Events.
CompositionAspect | Types | This aspect introduces an interface into a type by composition. The interface is introduced statically; the aspect method GetPublicInterfaces(Type) should return the type of introduced interfaces. However, the object implementing the interface is created dynamically at runtime by the implementation of the method CreateImplementationObject(AdviceArgs). For details, see Introducing Interfaces.
CustomAttributeIntroductionAspect | Any | This aspect introduces a custom attribute on any element of code. A custom attribute can be represented as a CustomAttributeData or a ObjectConstruction. For details, see Introducing Custom Attributes.
ManagedResourceIntroductionAspect | Assemblies | This aspect introduces a managed resource into the current assembly. For details, see Introducing Managed Resources.
ILocationValidationAspect | Fields, Properties, Parameters | This aspect causes any new value assigned to its target to be validated. If the aspect determines the value is invalid, an exception is thrown. The aspects of the PostSharp.Patterns.Contracts namespace are built on the top of this interface aspect. For details, see Contracts.
Tip Tip

The implementation of aspects OnMethodBoundaryAspect and OnExceptionAspect is very efficient; they should be preferred over other aspects whenever it makes sense.

Using Aspect Interfaces

The primitive aspect classes listed above only exist for convenience. In reality, PostSharp only understands interfaces. Every of these aspect classes implements a pair of interfaces. For instance, the class OnMethodBoundaryAspect implements the interfaces IOnMethodBoundaryAspect and IMethodLevelAspectBuildSemantics.

The aspect classes are more convenient because they derive from MulticastAttribute, which extends SystemAttribute with multicasting capability. See Adding Aspects to Multiple Declarations for details.

If you do not need or want the capabilities of MulticastAttribute (for instance because the aspect is not used as a custom attribute, see IAspectProvider), you can implement the aspect interface manually. An aspect class must implement an interface derived from IAspect, and may implement an interface derived from IAspectBuildSemantics. Please refer to the documentation of the aspect class to get information about the corresponding aspect interface.

Additionally to the aspect interface corresponding to an aspect class, you can define the following interfaces on aspect classes:

Aspect Interface | Description
IAspectProvider | This interface defines a single method ProvideAspects(Object), returning a collection of AspectInstance. The method allows an aspect to dynamically provide other aspects to the weaver.
IInstanceScopedAspect | By default, aspects have static scope: there is one instance of the aspect per target class. Implementing the IInstanceScopedAspect makes the aspect instance-scoped: there will be one instance of this aspect per instance of the target class.


Injecting Behaviors Before and After Method Execution

Injecting Behaviors Before and After Method Execution

There are two ways to inject behaviors into methods. The first is the method decorator: it allows you to add instructions before and after method execution. The second is method interception: the hook gets invoked instead of the method. Decorators are faster than interceptors, but interceptors are more powerful. The current article covers decorators. For the other aspect, see Intercepting Methods.

You may want to use method decorators to perform logging, monitor performance, initialize database transactions or any one of many other infrastructure related tasks. PostSharp provides you with an easy to use framework for all of these tasks in the form of the OnMethodBoundaryAspect.

Injection points

When you are decorating methods there are different locations that you may wish to inject functionality to. You may want to perform a task prior to the method executing or just before it finishes execution. There are situations where you may want to inject functionality only when the method has successfully executed or when it has thrown an exception. All of these injection points are structured and available to you in the OnMethodBoundaryAspect.

To create a simple aspect that writes some text whenever a method enters, succeeds, or fails:

  1. Create an aspect class and inherit OnMethodBoundaryAspect. Annotate the class with the [SerializableAttribute] custom attribute.

    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. To add functionality prior to the execution of the target method, override the method and code the functionality you desire.

    C#
    Copy
    [Serializable]
public class LoggingAspect : OnMethodBoundaryAspect
{
  public override void OnEntry(MethodExecutionArgs args)
  {
     Console.WriteLine("The {0} method has been entered.", args.Method.Name);
  }
}

  3. Inject functionality immediately after the method executes by overriding the OnExit(MethodExecutionArgs) method.

    Note Note

    It's important to remember that the OnExit(MethodExecutionArgs) method will execute every time that the target method completes its execution regardless of if the target method completed successfully or threw an exception.

    C#
    Copy
     public override void OnExit(MethodExecutionArgs args)
{
  Console.WriteLine("The {0} method has exited", args.Method.Name);
}

  4. To add functionality that only executes when the target method has completed successfully, you will override the OnSuccess(MethodExecutionArgs) method in your aspect. The OnSuccess(MethodExecutionArgs) method will be executed every time that the target method completes successfully. If the target method throws an exception OnSuccess(MethodExecutionArgs) will not execute.

    C#
    Copy
     public override void OnSuccess(MethodExecutionArgs args)
{
  Console.WriteLine("The {0} method executed successfully.", args.Method.Name);
}

  5. The final location that you can intercept requires you to override the OnException(MethodExecutionArgs) method. As the name of the overrode method suggests, this is where you can inject functionality that should execute when the target method throws and exception.

    C#
    Copy
     public override void OnException(MethodExecutionArgs args)
{
  Console.WriteLine("An exception was thrown in {0}.", args.Method.Name);
}

The four methods (OnEntry(MethodExecutionArgs), OnExit(MethodExecutionArgs), OnSuccess(MethodExecutionArgs) and OnException(MethodExecutionArgs)) that you overrode are the locations that you are able to intercept method execution. Between these four location you are able to implement many different infrastructure patterns with minimal effort.

Accessing the method

As illustrated in the examples above, you can access information about the method being intercepted from the property Method, which gives you a reflection object MethodBase. This object gives you access to parameters, return type, declaring type, and other characteristics. In case of generic methods or generic types, Method gives you the proper generic method instance, so you can use this object to get generic parameters.

Accessing parameters

It's rare that you will intercept method execution and not interact with the parameters that were passed to the target method. For example, when you implement method interception for logging you will probably want to log the parameter values that were passed to the target method.

Each of the interception locations that were outlined earlier has access to that information. If you look at the OnEntry(MethodExecutionArgs) method in your aspect you will see that it has a MethodExecutionArgs parameter. That parameter is used for OnExit(MethodExecutionArgs), OnSuccess(MethodExecutionArgs) and OnException(MethodExecutionArgs) as well. The collection Arguments gives access to parameter values.

Let's modify the OnEntry(MethodExecutionArgs) method and include the parameter values in the log message.

To include argument values to the logged text:

  1. Create a foreach loop to gather each of the parameter values in the Arguments property of the args parameter.

  2. In the loop concatenate the parameter values into a string.

  3. Pass that string of argument values to the logging tool.

    C#
    Copy
     public override void OnEntry(MethodExecutionArgs args)
{
  var argValues = new StringBuilder();
  foreach (var argument in args.Arguments)
  {
            argValues.Append(argument.ToString()).Append(",");
  }

  Console.WriteLine("The {0} method was entered with the parameter values: {1}",
                    args.Method.Name, argValues.ToString());
}
    Note Note

    A production implementation of this aspect would need to take re-entrance into account. See the article Logging for a ready-made logging aspect.

It's also possible to modify the parameter values inside your aspect methods. All you need to do is modify the value of the item in the Arguments collection. Remember that all items in the Arguments collection are object types so you will need to be careful with how you change values. If the value you are modifying was originally a string, you will want to ensure it stays a string type. It's especially true that when you change the parameter type in the OnEntry(MethodExecutionArgs) method you may cause the system to be unable to execute the target method due to a parameter type mismatch.

Note Note

The only parameter types that you can modify are those defined as either out or ref. If you need to modify input arguments, you should use Intercepting Methods.

Accessing the target objects

In combination with the parameters you will probably interact with the target code instance that the aspect is attached to. The Instance property provides you with the instance of the object that the aspect is currently operating against. It is an object type so you will need to cast it to the correct type to be able to interact with it. If you debug your aspect and that aspect doesn't make use of Instance, it will be set to null. It's also set to null if the target code is defined as static.

Accessing the return value

Like target method parameters you also have access to the return value for those target methods. It's possible to both read the return value as well as modify it. The return value can be found at ReturnValue in all four of the aspect methods covered earlier.

C#
Copy
 public override void OnExit(MethodExecutionArgs args)
{
    args.ReturnValue = false;
}
Note Note

If a target method is defined as void, the ReturnValue property will be set to null. ReturnValue is an object type so you must be careful how you modify the return value with respect to the return value type of the target code.

Changing execution flow

Returning without executing the method

When your aspect is interacting with the target code, there are situations where you will need to alter the execution flow behavior. For example, you may want to exit the execution of the target code at some point in the OnEntry(MethodExecutionArgs) advice. PostSharp offers this ability through the use of FlowBehavior.

C#
Copy
 public override void OnEntry(MethodExecutionArgs args)
{
    if (args.Arguments.Count > 0 &amp;&amp; args.Arguments[0] == null)
    {
        args.FlowBehavior = FlowBehavior.Return;
    }

  Console.WriteLine("The {0} method was entered with the parameter values: {1}",
                    args.Method.Name, argValues.ToString());
}

As you can see, all that is needed to exit the execution of the target code is setting the FlowBehavior property on the MethodExecutionArgs to Return.

Note Note

Using flow control to exit the target code execution will return back to the code that called the target code. As a result, you need to be considerate to the target code's return value. In the example above, the target code will always return null. This may or may not be the behavior that you want. If it isn't, you can set the ReturnValue on the MethodExecutionArgs and that value will be returned from the target code.

Managing execution flow control when dealing with exceptions there are two primary situations that you need to consider: re-throwing the exception and throwing a new exception.

Rethrowing an existing exception

To rethrow an existing exception, you will set the FlowBehavior property to RethrowException. Whatever exception that was caught in the OnException(MethodExecutionArgs) advice will be rethrown to the code that is calling the target code.

C#
Copy
 public override void OnException(MethodExecutionArgs args)
{
    if (args.Exception.GetType() == typeof(DivideByZeroException))
    {
        args.FlowBehavior = FlowBehavior.RethrowException;
    }
}

Throwing a new exception

To throw a new exception you will have to perform two tasks. First you will need to assign the new exception to the Exception property. This is the exception that will be thrown as part of the flow behavior. After that you will need to set the FlowBehavior property to ThrowException.

C#
Copy
 public override void OnException(MethodExecutionArgs args)
{
    if (args.Exception.GetType() == typeof(IndexOutOfRangeException))
    {
        args.Exception = new CustomArrayIndexException("This was thrown from an aspect",
                                                        args.Exception);
        args.FlowBehavior = FlowBehavior.ThrowException;
    }
}
Note Note

The remaining FlowBehavior enumeration value is Continue. In OnException(MethodExecutionArgs), this behavior will not rethrow the caught exception. In OnEntry(MethodExecutionArgs), OnSuccess(MethodExecutionArgs) and OnExit(MethodExecutionArgs) the target code execution will continue with no interruption.

Note Note

The default FlowBehavior value for OnEntry(MethodExecutionArgs), OnSuccess(MethodExecutionArgs) and OnExit(MethodExecutionArgs) is Continue. For OnException(MethodExecutionArgs) the default value is RethrowException.

Sharing state between advices

When you are working with multiple advices on a single aspect, you will encounter the need to share state between these advices. For example, if you have created an aspect that times the execution of a method, you will need to track the starting time at OnEntry(MethodExecutionArgs) and share that with OnExit(MethodExecutionArgs) to calculate the duration of the call.

To do this we use the MethodExecutionTag property on the MethodExecutionArgs parameter in each of the advices. Because MethodExecutionTag is an object type, you will need to cast the value stored in it while retrieving it and before using it.

C#
Copy
[Serializable]
public class ExecutionDurationAspect : OnMethodBoundaryAspect
{
    public override void OnEntry(MethodExecutionArgs args)
    {
        args.MethodExecutionTag = Stopwatch.StartNew();
    }

    public override void OnExit(MethodExecutionArgs args)
    {
        var sw = (Stopwatch)args.MethodExecutionTag;
        sw.Stop();

        System.Diagnostics.Debug.WriteLine("{0} executed in {1} seconds", args.Method.Name,
                                           sw.ElapsedMilliseconds / 1000);
    }
}
Note Note

The value stored in MethodExecutionTag will not be shared between different instances of the aspect. If the aspect is attached to two different pieces of target code, each attachment will have its own unshared MethodExecutionTag for state storage.

See Also

Reference

OnMethodBoundaryAspect
Arguments
MethodExecutionTag
SerializableAttribute
PSerializableAttribute
OnExit(MethodExecutionArgs)
OnSuccess(MethodExecutionArgs)
OnException(MethodExecutionArgs)
OnEntry(MethodExecutionArgs)
Method
Arguments

Other Resources

PostSharp Aspect Framework - Product Page


Handling Exceptions

Handling Exceptions

Adding exception handlers to code requires the addition of try/catch statements which can quickly pollute code. Exception handling implemented this way is also not reusable, requiring the same logic to be implemented over and over where ever exceptions must be dealt with. Raw exceptions also present cryptic information and can often expose too much information to the user.

PostSharp provides a solution to these problems by allowing custom exception handling logic to be encapsulated into a reusable class, which is then easily applied as an attribute to all methods and properties where exceptions are to be dealt with.

This topic contains the following sections.

  • Intercepting an exception
  • Specifying the type of handled exceptions
  • Ignoring exceptions
  • Replacing exceptions
  • Displaying the method arguments on exception
Intercepting an exception

PostSharp provides the OnExceptionAspect class which is the base class from which exception handlers are to be derived from.

The key element of this class is the OnException(MethodExecutionArgs) method: this is the method where the exception handling logic (i.e. what would normally be in a catch statement) goes. A MethodExecutionArgs parameter is passed into this method by PostSharp; it contains information about the exception.

To create an OnExceptionAspect class:

  1. Derive a class from OnExceptionAspect.

  2. Apply the SerializableAttribute to the class.

  3. Override OnException(MethodExecutionArgs) and implement your exception handling logic in this class.

The following snippet shows an example of an exception handler which watches for exceptions of any type, and then writes a message to the console when an exception occurs:

C#
Copy
[Serializable]
public class PrintExceptionAttribute : OnExceptionAspect
{

    public override void OnException(MethodExecutionArgs args)
    {
        Console.WriteLine(args.Exception.Message);
    }
}

Once created, apply the derived class to all methods and/or properties for which the exception handling logic is to be used, as shown in the following example:

C#
Copy
 class Customer
{
    public string FirstName { get; set; }
    public string LastName { get; set; }

    [PrintException]
    public void StoreName(string path)
    {
        File.WriteAllText( path, string.Format( “{0} {1}”, this.FirstName, this.LastName ) );
    }

}

Here PrintException will output a message when an exception occurs in trying to write text to a file.

Alternatively the attribute can be applied to the class itself as shown below, in which case the exception handler will handle exceptions for all methods and properties in the class:

C#
Copy
[PrintExceptionAttribute(typeof(IOException))]
    class Customer
    {
      .
      .
      .
    }

See the section Adding Aspects to Multiple Declarations for details about attribute multicasting.

Specifying the type of handled exceptions

The GetExceptionType(MethodBase) method can be used to return the type of the exception which is to be handled by this aspect. Otherwise, all exceptions will be caught and handled by this class.

Note Note

The GetExceptionType(MethodBase) method is evaluated at build time.

In the following snippet, we updated the PrintExceptionAttribute aspect and added the possibility to specify from the custom attribute constructor which type of exception should be traced.

C#
Copy
[Serializable]
    public class PrintExceptionAttribute : OnExceptionAspect
    {
        Type type;

    public PrintExceptionAttribute() : this(typeof(Exception))
    {
    }

        public PrintExceptionAttribute (Type type)
            : base()
        {
            this.type = type;
        }

        // Method invoked at build time.
        // Should return the type of exceptions to be handled.
        public override Type GetExceptionType(MethodBase method)
        {
            return this.type;
        }

        public override void OnException(MethodExecutionArgs args)
        {
            Console.WriteLine(args.Exception.Message);
        }
    }

Example:

C#
Copy
 class Customer
{
    public string FirstName { get; set; }
    public string LastName { get; set; }

    [PrintException(typeof(IOException)]
    public void StoreName(string path)
    {
        File.WriteAllText( path, string.Format( “{0} {1}”, this.FirstName, this.LastName ) );
    }

}
Note Note

If the aspect needs to handle several types of exception, the GetExceptionType should return a common base type, and the OnException implementation should be modified to dynamically handle different types of exception.

Ignoring exceptions

The FlowBehavior member of MethodExecutionArgs in the exception handler’s OnException(MethodExecutionArgs) method, can be set to ignore an exception. Note however that ignoring exceptions is generally dangerous and not recommended. In practice, it’s only safe to ignore exceptions in event handlers (e.g. to display a message in a WPF form) and in thread entry points.

Exceptions can be ignored by setting the FlowBehavior to Return:

C#
Copy
[Serializable]
public class PrintAndIgnoreExceptionAttribute : OnExceptionAspect
{

    public override void OnException(MethodExecutionArgs args)
    {
        Console.WriteLine(args.Exception.Message);
        args.FlowBehavior = FlowBehavior.Return;
    }
 }

If a method returns a value then the ReturnValue member of args can be set to an object to return. For example, consider the following GetDataLength method in Customer which returns the number of characters read from a file:

C#
Copy
 class Customer
{
    [PrintException(typeof(IOException))]
    public int GetDataLength(string path)
    {
return File.ReadAllText(path).Length;
    }

}

We can then modify the OnException(MethodExecutionArgs) method of PrintAndIgnoreExceptionAttribute to return an integer with a value of -1:

C#
Copy
 public override void OnException(MethodExecutionArgs args)
{
    Console.WriteLine(args.Exception.Message);
    args.FlowBehavior = FlowBehavior.Return;
    args.ReturnValue = -1;
}
Replacing exceptions

Many times an exception must be exposed to the user, either by allowing the original exception to be rethrown, or by throwing a new exception. This can be done by setting FlowBehavior as follows:

  • FlowBehavior.RethrowException: rethrows the original exception after the exception handler exits. This is the default behavior for the OnException(MethodExecutionArgs) advise.

  • FlowBehavior.ThrowException: throws a new exception once the exception handler exits. This is useful when details of the original exception should be hidden from the user or when a more meaningful exception is to be shown instead. When throwing a new exception, a new exception object must be assigned to the Exception member of MethodExecutionArgs. The following snippet shows the creation of a new BusinessExceptionAttribute which throws a BusinessException containing a description of the cause:

    C#
    Copy
    [Serializable]
public sealed class BusinesssExceptionAttribute : OnExceptionAspect
{
    public override void OnException(MethodExecutionArgs args)
    {
        .
        .
        .
        args.FlowBehavior = FlowBehavior.ThrowException;
        args.Exception = new BusinessException("Bad Arguments", new Exception("One or more arguments were null. Use the id " + guid.ToString() + " for more information"));
   }
}

class BusinessException : Exception
{
       public BusinessException(string message, Exception innerException) : base(message, innerException)
       {
       }
}
Displaying the method arguments on exception

When an exception is thrown, it can be useful to view and display the parameter values that were passed into the method where the exception occurred. These values can be retrieved by iterating through the Arguments property of the args parameter of the OnException(MethodExecutionArgs)method. In the following snippet, OnException(MethodExecutionArgs) has been modified to iterate through all exception values, and to concatenate them into a string. If a null value is encountered, then the code embeds the word null into the string. This string is then displayed as the message of the NullReferenceException which is rethrown:

C#
Copy
  public override void OnException(MethodExecutionArgs args)
  {
      string parameterValues = "";

      foreach (object arg in args.Arguments)
      {
          if (parameterValues.Length > 0)
          {
              parameterValues += ", ";
          }

          if (arg != null)
          {
              parameterValues += arg.ToString();
          }
          else
          {
              parameterValues += "null";
          }
      }

          Console.WriteLine( “Exception {0} in {1}.{2} invoked with arguments {3}”, args.Exception.GetType().Name, args.Method.DeclaringType.FullName, args.Method.Name, parameterValues );
   }
}
Note Note

The Arguments field of args cannot be directly viewed in the debugger. The Arguments field must be referenced by another object in order to be viewable in the debugger.

See Also

Reference

OnException(MethodExecutionArgs)
MethodExecutionArgs
OnExceptionAspect
SerializableAttribute
GetExceptionType(MethodBase)

Other Resources

Adding Aspects to Multiple Declarations


Injecting Behaviors into Async Methods

Injecting Behaviors into Async Methods

Async methods are methods with the async keyword in C#. Unlike normal methods, execution of async methods can be paused and resumed. Execution is paused when the method depends on a task that is being executed asynchronously, and is resumed when the dependent task has completed. An async method provides a convenient way to do potentially long-running work without blocking the caller's thread.

Async methods return a value of the Task type. At build time, the compiler performs a complex transformation of the code. The original async logic is moved to a different type called here the state machine type, and the original method body is replaced by just a few lines of code instantiated this state machine.

By default, all aspects applied on an async method are actually applied to the method instantiating the state machine. However, there are times when you want to actually add an aspect to the state machine. We will see how this is possible using the OnMethodBoundaryAspect aspect. For a more general information about using OnMethodBoundaryAspect in non-async methods, see Injecting Behaviors Before and After Method Execution.

There are two options when applying OnMethodBoundaryAspect to an async method. The first option is to apply the aspect to the method that instantiates and returns the task instance. The second option is to apply the aspect to the actual code that implements the logic inside the task. When using the second option you can also inject behaviors before and after your await statements.

This topic contains the following sections.

  • Applying the aspect to the method instantiating the async task
  • Applying the aspect to the async task itself
  • Adding behaviors around the "await" statement
Applying the aspect to the method instantiating the async task

You can control how the aspect is applied to the async method by setting the boolean ApplyToStateMachine property. Set this property to false to apply the aspect only to the code instantiating the async task. You can set the property in the constructor if you don't want to set it explicitly every time the aspect is used.

In the following procedure, we demonstrate how to inject behaviors into the method instantiating the async task. For this purpose, we create a simplified caching aspect that caches the result of the async method. This aspect can be applied to any async method returning Task<object>. For example, to the TestCaching method shown below:

C#
Copy
public async Task<object> TestCaching()
{
    await Task.Wait(1000); // Some long-running operation.
    return await Task.FromResult( new {Name = "Test object"} );
}

To inject behaviors into the method instantiating the async task:

  1. Create an aspect class and inherit OnMethodBoundaryAspect. Annotate the class with the [SerializableAttribute] custom attribute.

    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. Set the ApplyToStateMachine property to false in your constructor.

    C#
    Copy
    [Serializable]
public class CacheTaskResultAttribute : OnMethodBoundaryAspect
{
    public CacheTaskResultAttribute()
    {
        ApplyToStateMachine = false;
    }
}
    Note Note

    The default value of the ApplyToStateMachine property is false unless the OnYield(MethodExecutionArgs) or OnResume(MethodExecutionArgs) advice is implemented. However, PostSharp will emit a warning whenever OnMethodBoundaryAspect is applied to an async method without setting the ApplyToStateMachine property.

  3. Implement some of the advice methods of the OnMethodBoundaryAspect class, according to your requirements. For more information about these advice methods, see Injecting Behaviors Before and After Method Execution.

    For our CacheAttribute aspect, we need to implement two advises: OnEntry(MethodExecutionArgs) and OnSuccess(MethodExecutionArgs).

    C#
    Copy
    [Serializable]
public class CacheTaskResultAttribute : OnMethodBoundaryAspect
{
    public CacheTaskResultAttribute()
    {
        ApplyToStateMachine = false;
    }

    public override void OnEntry( MethodExecutionArgs args )
    {
        object cachedValue = MemoryCache.Default[args.Method.Name];
        if ( cachedValue != null )
        {
            args.ReturnValue = Task.FromResult( cachedValue );
            args.FlowBehavior = FlowBehavior.Return;
        }
    }

    public override void OnSuccess( MethodExecutionArgs args )
    {
        var task = (Task<object>) args.ReturnValue;
        args.ReturnValue =
            task.ContinueWith(
                t =>
                {
                    MemoryCache.Default[args.Method.Name] = t.Result;
                    return t.Result;
                });
    }
}

  4. Apply your custom attribute to the target methods. Below you can see the [Cache] attribute applied to the TestCaching method.

    C#
    Copy
    [Cache]
public async Task<object> TestCaching()
{
  await Task.Wait(1000); // Some long-running operation.
  return await Task.FromResult( new {Name = "Test object"} );
}
    Note Note

    You can also set the ApplyToStateMachine property value when applying the attribute to a method, for instance using the syntax [MyAspect( ApplyToStateMachine = false )]. This can be useful if it makes sense to apply this aspect to both the state machine or the instantiation method.

Thanks to the aspect, whenever the TestCaching method is called, the CacheAttribute.OnEntry method executes first. It checks whether the result value is already stored in the cache. If the value already exists, then a new task is created from this value and immediately returned back to the caller. Otherwise, the execution continues normally and a new task instance is created to run our async method.

The CacheAttribute.OnSuccess method is called before the newly created async task is returned back to the caller. The aspect's method creates a new continuation task and returns it back to the caller instead of the original one. Once the original task completes, the continuation added by the aspect stores the resulting value in cache. Afterwards, the original caller proceeds with processing the task's result.

Applying the aspect to the async task itself

In many cases, we need to inject behaviors into the code of the async task itself. You can accomplish this by setting the OnMethodBoundaryAspectApplyToStateMachine property to true.

We'll see how to use this feature to create an aspect that measures the execution time of a method. In this section, we will create a simple profiling aspect and show how to apply it correctly to the async methods.

To test the profiling aspect, we will measure the execution time of the TestProfiling example method, shown below. The call to Thread.Sleep represents the work performed by the method. This is the time we want to measure. The call to Task.Delay represents the work performed outside the method, for example the asynchronous call to a web service or a database server.

C#
Copy
public async Task TestProfiling()
{
    await Task.Delay( 1000 );
    Thread.Sleep( 1000 );
}

To inject behaviors into the async task itself:

  1. Create an aspect class and inherit OnMethodBoundaryAspect. Annotate the class with the [SerializableAttribute] custom attribute.

    C#
    Copy
    [Serializable]
public class ProfilingAttribute : OnMethodBoundaryAspect
{
}
    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. Implement some of the advice methods of the OnMethodBoundaryAspect class, according to your requirements. For more information about these advice methods, see Injecting Behaviors Before and After Method Execution.

    For our profiling aspect, we need to implement two advices: OnEntry(MethodExecutionArgs) and OnExit(MethodExecutionArgs).

    C#
    Copy
    [Serializable]
public class ProfilingAttribute : OnMethodBoundaryAspect
{
    public override void OnEntry( MethodExecutionArgs args )
    {
        Stopwatch sw = Stopwatch.StartNew();
        args.MethodExecutionTag = sw;
    }

    public override void OnExit( MethodExecutionArgs args )
    {
        Stopwatch sw = (Stopwatch) args.MethodExecutionTag;
        sw.Stop();
        Console.WriteLine( "Method {0} executed for {1}ms.",
                           args.Method.Name, sw.ElapsedMilliseconds );
    }
}

  3. Apply your custom attribute to the target methods. Set the ApplyToStateMachine property to true when applying the attribute to async methods. Below you can see the [Profiling] attribute applied to the TestProfiling method.

    C#
    Copy
    [Profiling( ApplyToStateMachine = true )]
public async Task TestProfiling()
{
    await Task.Delay( 1000 );
    Thread.Sleep( 1000 );
}
    Note Note

    You can set the ApplyToStateMachine property in the constructor if you don’t want to set it explicitly every time the aspect is used.

Whenever the TestProfiling method is called, it creates a new async task instance. At some later point, the task starts executing and immediately the ProfilingAttribute.OnEntry method is invoked. The method starts the stopwatch and stores it for the future use. Then the execution of the async task continues.

The ProfilingAttribute.OnExit method is called just before the async task completes. This method stops measuring the time and outputs the result to the console.

This program produces the following output:

Copy
Method TestProfiling executed for 2044ms.

As you can see, the output shows that we're not only measuring the execution time of the user code in the TestProfiling method, but also the time spent waiting for the external tasks to complete. The next section of this article will show how the ProfilingAttribute class can be improved to measure only the time spent inside the TestProfiling method.

Adding behaviors around the "await" statement

When applying the aspect to the async task itself, you can also inject behaviors before and after the await statements in that task. To achieve that, you need to override the OnYield(MethodExecutionArgs) and OnResume(MethodExecutionArgs) methods of the OnMethodBoundaryAspect class.

The OnYield(MethodExecutionArgs) method is invoked after the async task get paused and yields the control flow to the calling thread, as the result of the await statement.

The OnResume(MethodExecutionArgs) method is invoked when the async task resumes execution at the point after the await statement.

Note Note

Implementing OnYield(MethodExecutionArgs) or OnResume(MethodExecutionArgs) method also automatically sets the default value of ApplyToStateMachine property to true and suppresses the warning generated by PostSharp when the ApplyToStateMachine property is not set.

In the next steps we will add the OnYield and OnResume overrides to our ProfilingAttribute class. This will allow us to pause the stopwatch when the async method execution is paused, and to resume the stopwatch when the async method execution is resumed.

To inject behaviors around the "await" statement:

  1. Create an aspect class and inherit OnMethodBoundaryAspect. Annotate the class with the [SerializableAttribute] custom attribute. For this example, we will reuse the ProfilingAttribute class from the previous section.

    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. Override the OnYield(MethodExecutionArgs) method to add functionality at the point where the async task is paused and yields the control flow to the calling thread.

    The following code snippet uses OnYield(MethodExecutionArgs) method to pause the stopwatch when the execution of the async method is paused.

    C#
    Copy
    public override void OnYield( MethodExecutionArgs args )
{
    Stopwatch sw = (Stopwatch) args.MethodExecutionTag;
    sw.Stop();
}

  3. Override the OnResume(MethodExecutionArgs) method to add functionality at the point where the async task resumes its execution after the await statement. This method is invoked when another async task has completed and the control flow has returned to the original task right after the await statement.

    The following code snippet uses OnYield(MethodExecutionArgs) method to resume the stopwatch when the execution of the async method is resumed.

    C#
    Copy
    public override void OnResume( MethodExecutionArgs args )
{
    Stopwatch sw = (Stopwatch) args.MethodExecutionTag;
    sw.Start();
}

  4. Apply your custom attribute to the target methods. Below you can see the [Profiling] attribute applied to the TestProfiling method.

    C#
    Copy
    [Profiling]
public async Task TestProfiling()
{
    await Task.Delay( 1000 );
    Thread.Sleep( 1000 );
}

During the code execution, the stopwatch will start upon entering the TestProfiling method. It will stop before the await statement and resume when the task awaiting is done. Finally, the time measuring is stopped again before exiting the TestProfiling method and the result is written to the console.

Copy
Method ProfilingTest executed for 1007ms.
See Also

Reference

OnMethodBoundaryAspect
OnYield(MethodExecutionArgs)
OnResume(MethodExecutionArgs)
OnEntry(MethodExecutionArgs)
OnExit(MethodExecutionArgs)
OnSuccess(MethodExecutionArgs)
MethodExecutionArgs
ApplyToStateMachine
MethodExecutionTag
SerializableAttribute
PSerializableAttribute

Other Resources

Injecting Behaviors Before and After Method Execution
PostSharp Aspect Framework - Product Page


Injecting Behaviors into Iterators

Injecting Behaviors into Iterators

Iterator methods are methods that can return several values. In C#, values are produced using the yield return statement. Iterators return a value of type IEnumerable or IEnumerator. At build time, the compiler performs a complex transformation of the code. The original iterator logic is moved to a different type implementing the IEnumerator interface, and the original method body is replaced by just a few lines of code instantiated this class.

By default, all aspects applied on an iterator method are actually applied to the method instantiating the iterator class. However, there are times when you want to actually add an aspect to the iterator itself. We will see how this is possible using the OnMethodBoundaryAspect aspect. For a more general information about using OnMethodBoundaryAspect in non-async methods, see Injecting Behaviors Before and After Method Execution.

You have two options when applying OnMethodBoundaryAspect to an iterator method. The first option is to apply the aspect to the method that only creates and returns the iterator instance. The second option is to apply the aspect to the actual code that implements the logic inside the iterator. When using the second option you can also inject behaviors before and after your yield return statements and access the current yield value.

This topic contains the following sections.

  • Applying the aspect to the method instantiating the iterator
  • Applying the aspect to the iterator itself
  • Adding behaviors around the "yield return" statement
Applying the aspect to the method instantiating the iterator

You can control how the aspect is applied to the iterator by setting the boolean ApplyToStateMachine property. Set this property to false on your aspect to apply the aspect only to the code instantiating the iterator. You can set the property in the constructor if you don’t want to set it explicitly every time the aspect is used.

In the following procedure, we demonstrate how to inject behaviors into the method instantiating the iterator. For this purpose, we create a simplified caching aspect that stores all the values returned by iterator as a single array in cache. This aspect can be applied to any iterator returning IEnumerable.

To inject behaviors into the method instantiating the iterator:

  1. Create an aspect class and inherit OnMethodBoundaryAspect. Annotate the class with the [SerializableAttribute] custom attribute.

    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. Set the ApplyToStateMachine property to false in your constructor.

    C#
    Copy
    [Serializable]
public class CacheAttribute : OnMethodBoundaryAspect
{
    public CacheResultAttribute()
    {
        ApplyToStateMachine = false;
    }
}
    Note Note

    The default value of the ApplyToStateMachine property is false unless the OnYield(MethodExecutionArgs) or OnResume(MethodExecutionArgs) advice is implemented. However, PostSharp will emit a warning whenever OnMethodBoundaryAspect is applied to an iterator without setting the ApplyToStateMachine property.

  3. Override some of the virtual methods of the OnMethodBoundaryAspect class, according to your requirements. For more information about the corresponding virtual methods, see Injecting Behaviors Before and After Method Execution.

    The following snippet shows the overrides of OnEntry(MethodExecutionArgs) and OnSuccess(MethodExecutionArgs) methods for the CacheAttribute class.

    C#
    Copy
    [Serializable]
public class CacheAttribute : OnMethodBoundaryAspect
{
    public CacheAttribute()
    {
        ApplyToStateMachine = false;
    }

    public override void OnEntry( MethodExecutionArgs args )
    {
        object cachedValue = MemoryCache.Default[args.Method.Name];
        if ( cachedValue != null )
        {
            args.ReturnValue = cachedValue;
            args.FlowBehavior = FlowBehavior.Return;
        }
    }

    public override void OnSuccess( MethodExecutionArgs args )
    {
        object[] elements = ( (IEnumerable) args.ReturnValue ).OfType<object>().ToArray();
        MemoryCache.Default[args.Method.Name] = elements;
        args.ReturnValue = elements;
    }
}

  4. Apply your custom attribute to the target methods. Below you can see the [Cache] attribute applied to the TestCaching method.

    C#
    Copy
    [Cache]
public IEnumerable TestCaching()
{
    yield return 1;
    yield return 2;
    yield return 3;
}
    Note Note

    You can also set the ApplyToStateMachine property value when applying the attribute to a method, for instance using the syntax [MyAspect( ApplyToStateMachine = false )]. This can be useful if it makes sense to apply this aspect to both the state machine or the instantiation method.

Thanks to the aspect, whenever the TestCaching method is called, the CacheAttribute.OnEntry method executes first. It checks whether the result value is already stored in the cache. If the value already exists, then it is immediately returned back to the caller. Otherwise, the execution continues normally and a new iterator instance is created.

The CacheAttribute.OnSuccess method is called before the newly created iterator instance is returned back to the caller. The aspect's method enumerates all the iterator values using ToArray method and stores the resulting array in cache. The array is also returned to the caller instead of the original iterator instance.

Applying the aspect to the iterator itself

In many cases it can be useful to inject behavior into the user code of the iterator implementation itself. You can accomplish this by setting the ApplyToStateMachine property to true on your OnMethodBoundaryAspect.

For example, you may want to write a log entry each time the enumeration of the iterator begins and ends instead of logging only the creation of the iterator instance. In this section, we will create a simple logging aspect and show how to apply it correctly to iterators.

To inject behaviors into the iterator itself:

  1. Create an aspect class and inherit OnMethodBoundaryAspect. Annotate the class with the [SerializableAttribute] custom attribute.

    C#
    Copy
    [Serializable]
public class LogIteratorAttribute : OnMethodBoundaryAspect
{
}
    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. Override some of the virtual methods of the OnMethodBoundaryAspect class, according to your requirements. For more information about the corresponding virtual methods, see Injecting Behaviors Before and After Method Execution.

    The following snippet shows the overrides of OnEntry(MethodExecutionArgs) and OnSuccess(MethodExecutionArgs) methods for the LogIteratorAttribute class.

    C#
    Copy
    [Serializable]
public class LogIteratorAttribute : OnMethodBoundaryAspect
{
    public override void OnEntry(MethodExecutionArgs args)
    {
        Console.WriteLine("The enumeration of {0} started.", args.Method.Name);
    }

    public override void OnSuccess(MethodExecutionArgs args)
    {
        Console.WriteLine("The enumeration of {0} finished.", args.Method.Name);
    }
}

  3. Apply your custom attribute to the target iterator methods and set the ApplyToStateMachine property to true. Below you can see the [LogIterator] attribute applied to the TestLogging method.

    C#
    Copy
    [LogIterator( ApplyToStateMachine = true )]
public IEnumerable<int> TestLogging()
{
    yield return 1;
    yield return 2;
    yield return 3;
}
    Note Note

    You can set the ApplyToStateMachine property in the constructor if you don’t want to set it explicitly every time the aspect is used.

Whenever the TestLogging method is called, it creates a new iterator instance. Then the caller starts the enumeration of the iterator and immediately the LogIteratorAttribute.OnEntry method is invoked. The method writes the first log entry and the enumeration continues.

The LogIteratorAttribute.OnSuccess method is called after the enumeration of the iterator has completed. The method writes the second log entry and the control is given back to the caller.

The snippet below shows the enumeration of our sample iterator and the output written to the console.

C#
Copy
foreach (int n in TestLogging()) Console.WriteLine(n);
Copy
The enumeration of TestLogging started.
1
2
3
The enumeration of TestLogging finished.
Adding behaviors around the "yield return" statement

When applying the aspect to the iterator itself, you can also inject behaviors before and after the yield return statements in that iterator. To achieve that, you need to override the OnYield(MethodExecutionArgs) and OnResume(MethodExecutionArgs) methods of the OnMethodBoundaryAspect class.

The OnYield(MethodExecutionArgs) method is invoked after the iterator yields the control flow, as the result of the yield return statement. In this method you can also access and modify the current yield value by using the YieldValue property.

The OnResume(MethodExecutionArgs) method is invoked when the iterator resumes execution at the point after the yield return statement.

Note Note

Note, that implementing OnYield(MethodExecutionArgs) or OnResume(MethodExecutionArgs) method also automatically sets the default value of ApplyToStateMachine property to true and quiets the warning generated by PostSharp.

In the next steps we will create a sample aspect that counts the number of the not-null elements returned by the iterator and writes the result to the console.

To inject behaviors around the "yield return" statement:

  1. Create an aspect class and inherit OnMethodBoundaryAspect. Annotate the class with the [SerializableAttribute] custom attribute.

    C#
    Copy
    [Serializable]
public class NotNullCounterAttribute : OnMethodBoundaryAspect
{
}
    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. Override some of the virtual methods of the OnMethodBoundaryAspect class, according to your requirements. For more information about the corresponding virtual methods, see Injecting Behaviors Before and After Method Execution.

    The following snippet shows the overrides of OnEntry(MethodExecutionArgs) and OnExit(MethodExecutionArgs) methods for the NotNullCounterAttribute class.

    C#
    Copy
    [Serializable]
public class NotNullCounterAttribute : OnMethodBoundaryAspect
{
    public override void OnEntry(MethodExecutionArgs args)
    {
        // Initialize and store the couner for use in other method.
        args.MethodExecutionTag = 0;
    }

    public override void OnExit(MethodExecutionArgs args)
    {
        Console.WriteLine("{0} returned {1} not-null values.", args.Method.Name, args.MethodExecutionTag);
    }
}

  3. Override the OnYield(MethodExecutionArgs) method to add functionality at the point where the iterator yields the next value. This method is invoked when the execution of the iterator is paused and the caller takes over the control flow.

    The following code snippet shows the OnYield(MethodExecutionArgs) method override for the NotNullCounterAttribute class.

    C#
    Copy
    public override void OnYield(MethodExecutionArgs args)
{
    if (args.YieldValue != null)
    {
        args.MethodExecutionTag = ((int) args.MethodExecutionTag) + 1;
    }
}

  4. Apply your custom attribute to the target methods. Below you can see the [NotNullCounter] attribute applied to the TestLogging method.

    C#
    Copy
    [NotNullCounter]
public IEnumerable<string> TestLogging()
{
    yield return "One";
    yield return null;
    yield return "Two";
}

Thanks to the aspect, we will initialize the counter when the enumeration of the TestLogging starts, increase the counter each time a not-null value is returned, and finally write the result when the enumeration completes.

The snippet below shows the enumeration of our sample iterator and the output written to the console.

C#
Copy
foreach (string s in TestLogging()) Console.WriteLine(s ?? "<null>");
Copy
One
<null>
Two
TestLogging returned 2 not-null values.
See Also

Reference

OnMethodBoundaryAspect
OnYield(MethodExecutionArgs)
OnResume(MethodExecutionArgs)
OnEntry(MethodExecutionArgs)
OnSuccess(MethodExecutionArgs)
MethodExecutionArgs
ApplyToStateMachine
YieldValue
SerializableAttribute
PSerializableAttribute

Other Resources

Injecting Behaviors Before and After Method Execution
PostSharp Aspect Framework - Product Page


Intercepting Methods

Intercepting Methods

It is often useful to be able to intercept the invocation of a method and invoke your own hook in its place. Common use cases for this capability include dispatching the method execution to a different thread, asynchronously executing the method at a later time, and retrying the method call when exception is thrown.

PostSharp addresses these needs with the MethodInterceptionAspect aspect class which intercepts the invocation of a method before the method is executed. It also allows you to invoke the original method and access its arguments and return value.

The current article covers method interception, for another approach to injecting behaviors into methods, see Injecting Behaviors Before and After Method Execution.

This topic contains the following sections.

  • Intercepting a method call
  • Accessing the identity of the intercepted method
  • Accessing the arguments and the return value
  • Accessing the target objects
Intercepting a method call

Consider the following CustomerService class which has methods to load and save customer entities and relies on calls to a database or a web-service.

C#
Copy
public class CustomerService
{
    public void Save(Customer customer)
    {
        // Database or web-service call.
    }
}

Occasionally, the connection to the underlying store may become unreliable and the application user is presented with the error message. To improve the user experience you may want to retry the failing operation several times before displaying the error message. In the following steps we'll create a method interception class which can be applied to repository methods and will retry the invocation whenever an exception is thrown by the original method.

To create an aspect that retries a method call on exception:

  1. Create an aspect class and inherit MethodInterceptionAspect. Annotate the class with the [SerializableAttribute] custom attribute.

    C#
    Copy
    public class RetryOnExceptionAttribute : MethodInterceptionAspect
{
}
    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. Define a property MaxRetries and set its default value to 3 in the constructor.

    C#
    Copy
    public int MaxRetries { get; set; }

public RetryOnExceptionAttribute()
{
   this.MaxRetries  = 3;
}

  3. Override the OnInvoke(MethodInterceptionArgs) method.

    C#
    Copy
    public override void OnInvoke(MethodInterceptionArgs args)
{
    base.OnInvoke(args);
}

  4. Edit the OnInvoke method to catch the exception and retry the operation. Use base.OnInvoke() to invoke the intercepted method.

    The complete aspect code is as follows:

    C#
    Copy
    [Serializable]
public class RetryOnExceptionAttribute : MethodInterceptionAspect
{
    public int MaxRetries { get; set; }

    public override void OnInvoke(MethodInterceptionArgs args)
    {
        int retriesCounter = 0;

        while ( true )
        {
            try
            {
                base.OnInvoke(args);
                return;
            }
            catch (Exception e)
            {
                retriesCounter++;
                if (retriesCounter > this.MaxRetries) throw;

                Console.WriteLine(
                    "Exception during attempt {0} of calling method {1}.{2}: {3}",
                    retriesCounter, args.Method.DeclaringType, args.Method.Name, e.Message);
            }
        }
    }
}
    Note Note

    Calling base.OnInvoke() is equivalent to calling args.Proceed().

  5. Apply the [RetryOnException] custom attributes to all methods where the behavior is needed.

    In the following snippet, this aspect is applied to the CustomerService.Save method:

    C#
    Copy
    public class CustomerService
{
    [RetryOnException(MaxRetries = 5)]
    public void Save(Customer customer)
    {
        // Database or web-service call.
    }
}

Whenever the CustomerService.Save method will be invoked, the RetryOnExceptionAttribute.OnInvoke method will be called instead. It will invoke the original method and retry if necessary.

Accessing the identity of the intercepted method

As illustrated in the example above, you can access information about the method being intercepted from the property MethodInterceptionArgsMethod, which gives you a reflection object MethodBase. This object gives you access to parameters, return type, declaring type, and other characteristics. In case of generic methods or generic types, MethodInterceptionArgsMethod gives you the proper generic method instance, so you can use this object to get generic parameters.

Accessing the arguments and the return value

An implementation of MethodInterceptionAspect can read and modify the arguments of the intercepted method thanks to the MethodInterceptionArgsArguments property, and the return value thanks to the MethodInterceptionArgsReturnValue property.

For example, consider a UserService class with a method that returns user permissions. The method would normally return null if no permissions have been assigned to this user.

C#
Copy
public class UserService
{
    public Permissions GetPermissions(string username)
    {
        // Database or web-service call.
    }
}

If the given user has no assigned permission, instead of returning null, we would like the method to return the permissions assigned to the user named DefaultUser.

We can implement these requirements using an aspect derived from MethodInterceptionAspect. The aspect first invokes the original method, then it checks whether it has returned a null value. If the value is null, the method is invoked again but with the arguments replaced by the default values.

To create an aspect that uses default arguments when a method returns null:

  1. Create an aspect class and inherit MethodInterceptionAspect. Annotate the class with the [SerializableAttribute] custom attribute.

    C#
    Copy
    [Serializable]
public class RetryIfNullAttribute : MethodInterceptionAspect
{
}
    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. Add a field defaultArguments to the class and set this field from the constructor.

    C#
    Copy
    private object[] defaultArguments;

public RetryIfNullAttribute(params object[] defaultArguments)
{
    this.defaultArguments = defaultArguments;
}

  3. Override the OnInvoke(MethodInterceptionArgs) method.

    C#
    Copy
    public override void OnInvoke(MethodInterceptionArgs args)
{
    base.OnInvoke(args);
}

  4. Edit the OnInvoke method to implement the aspect logic. Check whether the MethodInterceptionArgsReturnValue property is null return value, and set the items of the MethodInterceptionArgsArguments property. Finally, invoke the intercepted method a second time by calling base.OnInvoke().

    The complete aspect code is as follows:

    C#
    Copy
    [Serializable]
public class RetryIfNullAttribute : MethodInterceptionAspect
{
    private object[] defaultArguments;

    public RetryIfNullAttribute(params object[] defaultArguments)
    {
        this.defaultArguments = defaultArguments;
    }

    public override void OnInvoke(MethodInterceptionArgs args)
    {
        base.OnInvoke(args);

        if (args.ReturnValue == null)
        {
            Console.WriteLine(
                "The method {0}.{1} has returned a null value." +
                " Retrying with the default arguments...",
                args.Method.DeclaringType, args.Method.Name);

            for (int i = 0; i < args.Arguments.Count && i < this.defaultArguments.Length; i++)
            {
                args.Arguments[i] = this.defaultArguments[i];
            }

            base.OnInvoke(args);
        }
    }
}

  5. Apply this method interception aspect as an attribute to all methods where the implemented logic is needed. In the following snippet, the aspect is applied to the UserService.GetPermissions method:

    C#
    Copy
    public class UserService
{
    [RetryIfNull("DefaultUser")]
    public Permissions GetPermissions(string username)
    {
        // database or web-service call
    }
}

Thanks to the aspect, whenever the UserService.GetPermissions method is invoked, the RetryIfNullAttribute.OnInvoke method will be called instead. The OnInvoke method will then invoke the original GetPermissions method. If it returns null for the provided username, then the method will be invoked again, but this time with the value DefaultValue for the username parameter.

Accessing the target objects

In combination with the parameters you will probably interact with the target code instance that the aspect is attached to. The Instance property provides you with the instance of the object that the aspect is currently operating against. It is an object type so you will need to cast it to the correct type to be able to interact with it. If you debug your aspect and that aspect doesn't make use of Instance, it will be set to null. It's also set to null if the target code is defined as static.

See Also

Reference

MethodInterceptionAspect
OnInvoke(MethodInterceptionArgs)
MethodInterceptionArgs
Arguments
Binding
Instance
Method
SerializableAttribute
PSerializableAttribute

Other Resources

PostSharp Aspect Framework - Product Page


Intercepting Properties and Fields

Intercepting Properties and Fields

In .NET, both fields and properties are "things" that can be set and get. You can intercept get and set operations using the LocationInterceptionAspect. It makes it possible to develop useful aspects, such as validation, filtering, change tracking, change notification, or property virtualization (where the property is backed by a registry value, for instance).

This topic contains the following sections.

  • Intercepting Get operations
  • Intercepting Set operations
  • Getting and setting the underlying property
  • Intercepting fields
  • Getting the property or property being accessed
Intercepting Get operations

In this example, we will see how to create an aspect that filters the value read from a field or property.

To create an aspect that filters the value read from a field or property

  1. Create an aspect that inherits from LocationInterceptionAspect and add the custom attribute [SerializableAttribute].

    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. Override the OnGetValue(LocationInterceptionArgs) method.

    C#
    Copy
    [Serializable]
public class StringCheckerAttribute : LocationInterceptionAspect
{
    public override void OnGetValue(LocationInterceptionArgs args)
    {
        base.OnGetValue(args);
    }

}

  3. Calling base.OnGetValue actually retrieves the value from the underlying field or property, and populates the Value property. Add some code to check if the property currently is set to null If the current value is null, we want to return a predefined value. To do this we can set the Value property. Any time this property is requested, and it is set to null, the value "foo" will be returned.

    C#
    Copy
     public override void OnGetValue(LocationInterceptionArgs args)
{
    base.OnGetValue(args);

    if (args.Value == null)
    {
        args.Value = "foo";
    }
}

  4. Now that you have a complete getter interception aspect written you can attach it to the target code. Simply add an attribute to either properties or fields to have the interception attached.

    C#
    Copy
     public class Customer
{
    [StringChecker]
    private readonly string _address;

    public Customer(string address)
    {
        _address = address;
    }
    [StringChecker]
    public string Name { get; set; }
    public string Address { get { return _address; } }
}
    Note Note

    Adding aspects to target code one property or field at a time can be a tedious process. There are a number of techniques in the article Adding Aspects to Multiple Declarations that explain how to add aspects en mass.

  5. Now when you create an instance of a customer and immediately try to access the Name and Address values the get request will be intercepted and null values will be returned as "foo".

    C#
    Copy
     class Program
{
    static void Main(string[] args)
    {
        var customer = new Customer("123 Main Street");
        Console.WriteLine("Address: {0}", customer.Address);
        Console.WriteLine("Name: {0}", customer.Name);
        Console.ReadKey();
    }
}
    Intercepting Properties 1

Property and field interception is a simple and seamless task. Once you have intercepted your target you can act on the target or you can allow the original code to execute.

Intercepting Set operations

The previous section showed how to intercept a get accessor. Intercepting a set accessor is accomplished in a similar manner by implementing OnSetValue(LocationInterceptionArgs) in the LocationInterceptionAspect.

The following snippet shows the addition of OnSetValue(LocationInterceptionArgs) to the StringCheckerAttribute example:

C#
Copy
[Serializable]
public class StringCheckerAttribute : LocationInterceptionAspect
{
public override void OnGetValue(LocationInterceptionArgs args)
{
base.OnGetValue(args);
}

public override void OnSetValue(LocationInterceptionArgs args)
{
base.OnSetValue(args);
}
}

When applied to a property with a set operator, OnSetValue(LocationInterceptionArgs) will intercept the set operation. In the Customer example shown below, OnSetValue(LocationInterceptionArgs) will be called whenever the Name property is set:

C#
Copy
 public class Customer
{
    .
    .
    .
[StringChecker]
public string Name { get; set; }
}

The SetNewValue(Object) method of LocationInterceptionArgs can be used instead of base.OnSetValue() to pass a different value in for the property. For example, OnSetValue(LocationInterceptionArgs) could be used to check for a null string, and then change the string to a non-null value:

C#
Copy
[Serializable]
public class StringCheckerAttribute : LocationInterceptionAspect
{
    .
    .
    .
public override void OnSetValue(LocationInterceptionArgs args)
{
if (args.Value == null)
{
args.Value = “Empty String";
}

args.ProceedSetValue();

}
}
Getting and setting the underlying property

PostSharp provides a mechanism to check a property’s underlying value via the LocationInterceptionArgsGetCurrentValue method. This can be useful to check the current property value when a setter is called and then take some appropriate action.

For example, the following snippet shows a modified OnSetValue(LocationInterceptionArgs) method which gets the current underlying property value and compares the (new) value passed into the setter against the current value. If current and new value don’t match then some message is written:

C#
Copy
 public override void OnSetValue(LocationInterceptionArgs args)
{
  //get the current underlying value
  string existingValue = (string)args.GetCurrentValue();

  if (((existingValue==null) && (args.Value != null)) || (!existingValue.Equals(args.Value)))
  {
    Console.WriteLine(“Value changed.”);
    args.ProceedSetValue();
  }
}
Note Note

GetCurrentValue will call the underlying property getter without going through OnGetValue(LocationInterceptionArgs). If several aspects are applied to the property (and/or to the property setter), GetCurrentValue will go through the next aspect in the chain of invocation.

PostSharp also provides a mechanism to set the underlying property in a getter via the SetNewValue(Object) method of LocationInterceptionArgs. This could be used for example, to ensure that a default value is assigned to the underlying property if there is currently no value. The following snippet shows a modified OnGetValue(LocationInterceptionArgs) method which gets the current underlying value, and sets a default value if the current value is null:

C#
Copy
 public override void OnGetValue(LocationInterceptionArgs args)
{
    object o = args.GetCurrentValue();
    if (o == null)
    {
        args.SetNewValue("value not set");
    }

    base.OnGetValue(args);
}
Intercepting fields

One benefit to implementing a LocationInterceptionAspect is that it can be applied directly to fields, allowing for reads and writes to those fields to be intercepted, just like with properties.

Applying a LocationInterceptionAspect implementation to a field is simply a matter of setting it as an attribute on a field, just as it was done with a property:

C#
Copy
 public class Customer
{
    .
    .
    .
[StringChecker]
public string name;
}

With the attribute applied to the name field, all attempts to get and set that field will be intercepted by StringChecker in its OnGetValue(LocationInterceptionArgs) and OnSetValue(LocationInterceptionArgs) methods.

Note that when a LocationInterceptionAspect is added to a field, the field is replaced by a property of the same field and visibility. The field itself is renamed and made private.

Getting the property or property being accessed

Information about the property or field being intercepted can be obtained through the LocationInterceptionArgs via its Location property. The type of this property, LocationInfo, can represent a FieldInfo, a PropertyInfo, or a ParameterInfo (although LocationInterceptionAspect cannot be added to parameters).

One use for this is to reflect the property name whenever a property is changed. In the following example, we have an Entity class that implements INotifyPropertyChanged and a public OnPropertyChanged method which allows notifications to be made whenever a property is changed. The Customer class has been modified to derive from Entity.

C#
Copy
 class Entity : INotifyPropertyChanged
{

  public event PropertyChangedEventHandler PropertyChanged;

  public void OnPropertyChanged(string propertyName)
  {
    if (PropertyChanged != null)
     PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  }
}

 class Customer : Entity
{
  public string Name { get; set; }
}

With the ability to invoke an OnPropertyChanged event, we can create a LocationInterceptionAspect which invokes this event when setting a value and pass in the property name from the underlying PropertyInfo object:

C#
Copy
[Serializable]
public class NotifyPropertyChangedAttribute : LocationInterceptionAspect
{

public override void OnSetValue(LocationInterceptionArgs args)
{
If ( args.Value != args.GetCurrentValue() )
{
args.Value = args.Value;
args.ProceedSetValue();
((Entity)args.Instance).OnPropertyChanged(args.Location.Name);
}
}
}
Note Note

This example is a simplistic implementation of the NotifyPropertyChangedAttribute aspect. For a production-ready implementation, see the section INotifyPropertyChanged.

This aspect can then be applied to the Customer class:

Copy
[NotifyPropertyChangedAttribute]
class Customer : INotifyPropertyChanged
{
    public string Name { get; set; }
}

Now when the Name property is changed, NotifyPropertyChangedAttribute will invoke the Entity.OnPropertyChanged method passing in the property name retrieved from its underlying property.

See Also

Reference

LocationInterceptionAspect
OnGetValue(LocationInterceptionArgs)
OnSetValue(LocationInterceptionArgs)
LocationInterceptionArgs
Location
LocationInfo
FieldInfo
PropertyInfo
ParameterInfo
INotifyPropertyChanged
NotifyPropertyChangedAttribute

Other Resources

Adding Aspects to Multiple Declarations
INotifyPropertyChanged


Intercepting Events

Intercepting Events

You interact with events in three primary ways; subscribing, unsubscribing and raising them. Like methods and properties, you may find yourself needing to intercept these three interactions. How do you execute code everytime that an event is subscribed to? Or raised? Or unsubscribed? PostSharp provides you with a simple mechanism to accomplish this easily.

This topic contains the following sections.

  • Intercepting Add and Remove
  • Intercepting Raise
  • Accessing the current context
  • Example: Removing offending event subscribers
Intercepting Add and Remove

Throughout the life of an event it is possible to have many different event handlers subscribe and unsubscribe. You may want to log each of these actions.

  1. Create an aspect that inherits from EventInterceptionAspect. Add the [PSerializableAttribute] custom attribute.

    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  2. Override the OnAddHandler(EventInterceptionArgs) method and add your logging code to the method body.

  3. Add the base.OnAddHandler call to the body of the OnAddHandler(EventInterceptionArgs) method. If this is omitted, the original call to add a handler will not be executed. Unless you want to stop the addition of the handler, you will need to add this line of code.

    C#
    Copy
     public class CustomEventing : EventInterceptionAspect
{
    public override void OnAddHandler(EventInterceptionArgs args)
    {
        base.OnAddHandler(args);
        Console.WriteLine("A handler was added");
    }
}

  4. To log the removal of an event handler, override the OnRemoveHandler(EventInterceptionArgs) method.

  5. Add the logging you require to the method body.

  6. Add the base.OnRemoveHandler call to the body of the OnRemoveHandler(EventInterceptionArgs) method. Like you saw when overriding the OnAddHandler(EventInterceptionArgs) method, if you omit this call, the original call to remove the handler will not occur.

    C#
    Copy
     public override void OnRemoveHandler(EventInterceptionArgs args)
{
    base.OnRemoveHandler(args);
    Console.WriteLine("A handler was removed");
}

Once you have defined the interception points in the aspect you will need to attach the aspect to the target code. The simplest way to do this is to add the attribute to the event handler definition.

C#
Copy
 public class Example
{
    public EventHandler<EventArgs> SomeEvent;

    public void DoSomething()
    {
        if (SomeEvent != null)
        {
            SomeEvent.Invoke(this, EventArgs.Empty);
        }
    }
}
Intercepting Raise

When you are intercepting events you will also have situations where you will want to intercept the code execution when the event is raised. Raising an event can occur may places and you will want to centralize this code to save repetition.

  1. Override the OnInvokeHandler(EventInterceptionArgs) method on your aspect class and add the logging you require to the method body.

  2. Add a call to base.OnInvokeHandler to ensure that the original invocation occurs.

    C#
    Copy
     public override void OnInvokeHandler(EventInterceptionArgs args)
{
    base.OnInvokeHandler(args);
    Console.WriteLine("A handler was invoked");
}

By adding the attribute to the target code's event handler earlier in this process you have enabled intercepting of each raised event.

Accessing the current context

At any time, the Handler property is set to the delegate being added, removed, or invoked. You can read and write this property. If you write it, the delegate you assign must be compatible with the type of the event. The Event property gets you the EventInfo of the event being accessed.

Within OnInvokeHandler(EventInterceptionArgs), the property Arguments gives access to the arguments with which the delegate was invoked.

These concepts will be illustrated in the following example.

Example: Removing offending event subscribers

When events are subscribed to, the component that raises the event has no way to ensure that the subscriber will behave properly when that event is raised. It's possible that the subscribing code will throw an exception when the event is raised and when that happens you may want to unsubscribe the handler to ensure that it doesn't continue to throw the exception. The EventInterceptionAspect is powerful and can help you to accomplish this with ease.

  1. Override the OnInvokeHandler(EventInterceptionArgs) method on your aspect.

  2. In the method body add a try...catch block.

  3. In the try block add a call to base.OnInvokeHandler and in the catch block add a call to RemoveHandler(Delegate)

    C#
    Copy
     public class CustomEventing : EventInterceptionAspect
{
    public override void OnInvokeHandler(EventInterceptionArgs args)
    {
        try
        {
            base.OnInvokeHandler(args);
        }
        catch (Exception e)
        {
            Console.WriteLine("Handler '{0}' invoked with arguments {1} failed with exception {2}",
                              args.Handler.Method,
                              string.Join(", ", args.Arguments.Select(
                                                                      a => a == null ? "null" : a.ToString())),
                              e.GetType().Name);

            args.RemoveHandler(args.Handler);
            throw;
        }
    }

}

Now any time an exception is thrown when the event is executed, the offending event handler will be unsubscribed from the event.

See Also

Reference

EventInterceptionAspect
Handler
Event
PSerializableAttribute
SerializableAttribute
OnAddHandler(EventInterceptionArgs)
OnAddHandler(EventInterceptionArgs)
OnRemoveHandler(EventInterceptionArgs)
OnInvokeHandler(EventInterceptionArgs)
EventInfo
RemoveHandler(Delegate)


Introducing Interfaces

Introducing Interfaces

When you create a CompositionAspect you are able to dynamically add interfaces to the target code at compile time and make use of that interface type at run time.

  1. The first thing that you need to do is create an aspect that inherits from CompositionAspect and implements its members.

    C#
    Copy
    [Serializable]
public class GeneralCompose : CompositionAspect
{
    public override object CreateImplementationObject(AdviceArgs args)
    {
        throw new System.NotImplementedException();
    }
}

  2. Next, you need some way to tell the aspect what interface and concrete type you want to implement on the target code. To do that, create a constructor for your aspect that accepts two parameters; one for the interface type and one for the concrete implementation type. Assign those two constructor parameters to field level variables so we can make use of them in the aspect.

    C#
    Copy
    [Serializable]
public class GeneralCompose : CompositionAspect
{
    private readonly Type _interfaceType;
    private readonly Type _implementationType;

    public GeneralCompose(Type interfaceType, Type implementationType)
    {
        _interfaceType = interfaceType;
        _implementationType = implementationType;
    }

  3. There are two methods that you need to implement to complete this aspect. The first is an override of the GetPublicInterfaces(Type) method. This method has a target type parameter which allows you to filter the application of the interface if you choose to. For this example, simply return an array that contains the interface type that was provided via the aspect's constructor.

    C#
    Copy
     protected override Type[] GetPublicInterfaces(Type targetType)
{
return new[] { _interfaceType };
}
    Note Note

    The interfaces that are returned from the GetPublicInterfaces(Type) method will be applied to the target code during compilation.

  4. The second method that you need to override is CreateImplementationObject(AdviceArgs). For this example you will return an instance of the concrete implementation that was provided in the aspect's constructor. The CreateImplementationObject(AdviceArgs) method doesn't return the type of the concrete implementation. It returns an instance of that type instead. To create the instance use the CreateInstance(Type, ActivatorSecurityToken) method.

    C#
    Copy
     public override object CreateImplementationObject(AdviceArgs args)
{
return Activator.CreateInstance(_implementationType);
}
    Note Note

    The CreateImplementationObject(AdviceArgs) method is invoked at the application's runtime.

  5. Now that you have created a complete CompositionAspect, it will need to be applied to the target code. Add the aspect to the target code as an attribute. Provide the attribute with the interface and concrete types that you wish to implement.

    C#
    Copy
    [GeneralCompose(typeof(IList), typeof(ArrayList))]
public class Fruit
{
}

  6. After compiling your application you will find that the target code now implements the assigned interfaces and exposes itself as a new instance of the concrete type you declared. The next question that needs addressing is how you will interact with the target code using that interface type.

    To access the dynamically applied interface you must make use of a special PostSharp feature. The CastSourceType, TargetType(SourceType) method will allow you to safely cast the target code to the interface type that you dynamically applied. Once that call has been done, you are able to make use of the instance through the interface constructs.

    C#
    Copy
    [GeneralCompose(typeof(IList), typeof(ArrayList))]
public class Fruit
{
    public Fruit()
    {
        IList list = Post.Cast<Fruit,IList>(this);
        list.Add("apple");
        list.Add("orange");
        list.Add("banana");
    }
}


Introducing Custom Attributes

Introducing Custom Attributes

Applying custom attributes to class members in C# is a powerful way to add metadata about those members at compile time.

PostSharp provides the ability to create a custom attribute class which when applied to another class, can iterate through those class members and automatically decorate them with custom attributes. This can be useful for example, to automatically apply custom attributes or groups of custom attributes when new class members are added, without having to remember to do it manually each time.

This topic contains the following sections.

  • Introducing new custom attributes
  • Copying existing custom attributes
Introducing new custom attributes

In the following example, we’ll create an attribute decorator class which applies .NET’s DataContractAttribute to a class and DataMemberAttribute to members of a class at build time.

  1. Start by creating a class called AutoDataContractAttribute which derives from TypeLevelAspect. TypeLevelAspect transforms the class into an attribute which can be applied to other classes. Also implement IAspectProvider which exposes the ProvideAspects(Object) method for iterating on class members. ProvideAspects(Object) will be called for each member in the target class and will contain the code for applying the attributes:

    C#
    Copy
    public sealed class AutoDataContractAttribute : TypeLevelAspect, IAspectProvider
{
    public IEnumerable<AspectInstance> ProvideAspects(object targetElement)
    {
}

  2. Implement the ProvideAspects(Object) method to cast the targetElement parameter to a Type object. Note that this method will be called at build time. Since ProvideAspects(Object) will be called for the class itself and for each member of the target class, the Type object can be used for inspecting each member and making decisions about when and how to apply custom attributes. In the following snippet, the implementation returns a new AspectInstance for the Type containing a new DataContractAttribute and then iterates through each property of the Type returning a new AspectInstance with the DataMemberAttribute for each. Note that both the DataContractAttribute and DataMemberAttribute are both wrapped in CustomAttributeIntroductionAspect objects:

    C#
    Copy
    public sealed class AutoDataContractAttribute : TypeLevelAspect, IAspectProvider
{
    // This method is called at build time and should just provide other aspects.
    public IEnumerable<AspectInstance> ProvideAspects(object targetElement)
    {
        Type targetType = (Type) targetElement;

        CustomAttributeIntroductionAspect introduceDataContractAspect =
            new CustomAttributeIntroductionAspect(
                new ObjectConstruction(typeof (DataContractAttribute).GetConstructor(Type.EmptyTypes)));
        CustomAttributeIntroductionAspect introduceDataMemberAspect =
            new CustomAttributeIntroductionAspect(
                new ObjectConstruction(typeof (DataMemberAttribute).GetConstructor(Type.EmptyTypes)));

        // Add the DataContract attribute to the type.
        yield return new AspectInstance(targetType, introduceDataContractAspect);

        // Add a DataMember attribute to every relevant property.
        foreach (PropertyInfo property in
            targetType.GetProperties(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance))
        {
            if (property.CanWrite)
                yield return new AspectInstance(property, introduceDataMemberAspect);
        }
    }
}
    Note Note

    Since the ProvideAspects(Object) method returns an IEnumerable, the yield keyword should be used to return aspects for PostSharp to apply.

  3. Apply the AutoDataContractAttribute class. In the following example we apply it to a Product class where it will decorate Product with DataContractAttribute and each member with DataMemberAttribute:

    C#
    Copy
    [AutoDataContractAttribute]
public class Product
{
    public int ID { get; set; }

    public string Name { get; set; }

    public int RevisionNumber { get; set; }
}

See Example: Automatically Adding DataContract and DataMember Attributes to learn how to have the DataContractAttribute automatically applied to derived classes.

Copying existing custom attributes

Another way to introduce attributes to class members is to copy them from another class. This is useful for example, when distinct classes have members with the same names and are of the same types. In this case, attributes can be defined in one class and then that class can be used to decorate other similar classes with same attributes.

In the following snippet, Product’s ID and Name properties have both been modified to contain an additional attribute from the System.ComponentModel.DataAnnotations namespace – Editable, Display, and Required respectively. Below Product is another class called ProductViewModel containing the same properties to which we want to copy the attributes to:

C#
Copy
class Product
{
    [EditableAttribute(false)]
    [Required]
    public int Id { get; set; }

    [Display(Name = "The product's name")]
    [Required]
    public string Name { get; set; }
    public int RevisionNumber { get; set; }
}

class ProductViewModel
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int RevisionNumber { get; set; }
}

To copy the attributes from the properties of Product to the corresponding properties of ProductViewModel, create an attribute class which can be applied to ProductViewModel to perform this copy process:

  1. Create a TypeLevelAspect which implements IAspectProvider. In the snippet below our class is called CopyCustomAttributesFrom:

    C#
    Copy
    class CopyCustomAttributesFrom : TypeLevelAspect, IAspectProvider
{
}

  2. Create a constructor to take in the class type from which the property attributes are to be copied from. This class type will be used in the next step to enumerate its properties:

    C#
    Copy
    class CopyCustomAttributesFrom : TypeLevelAspect, IAspectProvider
{
private Type sourceType;

public CopyCustomAttributesFrom(Type srcType)
{
    sourceType = srcType;
}
    }

  3. Implement ProvideAspects(Object):

    C#
    Copy
    class CopyCustomAttributesFrom : TypeLevelAspect, IAspectProvider
{
    // Details skipped.

    public IEnumerable<AspectInstance> ProvideAspects(object targetElement)
    {
        Type targetClassType = (Type)targetElement;

        //loop thru each property in target
        foreach (PropertyInfo targetPropertyInfo in targetClassType.GetProperties())
        {
            PropertyInfo sourcePropertyInfo = sourceType.GetProperty(targetPropertyInfo.Name);

            //loop thru all custom attributes for the source property and copy to the target property
            foreach (CustomAttributeData customAttributeData in sourcePropertyInfo.GetCustomAttributesData())
            {
                //filter out attributes that aren’t DataAnnotations
                if (customAttributeData.AttributeType.Namespace.Equals("System.ComponentModel.DataAnnotations"))
                {
                    CustomAttributeIntroductionAspect customAttributeIntroductionAspect =
                        new CustomAttributeIntroductionAspect(new ObjectConstruction(customAttributeData));

                    yield return new AspectInstance(targetPropertyInfo, customAttributeIntroductionAspect);
                }
            }

        }
    }
}

    The ProvideAspects(Object) method iterates through each property of the target class and then gets the corresponding property from the source class. It then iterates through all custom attributes defined for the source property, copying each to the corresponding property of the target class. ProvideAspects(Object) also filters out attributes which aren’t from the System.ComponentModel.DataAnnotations namespace to demonstrate how you may want to ignore some attributes during the copy process.

  4. Decorate the ProductViewModel class with the CopyCustomAttributesFrom attribute, specifying Product as the source type in the constructor. During compilation, CopyCustomAttributesFrom’s ProvideAspects(Object) method will then perform the copy process from Product to ProductViewModel:

    C#
    Copy
    [CopyCustomAttributesFrom(typeof(Product))]
class ProductViewModel
{
    // Details skipped.
}

The following screenshot shows the Product and ProductViewModel classes reflected from an assembly. Here we can see that the Editable and Display attributes were copied from Product to ProductViewModel using CopyCustomAttributesAttribute at build time:

Note Note

It is not possible to delete or replace an existing custom attribute.

See Also

Reference

ProvideAspects(Object)
CopyCustomAttributesAttribute
DataContractAttribute
DataMemberAttribute
TypeLevelAspect
IAspectProvider
AspectInstance
CustomAttributeIntroductionAspect

Other Resources

Example: Automatically Adding DataContract and DataMember Attributes


Introducing Managed Resources

Introducing Managed Resources

Embedding resources in .NET allows for data to be packaged together with your code in an assembly. Resources are normally specified at design time and then embedded by the compiler during build time.

PostSharp’s AssemblyLevelAspect adds additional flexibility by allowing you to programmatically add resources at compile time. In doing so you can add logic and therefore flexibility in determining which resources get embedded and how. For example, you could use this feature to encrypt a resource just before embedding it into your assembly.

Introducing resources

In the following example, we’ll create an assembly decorator which retrieves the current date and time during compilation, and then stores that information in the current assembly as a resource. The example will then show that that information can be retrieved from the assembly at runtime.

  1. Start by creating a class called AddBuildInfoAspect which derives from AssemblyLevelAspect. Also implement IAspectProvider which exposes the ProvideAspects(Object) method. The ProvideAspects(Object) method will be called once by PostSharp, providing access to assembly information and allowing for a resource to be programmatically added to the assembly:

    C#
    Copy
     public sealed class AddBuildInfoAspect : AssemblyLevelAspect, IAspectProvider
{
    public IEnumerable<AspectInstance> ProvideAspects(object targetElement)
    {
    }
}

  2. Implement the ProvideAspects(Object) method:

    C#
    Copy
     public sealed class AddBuildInfoAspect : AssemblyLevelAspect, IAspectProvider
{
    public IEnumerable<AspectInstance> ProvideAspects(object targetElement)
    {
        Assembly assembly = (Assembly)targetElement;

        byte[] userNameData = Encoding.ASCII.GetBytes(
           assembly.FullName + " was compiled by: " + Environment.UserName);
        ManagedResourceIntroductionAspect mria2 = new ManagedResourceIntroductionAspect("BuildUser", userNameData);

        yield return new AspectInstance(assembly, mria2);
    }
}

    In this example the targetElement object passed in is cast to an Assembly object from which the assembly named is retrieved. The code then gets the current date and time, concatenates it with the assembly name, and then converts this string to a byte array. The byte array is then stored along with a name for the data in PostSharp’s ManagedResourceIntroductionAspect object, and returned via an AspectInstance. PostSharp then embeds the resource into the current assembly.

  3. Open your project’s AssemblyInfo.cs file and add a line to include the AddBuildInfoAspect class:

    C#
    Copy
    [assembly:AddBuildInfoAspect]

With this code in place the assembly will now embed the date and time as a resource into itself during compilation.

The following code demonstrates how to retrieve the data at runtime:

C#
Copy
 class Program
{
    static void Main(string[] args)
    {
        Assembly a = Assembly.GetExecutingAssembly();
        Stream stream = a.GetManifestResourceStream("BuildUser");

        byte[] bytesRead = new byte[stream.Length];
        stream.Read(bytesRead, 0, (int)stream.Length);
        string value = Encoding.ASCII.GetString(bytesRead);
        Console.WriteLine(value);
    }
}

This will display the following line in the console window:

See Also

Reference

AssemblyLevelAspect
IAspectProvider
ManagedResourceIntroductionAspect
AspectInstance

Other Resources

Adding Aspects Programmatically using IAspectProvider


Understanding Aspect Lifetime and Scope

Understanding Aspect Lifetime and Scope

An original feature of PostSharp is that aspects are instantiated at compile time. Most other frameworks instantiate aspects at run time.

Persistence of aspects between compile time and run time is achieved by serializing aspect instances into a binary resource stored in the transformed assembly. Therefore, you should carefully mark all aspect classes with the SerializableAttribute custom attribute, and distinguish between serialized fields (typically initialized at compile-time and used at run-time) and non-serialized fields (typically used at run-time only or at compile-time only).

Note Note

If your project targets Silverlight, Windows Phone, or the Compact Framework, aspects are initialized at run-time and all compile-time steps are skipped.

This topic contains the following sections.

  • Scope of Aspects
  • Steps in the Lifetime of an Aspect Instance
  • Examples
Scope of Aspects

PostSharp offers two kinds of aspect scopes: static (per-class) and per-instance.

Statically Scoped Aspects

With statically-scoped aspects, PostSharp creates one aspect instance for each element of code to which the aspect applies. The aspect instance is stored in a static field and is shared among all instances of the target class.

In generic types, the aspect instance has not exactly the same scope as static fields. Consider the following piece of code:

C#
Copy
 public class GenericClass<T>
{
  static T f;

  [Trace]
  public void void SetField(T value) { f = value; }
}

public class Program
{
   public static void Main()
   {
      GenericClass<int>.SetField(1);
      GenericClass<long>.SetField(2);
   }
}

In this program, there are two instances of the static field f (one for GenericClass<int>, the second for GenericClass<long>) but only a single instance of the aspect Trace.

Instance-Scoped Aspects

Instance-scoped aspect have the same scope (instance or static) as the element of code to which they are applied. If an instance-scoped aspect is applied to a static member, it will have static scope. However, if it is applied to an instance member or to a class, it will have the same lifetime as the class instance: an aspect instance will be created whenever the class is instantiated, and the aspect instance will be garbage-collectable at the same time as the class instance.

Instance-scoped aspects are implemented according to the prototype pattern: the aspect instance created at compile time serves as a prototype, and is cloned at run-time whenever the target class is instantiated.

Instance-scoped aspects must implement the interface IInstanceScopedAspect. Any aspect may be made instance-scoped. The following code is a typical implementation of the interface IInstanceScopedAspect:

C#
Copy
 object IInstanceScopedAspect.CreateInstance( AdviceArgs adviceArgs )
{
  return this.MemberwiseClone();
}

object IInstanceScopedAspect.RuntimeInitializeInstance()
{
}
Steps in the Lifetime of an Aspect Instance

The following table summarizes the different steps of

Phase

Step

Description

Compile-Time

Instantiation

PostSharp creates a new instance of the aspect for every target to which it applies. If the aspect has been applied using a multicast custom attribute (MulticastAttribute), there will be one aspect instance for each matching element of code.

When the aspect is given as a custom attribute or a multicast custom attribute, each custom attribute instance is instantiated using the same mechanism as the Common Language Runtime (CLR) does: PostSharp calls the appropriate constructor and sets the properties and/or fields with the appropriate values. For instance, when you use the construction [Trace(Category="FileManager")], PostSharp calls the default constructor and the Category property setter.

Validation

PostSharp validates the aspect by calling the CompileTimeValidate aspect method. See Validating Aspect Usage for details.

Compile-Time Initialization

PostSharp invokes the CompileTimeInitialize aspect method. This method may, but must not, be overridden by concrete aspect classes in order to perform some expensive computations that do not depend on runtime conditions. The name of the element to which the custom attribute instance is applied is always passed to this method.

Serialization

After the aspect instances have all been created and initialized, PostSharp serializes them into a binary stream. This stream is stored inside the new assembly as a managed resource.

Run-Time

Deserialization

Before the first aspect must be executed, the aspect framework deserializes the binary stream that has been stored in a managed resource during post-compilation.

At this point, there is still one aspect instance per target class.

Per-Class Runtime Initialization

Once all custom attribute instances are deserialized, we call for each of them the RuntimeInitialize method. But this time we pass as an argument the real System.Reflection object to which it is applied.

Per-Instance Runtime Initialization

This step applies only to instance-scoped aspects when they have been applied to an instance member.

When a class is instantiated, the aspect framework creates an aspect instance by invoking the method CreateInstance(AdviceArgs) of the prototype aspect instance. After the new aspect instance has been set up, the aspect framework invokes the RuntimeInitializeInstance.

Advice Execution

Finally, advices (methods such as OnEntry(MethodExecutionArgs)) are executed.

Examples

Example: Raising an Event When the Object is Finalized

See Also

Other Resources

Validating Aspect Usage
Initializing Aspects
Understanding Aspect Serialization
Coping with Custom Object Serializers


Initializing Aspects

Initializing Aspects

As explained in the section Understanding Aspect Lifetime and Scope, a different aspect instance is associated with every element of code it is applied to. Aspect instances are created at compile time, serialized into the assembly as a managed resource, and deserialized at runtime. If the aspect is instance-scoped, instances are duplicated from the prototype and initialized.

Therefore, you can override one of the following three methods to handle aspect initializations:

  1. The method CompileTimeInitialize is invoked at compile time, and should initialize only serializable fields of the aspect, so that the value of these fields will be available at run time. The argument of this method is the System.Reflection object representing the element of code to which this aspect instance has been applied. Therefore, this method can already perform expensive computations that depend only on metadata.

  2. The method RuntimeInitialize is invoked at run time. Note that the aspect constructor itself is not invoked at run time. Therefore, overriding RuntimeInitialize is the only way to perform initialization tasks at run time. If the aspect is instance-scoped, this method is executed on the prototype instance.

  3. The methods IInstanceScopedAspectCreateInstance(AdviceArgs) and IInstanceScopedAspectRuntimeInitializeInstance is invoked only for instance-scoped aspects. They initialize the aspect instance itself, as RuntimeInitialize was invoked on the prototype.

Tip Tip

Initializing an aspect at compile time is useful when you need to compute a difficult result that depends only on metadata -- that is, it does not depend on any runtime information. An example is to build the strings that need to be printed by a tracing aspect. It is rather expensive to build strings that contain the full type name, the method name, and eventually placeholders for generic parameters and parameters. However, all required pieces of information are available at compile time. So compile time is the best moment to compute these strings.

See Also

Other Resources

Understanding Aspect Lifetime and Scope


Validating Aspect Usage

Validating Aspect Usage

Some aspects make sense only on a specific subset of targets. For instance, an aspect may require to be applied on non-static methods only. Another aspect may not be compatible with methods that have ref or out parameters. If these constraints are not respected, these aspects will fail at runtime. However, defects detected by the compiler are always cheaper to fix than ones detected later. So, as the developer of an aspect, you should ensure that the build will fail if your aspect is being used on an invalid target.

This topic contains the following sections.

  • Using [MulticastAttributeUsage]
  • Implementing CompileTimeValidate
  • Using Message Sources
  • Validating Attributes That Are Not Aspects
  • Examples
Using [MulticastAttributeUsage]

The first level of protection is to configure multicasting properly with [MulticastAttributeUsageAttribute], as described in the article Adding Aspects Declaratively Using Attributes. However, this approach can only filter based on characteristics that are supported by the multicasting component.

Implementing CompileTimeValidate

The best way to validate aspect usage is to override the CompileTimeValidate(Object) method of your aspect class.

In this example, we will show how an aspect RequirePermissionAttribute can require to be applied only to methods of types that implement the ISecurable interface.

  1. Inherit from one of the pre-built aspects. In this case OnMethodBoundaryAspect.

    C#
    Copy
    public class RequirePermissionAttribute: OnMethodBoundaryAspect

  2. Override the CompileTimeValidate(Object) method.

    C#
    Copy
     public override bool CompileTimeValidate(MethodBase target)
{

  3. Perform a check to see if the target class implements the interface in question.

    C#
    Copy
    Type targetType = target.DeclaringType;
if (!typeof(ISecurable).IsAssignableFrom(targetType))
{

}

  4. If the target does not implement the interface you must signal the compilation process that this target should not have the aspect applied to it. There are two ways to do this. The first option is to throw an InvalidAnnotationException.

    C#
    Copy
    if (!typeof(ISecurable).IsAssignableFrom(targetType))
{
  throw new InvalidAnnotationException("The target type does not implement ISecurable.");
}

  5. The second option is to emit an error message to the compilation process.

    C#
    Copy
     if (!typeof(ISecurable).IsAssignableFrom(targetType))
{
  Message.Write(SeverityType.Error, "Custom01",
                "The target type does not implement ISecurable.", target);
 return false;
}
Note Note

You may have noticed that CompileTimeValidate(Object) returns a boolean value. If you only return false from this method the compilation process will silently ignore it. You must either throw the InvalidAnnotationException or emit an error message to not silently ignore the false return value.

Making use of the CompileTimeValidate(Object) method is a great way to encode custom rules for applying aspects to target code. While it could be used to duplicate the functionality of the AttributeTargetTypeAttributes or AttributeTargetMemberAttributes, its real power is to go beyond those filtering techniques. By using CompileTimeValidate(Object) you are able to filter aspect application in any manner that you can interrogate your codebase using reflection.

Using Message Sources

If you plan to raise many messages, you may prefer to define your own MessageSource. A MessageSource is backed by a managed resource mapping error codes to error messages.

In order to create your own MessageSource, you should:

  1. Create an implementation of the IMessageDispenser. Typically, implement the GetMessage(String) method using a large switch statement. To each message will correspond a string

  2. Create a static instance of the MessageSource class for your message source.

    For instance, the following code defines a message source based on a message dispenser:

    C#
    Copy
    internal class ArchitectureMessageSource : MessageSource
{
    public static readonly ArchitectureMessageSource Instance = new ArchitectureMessageSource();

    private ArchitectureMessageSource() : base( "PostSharp.Architecture", new Dispenser() )
    {
    }

    private class Dispenser : MessageDispenser
    {
        public Dispenser() : base( "CUS" )
        {
        }

        protected override string GetMessage( int number)
        {
            switch ( number )
            {
                case 1:
                    return "Interface {0} cannot be implemented by {1} because of the [InternalImplement] constraint.";

                case 2:
                    return "{0} {1} cannot be referenced from {2} {3} because of the [ComponentInternal] constraint.";

                case 3:
                    return "Cannot use [ComponentInternal] on {0} {1} because the {0} is not internal.";

                case 4:
                    return "Cannot use [Internal] on {0} {1} because the {0} is not public.";

                default:
                    return null;
            }
        }
    }
}

  3. Then you can use a convenient set of methods on your MessageSource object:

    C#
    Copy
    MyMessageSource.Instance.Write( classType, SeverityType.Error, "CUS001", new object[] { interfaceType, classType } );
Note Note

You can also emit information and warning messages.

Tip Tip

Use ReflectionSearch to perform complex queries over System.Reflection.

Validating Attributes That Are Not Aspects

You can validate any attribute derived from Attribute by implementing the interface IValidableAnnotation.

Examples

Example: Dispatching a Method Execution to the GUI Thread

See Also

Reference

MethodLevelAspectCompileTimeValidate(MethodBase)
TypeLevelAspectCompileTimeValidate(Type)
FieldLevelAspectCompileTimeValidate(FieldInfo)
LocationLevelAspectCompileTimeValidate(LocationInfo)
EventLevelAspectCompileTimeValidate(EventInfo)
AssemblyLevelAspectCompileTimeValidate(Assembly)
IValidableAnnotation
MessageSource
Message
Message.Write


Developing Composite Aspects

Developing Composite Aspects

PostSharp offers two approaches to aspect-oriented development. The first, as explained in section Developing Simple Aspects, is very similar to object-oriented programming. It requires the aspect developer to override virtual methods or implement interfaces. This approach is very efficient for simple problems.

One way to grow in complexity with the first approach is to use the interface IAspectProvider (see Adding Aspects Dynamically). However, even this technique has its limitations.

This chapter documents the second approach, closer to the classic paradigm of aspect-oriented programming introduced by AspectJ. This approach allows developers to implement more complex design patterns using aspects. We call aspects developed with this approach composite aspects, because they are freely composed of different elements named advices and pointcuts.

An advice is anything that adds a behavior or a structural element to an element of code. For instance, introducing a method into a class, intercepting a property setter, or catching exceptions, are advices.

A pointcut is a function returning a set of elements of code to which advices apply. For instance, a function returning the set of properties annotated with the custom attribute DataMember is a pointcut.

Classes supporting advices and pointcuts are available in the namespace PostSharp.Aspects.Advices.

A composite aspect generally generally derives from a class that does not define its own advices: AssemblyLevelAspect, TypeLevelAspect, InstanceLevelAspect, MethodLevelAspect, LocationLevelAspect or EventLevelAspect. As such, these aspects have no functionality. You can add functionalities by adding advices to the aspect.

Advices are covered in the following sections:

Section | Description
Adding Behaviors to Existing Members | Advices with equivalent functionality as OnMethodBoundaryAspect, MethodInterceptionAspect, LocationInterceptionAspect, and EventInterceptionAspect.
Introducing Interfaces, Methods, Properties and Events | Make the aspect introduce an interface into the target class. The interface is implemented by the aspect itself.
Accessing Members of the Target Class | Make the aspect introduce a new method, property or event into the target class. The new member is implemented by the aspect itself. Conversely, the aspect can import a member of the target so that it can invoke it through a delegate.


Adding Behaviors to Existing Members

Adding Behaviors to Existing Members

In order to add new behaviors to (i.e. modify) existing members (methods, fields, properties, or events), two questions must be addressed:

  • What transformation should be performed? The answer lays in the advice. This advice is a method of your advice, annotated with a custom attribute determining in which situation the method should be invoked. You can freely choose the name of the method, but its signature must match the one expected by the advice type.

  • Where should it be performed, i.e. on which elements on code? The answer lays in the pointcut, another custom attribute expected on the method providing the transformation.

This topic contains the following sections.

  • How to Add a Behavior to an Existing Member
  • Advice Kinds
  • Pointcuts Kinds
  • Grouping Advices
How to Add a Behavior to an Existing Member

  1. Start with an empty aspect class deriving AssemblyLevelAspect, TypeLevelAspect, InstanceLevelAspect, MethodLevelAspect, LocationLevelAspect or EventLevelAspect. Mark it as serializable.

  2. Choose an advice type in the list below. For instance: OnMethodEntryAdvice.

  3. Create a method. The signature of this method should match exactly the signature matched by this advice type.

  4. Annotate this method with a custom attribute of the advice type you chose. For instance: [OnMethodEntryAdvice].

  5. Choose a pointcut type in the list below. For instance: SelfPointcut. Annotate the advice method with that custom attribute. For instance: [SelfPointcut].

Example

The following code shows a simple tracing aspect implemented with an advice and a pointcut. This aspect is exactly equivalent to a class derived from OnMethodBoundaryAspect where only the method OnEntry(MethodExecutionArgs) has been overwritten. The example is a method-level aspect and SelfPointcut means that the advice applies to the same target as the method itself.

C#
Copy
using System;
using PostSharp.Aspects;
using PostSharp.Aspects.Advices;

namespace Samples6
{
    [Serializable]
    public sealed class TraceAttribute : MethodLevelAspect
    {
        [OnMethodEntryAdvice, SelfPointcut]
        public void OnEntry(MethodExecutionArgs args)
        {
            Console.WriteLine("Entering {0}.{1}", args.Method.DeclaringType.Name, args.Method.Name);
        }
    }
}
Advice Kinds

The following table lists all types of advices that can transform existing members. Note that all these advices are available as a part of a simple aspect (for instance OnMethodEntryAdvice corresponds to OnMethodBoundaryAspectOnEntry(MethodExecutionArgs). For a complete documentation of the advice, see the documentation of the corresponding simple aspect.

Advice Type | Targets | Description
OnMethodEntryAdvice OnMethodSuccessAdvice OnMethodExceptionAdvice OnMethodExitAdvice | Methods | These advices are equivalent to the advices of the aspect OnMethodBoundaryAspect. The target method to be wrapped by a try/catch/finally construct.
OnMethodInvokeAdvice | Methods | This advice is equivalent to the aspect MethodInterceptionAspect. Calls to the target methods are replaced to calls to the advice.
OnLocationGetValueAdvice OnLocationSetValueAdvice | Fields, Properties | These advices are equivalent to the advices of the aspect LocationInterceptionAspect. Fields are changed into properties, and calls to the accessors are replaced to calls to the proper advice.
LocationValidationAdvice | Fields, Properties, Parameters | This advice is equivalent to the ValidateValue(T, String, LocationKind) LocationInterceptionAspect method of the ILocationValidationAspectT aspect interface. It validates values assigned to their targets and throws an exception in case of error.
OnEventAddHandlerAdvice OnEventRemoveHandlerAdvice OnEventInvokeHandlerAdvice | Events | These advices are equivalent to the advices of the aspect EventInterceptionAspect. Calls to add and remove semantics are replaced by calls to advices. When the event is fired, the OnEventInvokeHandler is invoked for each handler, instead of the handler itself.
Pointcuts Kinds

Pointcuts determine where the transformation provided by the advice should be applied.

From a logical point of view, pointcuts are functions that return a set of code elements. A pointcut can only select elements of code that are inside the target of the aspect itself. For instance, if an aspect has been applied to a class A, the pointcut can select the class A itself, members of A, but different classes or members of different classes.

Multicast Pointcut

The pointcut type MulticastPointcut allows to express a pointcut in a purely declarative way, using a single custom attribute. It works in a very similar way as MulticastAttribute (see Adding Aspects Declaratively Using Attributes) the kind of code elements being selected, their name and attributes can be filtered using properties of this custom attribute.

For instance, the following code applies the OnPropertySet advice to all non-abstract properties of the class to which the aspect has been applied.

C#
Copy
 [OnLocationSetValueAdvice,
 MulticastPointcut( Targets = MulticastTargets.Property,
                    Attributes = MulticastAttributes.Instance | MulticastAttributes.NonAbstract)]
public void OnPropertySet( LocationInterceptionArgs args )
{
  // Details skipped.
}

Method Pointcut

The pointcut type MethodPointcut allows to express a pointcut imperatively, using a C# or VB method. The argument of the custom attribute should contain the name of the method implementing the pointcut.

The only parameter of this method should be type-compatible with the kind of elements of code to which the aspect applies. The return value of the pointcut method should be a collection (IEnumerable) of objects that are type-compatible with the kind of elements of code to which the advice applies.

For instance, the following code applies the OnPropertySet advice to all writable properties that are not annotated with the IgnorePropertyChanged custom attribute.

C#
Copy
private IEnumerable<PropertyInfo> SelectProperties( Type type )
{
    const BindingFlags bindingFlags = BindingFlags.Instance |
        BindingFlags.DeclaredOnly | BindingFlags.Public;

    return from property
               in type.GetProperties( bindingFlags )
           where property.CanWrite && !property.IsDefined(typeof(IgnorePropertyChanged))
           select property;
}

[OnLocationSetValueAdvice, MethodPointcut( "SelectProperties" )]
public void OnPropertySet( LocationInterceptionArgs args )
{
    // Details skipped.
}

As you can see in this example, pointcut methods can use the power of LINQ to query System.Reflection.

Self Pointcut

The pointcut type SelfPointcut simply selects the target of the aspect.

Grouping Advices

The table of above shows advice types grouped in families. Advices of different type but of the same family can be grouped into a single logical filter, so they are considered as single transformation.

Why Grouping Advices

Consider for instance three advices of the family OnMethodBoundaryAspect: OnMethodEntryAdvice, OnMethodSuccessAdvice and OnMethodExceptionAdvice. The way how they are ordered is important, as it results in different generation of try/catch/finally block.

The following table compares advice ordering strategies. In the left column, advices are executed in the order: OnEntry, OnExit, OnException. In the right column, advices are grouped together.

C#
Copy
 void Method()
{
  try
  {
    OnEntry();

    try
    {
      // Original method body.
    }
    finally
    {
      OnExit();
    }
  }
  catch
  {
     OnException();
     throw;
  }
}
C#
Copy
 void Method()
{
  OnEntry();

  try
  {
      // Original method body.
  }
  catch
  {
     OnException();
     throw;
  }
  finally
  {
      OnExit();
  }
}

The code in the left column may make sense in some situations, but it is not consistent with the code generated by OnMethodBoundaryAspect. Note that the advices may have been ordered differently: the order OnEntry, OnException, OnExit would have generated the same code as in the right column. However, you would have had to use custom attributes to specify order relationships between advices (see Ordering Advices). Grouping advices is a much easier way to ensure consistency.

Additionally, when advices of the OnMethodBoundaryAspect family are grouped together, it will be possible to share information among them using MethodExecutionTag.

The reasons to group advices of the family LocationInterceptionAspect and EventInterceptionAspect are similar: advices grouped together behave consistently as a single filter (see Understanding Interception Aspects).

How to Group Advices

To group several advices into a single filter:

  1. Choose a master advice. The choice of the master advice is arbitrary. All other advices of the group are called slave advices.

  2. Annotate the master advice method with one advice custom attribute (see Available Advices and one pointcut custom attribute (see Available Pointcuts), as usually.

  3. Annotate all slave advices with one advice custom attribute. Set the property Master of the custom attribute to the name of the master advice method.

  4. Do not specify any pointcut on slave advice methods.

The following code shows how two advices of type OnMethodEntryAdvice and OnMethodExitAdvice can be grouped into a single filter:

C#
Copy
[OnMethodEntryAdvice, MulticastPointcut]
public void OnEntry(MethodExecutionArgs args)
{
}

[OnMethodExitAdvice(Master="OnEntry")]
public void OnExit(MethodExecutionArgs args)
{
}
See Also

Reference

PostSharp.Aspects.Advices

Other Resources

Ordering Advices
Understanding Interception Aspects


Introducing Interfaces, Methods, Properties and Events into Existing Classes

Introducing Interfaces, Methods, Properties and Events into Existing Classes

Some design patterns require you to add properties, methods or interfaces to your target code. If many components in your codebase need to represent the same construct, repetitively adding those constructs flies in the face of the DRY (Don't Repeat Yourself) principle. So how can you add code constructs to your target code without it becoming repetitive?

PostSharp offers a number of ways for you to add different code constructs to your codebase in a controlled and consistent manner. Let's take a look at those techniques.

This topic contains the following sections.

  • Introducing interfaces
  • Introducing methods
  • Introducing properties
  • Controlling the visibility of introduced members
  • Overriding members or interfaces
Introducing interfaces

One of the common situations that you will encounter is the need to implement a specific interface on a large number of classes. This may be INotifyPropertyChanged, IDisposable, IEquatable or some custom interface that you have created. If the implementation of the interface is consistent across all of the targets then there is no reason that we shouldn't centralize its implementation. So how do we go about adding that interface to a class at compile time?

  1. Let's add the IIdentifiable interface to the target code.

    C#
    Copy
     public interface IIdentifiable
{
    Guid Id { get; }
}

  2. Create an aspect that inherits from InstanceLevelAspect and add the custom attribute [SerializableAttribute].

    Note Note

    Use [PSerializableAttribute] instead of [SerializableAttribute] if your project targets Silverlight, Windows Phone, Windows Store, or runs with partial trust.

  3. The key to adding an interface to target code is that you must implement that interface on your aspect. Let's implement the IIdentifiable interface on our aspect. It's this implementation of the interface that will be added to the target code, so anything that you include in method or property bodies will be added to the target code as you have declared it in the aspect.

    C#
    Copy
    [Serializable]
public class IdentifiableAspect : InstanceLevelAspect, IIdentifiable
{
    public Guid Id { get; private set; }
}

  4. Add the IntroduceInterfaceAttribute attribute to the aspect and include the interface type that you want to add to the target code.

    C#
    Copy
    [IntroduceInterface(typeof(IIdentifiable))]
[Serializable]
public class IdentifiableAspect : InstanceLevelAspect, IIdentifiable
{
    public Guid Id { get; private set; }
}

  5. Finally you need to declare where this aspect should be applied to the codebase. In this example let's add it, as an attribute, to a class.

    C#
    Copy
    [IdentifiableAspect]
public class Customer
{
    public string Name { get; set; }
    public string Address { get; set; }
}

  6. After compilation you can decompile the target code and see that the interface has been added to it.

As you can see in the decompiled code, interfaces are implemented explicitly on the target code. It is also possible to introduce public members to target code. This is covered below.

Note Note

Interfaces and members introduced by PostSharp are not visible at compile time. To access the dynamically applied interface you must make use of a special PostSharp feature; the CastSourceType, TargetType(SourceType) pseudo-operator. The CastSourceType, TargetType(SourceType) method will allow you to safely cast the target code to the interface type that was dynamically applied. Once that call has been done, you are able to make use of the instance through the interface constructs.

There is no way to access a dynamically-inserted method, property or event, other than through reflection or the dynamic keyword.

Note Note

When you start adding code constructs to your target code, you need to determine how to initialize them correctly. Because these code construct are not available for you to work with at compile time you need to figure out how to deal with them some other way. To see more about initializing code constructs that you introduce via aspects, please see the section Initializing Aspects.

Introducing methods

The introduction of methods to your target code is very similar to introducing interfaces. The biggest difference is that you will be introducing code at a much more granular level.

  1. Create an aspect that inherits from InstanceLevelAspect and add the custom attribute [SerializableAttribute].

  2. Add to the aspect the method you want to introduce to the target code.

    C#
    Copy
    [Serializable]
public class OurCustomAspect : InstanceLevelAspect
{
    public void TheMethodYouWantToUse(string aValue)
    {
        Console.WriteLine("Inside a method that was introduced {0}", aValue);
    }
}
    Note Note

    The method that you declare must be marked as public. If it is not you will see an error at compile time.

  3. Decorate the method with the IntroduceMemberAttribute attribute.

    C#
    Copy
    [IntroduceMember]
public void TheMethodYouWantToUse(string aValue)
{
    Console.WriteLine("Inside a method that was introduced {0}", aValue);
}

  4. Finally, declare where you want this aspect to be applied in the codebase.

    C#
    Copy
    [OurCustomAspect]
public class Customer
{
    public string Name { get; set; }
}

  5. After compilation you can decompile the target code and see that the method has been added.

    Introducing Method decompile
Introducing properties

The introduction of properties is almost exactly the same as the introduction of methods. Like introducing a method you will use the IntroduceMemberAttribute attribute. Let's take a look at the details.

  1. Create an aspect that inherits from InstanceLevelAspect and add the custom attribute [SerializableAttribute].

  2. Add the property you want to introduce to the aspect.

    C#
    Copy
    [Serializable]
public class OurCustomAspect : InstanceLevelAspect
{
    public string Name { get; set; }
}
    Note Note

    The property that you declare must be marked as public. If it is not you will see a compiler error.

  3. Decorate the property with the IntroduceMemberAttribute attribute.

    C#
    Copy
    [IntroduceMember]
public string Name { get; set; }

  4. Add the aspect attribute to the target code where the aspect should be applied.

    C#
    Copy
    [OurCustomAspect]
public class Customer
{

}

  5. After you have compiled the codebase you can decompile the target code and see that the property has been added.

    Introducing Property decompile

As noted for both the introduction of methods and properties, the code being introduced must be declared as public. This is needed to ensure that PostSharp can function. If you look closely at the decompiled targets you will see that the introduced members are actually calling the methods/properties that were declared on the aspect. If the method/property on the aspect is not public, the target code will not be able to call it as it should.

Note Note

It is possible to introduce properties to target code, but it is not possible to introduce fields to your target code. The reason is that all members are introduced by delegation: the actual implementation of the member always resides in the aspect.

Controlling the visibility of introduced members

You may not want the introduced member to have public visibility once it has been introduced to the target code. PostSharp allows you to control the visibility of the introduced member through the use of the Visibility property on the aspect. To declare that a member should be introduced with private visibility, all you have to do is declare it as such.

C#
Copy
[IntroduceMember(Visibility = Visibility.Private)]
public string Name { get; set; }

You have the ability to introduce members with a number of different visibilities including public, private, assembly (internal in C#) and others. You also have the ability to mark an introduction so that it will be declared as virtual if you set the IsVirtual property to true.

C#
Copy
[IntroduceMember(Visibility = Visibility.Private, IsVirtual = true)]
public string Name { get; set; }
Overriding members or interfaces

One thing you need to be aware of is the situation where you are introducing a member that may already exist in the scope of the target code. Perhaps the method you are trying to introduce is available on the target code through inheritance. It's possible that the method is explicity declared on the target code as well. The introduction of a member via an aspect needs to take these situations into account. PostSharp allows you to take these situations into account through the use of the OverrideAction property.

The OverrideAction property allows you to declare a rule for how the introduction of a member or interface should behave if the member or interface is already implemented on the target code. This property allows you to declare rules such as Fail (any conflict situation will throw a compile time error), Ignore (continue on without trying to introduce the member/interface), OverrideOrFail or OverrideOrIgnore. It's important to understand how you want to apply your introduced members/interfaces in situations where that member/interface may already exist.

C#
Copy
[IntroduceMember(OverrideAction = MemberOverrideAction.Fail)]
public string Name { get; set; }
See Also

Reference

CreateImplementationObject(AdviceArgs)
CompositionAspect
CastSourceType, TargetType(SourceType)
INotifyPropertyChanged
IDisposable
InstanceLevelAspect
PSerializableAttribute
SerializableAttribute
IntroduceInterfaceAttribute
IntroduceMemberAttribute
Visibility
IsVirtual
OverrideAction
Fail
Ignore
OverrideOrFail
OverrideOrIgnore
GetPublicInterfaces(Type)
CreateImplementationObject(AdviceArgs)
CreateInstance(Type, ActivatorSecurityToken)


Accessing Members of the Target Class

Accessing Members of the Target Class

PostSharp makes it possible to import a delegate of a target class method, property or event into the aspect class, so that the aspect can invoke this member.

These mechanisms allow developers to encapsulate more design patterns using aspects.

This topic contains the following sections.

  • Importing Members of the Target Class
  • Interactions Between Several Member Introductions and Imports
  • Examples
Importing Members of the Target Class

Importing a member into an aspect allows this aspect to invoke the member. An aspect can import methods, properties, or fields.

To import a member of the target type into the aspect class:

  1. Define a field into the aspect class, of the following type:

    Member Kind

    Field Type

    Method

    A typed Delegate, typically one of the variants of Action or FuncTResult. The delegate signature should exactly match the signature of the imported method.

    Property

    PropertyTValue, where the generic argument is the type of the property.

    Collection Indexer

    PropertyTValue, TIndex, where the first generic argument is the type of the property value and the second is the type of the index parameter. Indexers with more than one parameter are not supported.

    Event

    EventTDelegate, where the generic argument is the type of the event delegate (for instance EventHandler).

  2. Make this field public. The field cannot be static.

  3. Add the custom attribute ImportMemberAttribute to the field. As the constructor argument, pass the name of the member to be imported.

At runtime, the field is set to a delegate of the imported member. Properties and events are imported as set of delegates (PropertyTValueGet, PropertyTValueSet; EventTDelegateAdd, EventTDelegateRemove). These delegates can be invoked by the aspect as any delegate.

The property ImportMemberAttributeIsRequired determines what happens if the member could not be found in the target class or in its parent. By default, the field will simply have the null value if it could not be bound to a member. If the property IsRequired is set to true, a compile-time error will be emitted.

Interactions Between Several Member Introductions and Imports

Although member introduction and import may seem simple advices at first sight, things become more complex when the several advices try to introduce or import the same member. PostSharp handles these situations in a robust and predictable way. For this purpose, it is primordial to process classes, aspects and advices in a consistent order.

PostSharp enforces the following order:

  1. Base classes are processed first, derived classes after. Therefore, when a class is being processed, all parent classes have already been fully processed.

  2. Aspects targeting the same class are sorted (see Coping with Several Aspects on the Same Target) and executed.

  3. Advices of the same aspect are sorted and executed in the following order:

    1. Member imports which have the property ImportMemberAttributeOrder set to BeforeIntroductions.

    2. Member introductions.

    3. Members imports which have the property ImportMemberAttributeOrder set to AfterIntroductions (this is the default value).

Based on this well-defined order, the advices behave as follow:

Advice

Precondition

Behavior

ImportMemberAttribute

No member, or private member defined in a parent class.

Error if ImportMemberAttributeIsRequired is true, ignored otherwise (by default).

Non-virtual member defined.

Member imported.

Virtual member defined.

If ImportMemberAttributeOrder is BeforeIntroductions, the overridden member is imported. This similar to calling a method with the base prefix in C#. Otherwise (and by default), the member is dynamically resolved using the virtual table of the target object.

IntroduceMemberAttribute

No member, or private member defined in a parent class.

Member introduced.

Non-virtual member defined in a parent class

Ignored if the property IntroduceMemberAttributeOverrideAction is Ignore or OverrideOrIgnore, otherwise fail (by default).

Virtual member defined in a parent class

Introduce a new override method if the property IntroduceMemberAttributeOverrideAction is OverrideOrFail or OverrideOrIgnore, ignore if the property is Ignore, otherwise fail (by default).

Member defined in the target class (virtual or not)

Fail by default or if the property IntroduceMemberAttributeOverrideAction is Fail.

Otherwise:

  1. Move the previous method body to a new method so that the previous implementation can be imported by advices ImportMemberAttribute with the property Order set to BeforeIntroductions.

  2. Override the method with the imported method.

Examples

Example: Raising an Event When the Object is Finalized

See Also

Reference

IntroduceMemberAttribute
ImportMemberAttribute

Other Resources

Coping with Several Aspects on the Same Target


Adding Aspects Dynamically

Adding Aspects Dynamically

Additionally to providing advices, an aspect can provide other aspects dynamically using IAspectProvider. This allows aspect developers to address situations where it is not possible to add aspects declaratively (using custom attributes) to the source code; aspects can be provided on the basis of a complex analysis of the target assembly using System.Reflection, or by reading an XML file, for instance.

For details about IAspectProvider, see Adding Aspects Programmatically using IAspectProvider.

See Also

Reference

IAspectProvider

Other Resources

Example: Automatically Adding DataContract and DataMember Attributes
Adding Aspects Programmatically using IAspectProvider


Coping with Several Aspects on the Same Target

Coping with Several Aspects on the Same Target

As the team learns aspect-oriented programming and starts adding more aspect to projects, chances raise that several aspects are added to the same element of code. This could be a major source of troubles if PostSharp did not provide a robust framework to detect and prevent conflicts between aspects:

  • Most aspects need to be ordered. For instance, an authorization aspect must be executed before a caching aspect.

  • Even if some aspects don't care to be ordered, it's good to have them applied in predictable order. Otherwise, some code that works today may be broken tomorrow -- just because aspects were applied in a different order.

  • Some aspects conflict; they cannot be together on the same aspect, or not in a given order. For instance, it does not make sense to persist an object using two different aspects: one would persist to the database, the other to the registry.

  • Some aspects require other aspects to be applied. For instance, an aspect changing the mouse pointer to an hourglass requires the method to execute asynchronously, otherwise the pointer shape will never be updated.

PostSharp addresses these issues by making it possible to add dependencies between aspects. The aspect dependency framework is implemented in the namespace PostSharp.Aspects.Dependencies.

Note Note

The aspect dependency framework is not related to the notion of dependency injection.

Aspect Dependency Custom Attributes

You can express dependencies of an aspect by annotating the aspect class with custom attributes derived from the type AspectDependencyAttribute. Several derived types are available; every type matches other aspects according to different criteria.

Types of Aspect Dependency Custom Attributes
Attribute Type | Description
AspectTypeDependencyAttribute | This custom attribute expresses a dependency with a well-known aspect class.
AspectRoleDependencyAttribute | This custom attribute expresses a dependency with any aspect classes enrolled in a given role. Its dual is ProvideAspectRoleAttribute: this custom attribute enrolls an aspect class into a role. A role is simply a string. Whenever possible, consider using one of the roles defined in the class StandardRoles.
AspectEffectDependencyAttribute | This custom attribute expresses a dependency with any aspect that has a specific effect on the source code or the control flow. Effects are represented as a string, whose valid values are listed in the type StandardEffects. Effects are provisioned by the aspect weaver on the basis of a rough analysis of what the aspect may do; aspect developers cannot assign new effects to aspects. However, they can waive effects by using the custom attribute WaiveAspectEffectAttribute. For instance, an aspect developer can specify that a trace attribute has no effect at all; this aspect will commute with any other aspect (see below).

Every of these custom attributes have similar structure and members. The first parameter of their constructor, of type AspectDependencyAction, determines the kind of dependency relationship added between the current aspect and the aspects matched by the custom attribute.

PostSharp supports the following kinds of relationships:

Kinds of Aspect Dependency Relationships
Action | Description
Order | The dependency expresses an order relationship. The second constructor of the custom attribute, of type AspectDependencyPosition (with values Before or After), must be specified. The custom attributes determine the position of the current aspect with respect to matched aspects.
Require | The dependency expresses a requirement. PostSharp will issue a compile-time error if the requirement is not satisfied for any target of the current aspect. The second constructor of the custom attribute, of type AspectDependencyPosition, is optional. If specified, an aspect matching the dependency should be present before or after the current aspect.
Conflict | The dependency expresses a conflict. PostSharp will issue a compile-time error if any aspect matching the dependency rule is present on any target of the current aspect. The second constructor of the custom attribute, of type AspectDependencyPosition, is optional. If specified, an error is issued only if a matching aspect is present before or after the current aspect.
Commute | The dependency specifies that the current aspect is commutable with any matching aspect. When aspects are commutable, PostSharp does not issue any warning if they are not strongly ordered.

Custom attribute types and values of the enumeration AspectDependencyAction are orthogonal; they can be freely combined.

Examples

Using role-based dependencies

The following code shows how three aspects can be ordered without having explicit knowledge of each other. Each aspect provides a different role, and defines dependencies with respect to other roles.

C#
Copy
[ProvideAspectRole( StandardRoles.Threading )]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.Before, "UI")]
public sealed class AsyncAttribute : MethodInterceptionAspect
{
  // Details skipped
}

[ProvideAspectRole( StandardRoles.ExceptionHandling )]
[AspectRoleDependency( AspectDependencyAction.Order, AspectDependencyPosition.After, StandardRoles.Threading )]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, "UI")]
public sealed class ExceptionDialogAttribute : OnExceptionAspect
{
  // Details skipped
}

[ProvideAspectRole("UI")]
public sealed class StatusTextAttribute : OnMethodBoundaryAspect
{
  // Details skipped
}

Using effect-based dependencies

The following code shows how to protect an authorization aspect to be executed after an aspect which may change the control flow and skipping the execution of the method, such as a caching aspect. Then, it shows how the aspectAsyncAttribute can opt out from this effect, because the aspect developer knows that does aspect does not skip the execution of the method, but only defers it.

C#
Copy
[AspectEffectDependency( AspectDependencyAction.Conflict, AspectDependencyPosition.Before,
                         StandardEffects.ChangeControlFlow )]
public sealed class AuthorizationAttribute : OnMethodBoundaryAspect
{
  // Details skipped.
}

 [WaiveAspectEffect(StandardEffects.ChangeControlFlow)]
 public sealed class AsyncAttribute : MethodInterceptionAspect
 {
   // Details skipped
 }
Deferring Ordering to Aspect Users

By adding dependencies to the aspect class, the aspect developer specifies the order of execution of aspects in a fully static way. The same order is used for every element of code to which aspects apply. While this behavior is most of time desirable, there may be situations where we want to defer ordering to users of our aspects.

Aspect users can influence the order of execution of an aspect by setting the aspect property AspectPriority, typically when using the aspect custom attribute (the same property is available in the configuration object as AspectConfigurationAspectPriority, see Configuring Aspects).

Setting the AspectPriority results to an aspect in adding an ordering dependency between this aspect and all other aspects where the same property has been set. Therefore, aspect priorities complement, and do not replace, other ordering dependencies. The aspect developer may specify vital aspect dependencies (that is, under-specify aspect ordering), and let it to the aspect user to complete the ordering with priorities.

Caution note Caution

Do not confuse the property AspectPriority with AttributePriority. The latter determines an order in which several custom attributes of the same type are processed by the MulticastAttribute engine. The first determines in which order the aspects are executed at run time.

Adding Dependencies to Third-Party Aspects

If you are using aspects provided by several third-party vendors who don't know about each other, you may need to solve conflicts on your own.

You can do that by adding any custom attribute derived from AspectDependencyAttribute at assembly level, and use the property TargetType to specify to which aspect class the dependency applies.

Here is an example:

C#
Copy
[assembly: AspectTypeDependency( AspectDependencyAction.Order, AspectDependencyPosition.Before,
                                 typeof(Vendor1.TraceAspect), TargetType = typeof(Vendor2.ExceptionHandlingAspect) ]
See Also

Reference

PostSharp.Aspects.Dependencies


Ordering Advices

Ordering Advices

The section Coping with Several Aspects on the Same Target talks in terms of aspect dependencies and aspect ordering. Most of what has been said there is also valid to advices. When we talk of the order of execution of aspects, we actually mean the execution of advices ("aspects" themselves, stricto sensu, are never executed).

Dependencies defined at aspect level implicitly apply to all advices. When developing a composite aspect (see Developing Composite Aspects), it is possible to add dependencies directly to advice methods by annotating them with custom attributes of the namespace PostSharp.Aspects.Dependencies.

Note that all advices provided by an aspect are ordered in a single block. Suppose that a method is the target of advices Aspect1.MethodA, Aspect1.MethodB and Aspect2.MethodC. The next table shows valid and invalid orders:

Valid Orders | Invalid Orders
Aspect1.MethodA, Aspect1.MethodB, Aspect2.MethodC | Aspect1.MethodA, Aspect2.MethodC, Aspect1.MethodB
Aspect1.MethodB, Aspect1.MethodA, Aspect2.MethodC | Aspect1.MethodB, Aspect2.MethodC, Aspect1.MethodA
Aspect2.MethodC, Aspect1.MethodA, Aspect1.MethodB |
Aspect2.MethodC, Aspect1.MethodB, Aspect1.MethodA |
Ordering Advices of the Same Aspect

Advices of the same aspect can be used using any custom attribute derived from AspectDependencyAttribute.

Because advices of the same aspect instance are necessarily ordered in block, it is appropriate to specify dependencies between aspect classes extensively, and specify ordering of advices only in the scope of the current aspect instance. The most appropriate dependency custom attribute for this purpose is AdviceDependencyAttribute, which accepts the name of the advice method as a parameter.

See Also

Reference

AdviceDependencyAttribute


Understanding Interception Aspects

Understanding Interception Aspects

Aspect types MethodInterceptionAspect, LocationInterceptionAspect and EventInterceptionAspect are all based on the same principle: the aspect is invoked instead of the enhanced semantic. The aspect gets access to the intercepted semantic through methods prefixed by Proceed, or by other methods.

Things become more complex when several interception aspects are applied to the same element of code. Consider a method enhanced by three aspects A, B and C. When aspect A calls the method Proceed, it will actually invoke the method OnInvoke(MethodInterceptionArgs) of aspect B. Similarly, aspect B will invoke aspect C, and aspect C will eventually invoke the original method.

Chains of Invocation

Interception aspects form a chain on invocation where every aspect instance is a node in the chain, and the intercepted member is the last node.

An interception aspect can only invoke the next node in the chain. There is no way an aspect can invoke another node, or can access directly the intercepted member. This design ensures that aspects behave in a robust and consistent way in all situations.

Aspect types LocationInterceptionAspect and EventInterceptionAspect have several semantics (Get and Set for LocationInterceptionAspect; Add, Remove and Invoke for EventInterceptionAspect). All advices of the same aspect instance (one advice per semantic) logically belong to the same node in the chain of invocation. Therefore, when the implementation of the advice LocationInterceptionAspectOnSetValue(LocationInterceptionArgs) invokes the method LocationInterceptionArgsGetCurrentValue, it actually invokes the Get semantic of the next node in the chain. If the aspect had used PropertyInfoGetValue(Object) to get the value (as was usual in PostSharp 1.0), it would have invoked the first node in the chain!

Aspects as Filters: a Disciplined Approach to Aspect-Oriented Programming

In its early days, aspect-oriented programming (AOP) has been perceived as a dangerous technology. Aspects allowed to do anything with a program. Although AOP has been designed to improve the readability and maintainability of source code, it could actually have the opposite effect.

As goes the saying, with a sharp tool, one must pay greater attention.

PostSharp was designed to respect one of the most fundamental principles of software engineering: encapsulation. Encapsulation means the condition of being enclosed, as in a capsule. In object-oriented programming, the primary capsule is the class itself. Outside code communicates with the capsule through well-defined ports: public members. Outside code cannot modify what's inside the capsule. A well-designed capsule should check the validity of messages it receives or it sends - something called precondition and postcondition checking. The second level of encapsulation is the method: even inside a class, code should be designed so that the implementation of a method does not need to care about the implementation of another method.

Of course, it is possible to ignore the rules of encapsulation. But it would most probably result in poorly readable and maintainable code.

PostSharp actually allows you to break the first capsule: you can add advices to private members of a class. But it stops there: you cannot break the capsule of a method. Instead, you can enclose a method into a new capsule analog to a filter: the advice. When a method is enhanced by an advice, outside code seeking access to this method must go through its advice.

When a method is enhanced by several advices, every advice constitutes a filter that encloses not only the method, but all advices with lower priority.

Methods have a single semantic: Invoke. Properties, fields and events have many multiple semantics. These members can be considered as a single capsule, and their semantics as different ports in the capsule.

Note Note

Things can become more complex. Consider a property with a getter and a setter. The property is enhanced by an aspect of type LocationInterceptionAspect. The property setter is enhanced by a MethodInterceptionAspect with lower priority. From a logical point of view, the property is considered as a single capsule with two ports. The capsule is enclosed by two filters, one for each aspect. The aspect LocationInterceptionAspect filters both ports. However, MethodInterceptionAspect only filters the Set port. If the LocationInterceptionAspect invokes the Get semantic, it will be directed to the property getter, because there is no filter between the advice and the semantic. However, when the same aspect invokes the Set semantic, it will be directed to LocationInterceptionAspect as this filters lays in the way.

Note Note

The Invoke semantic of EventInterceptionAspect is executed in invert order. Indeed, the message originates inside the capsule is emitted outside. For all other semantics, the message always comes from outside and is directed to the capsule.

Aspect Bindings

When an advice is invoked, it receives an interface to the next node in the chain of invocation: an aspect binding. Every aspect type has its corresponding binding interface, exposed on a property of the advice argument object.

Aspect Type | Binding Interface | Exposed On
MethodInterceptionAspect | IMethodBinding | MethodInterceptionArgsBinding
LocationInterceptionAspect | ILocationBinding | LocationInterceptionArgsBinding
EventInterceptionAspect | IEventBinding | EventInterceptionArgsBinding

Binding objects are singletons. They are fully thread-safe and reentrant. They can be invoked in any situation. This contrasts with advice arguments, which may be shared among different advices and should not be used once the advice gave over control to the next node in the chain invocation.

Note Note

As objects of type Arguments may be shared among different advices, some of which may modify the arguments, it may be safe to clone the object before the advice gives over control.

Note Note

For run-time performance reasons, PostSharp does not access binding classes through their interface, but directly invokes their implementation. Implementation classes of binding interfaces are considered an implementation detail and should not be referred to from user code.

See Also

Reference

LocationInterceptionAspect
MethodInterceptionAspect
EventInterceptionAspect


Understanding Aspect Serialization

Understanding Aspect Serialization

As explained in section Understanding Aspect Lifetime and Scope, aspect are first instantiated at build time by the weaver, are then initialized by the CompileTimeInitialize method, and serialized and stored in the assembly as a managed resource. Aspects are then deserialized at runtime, before being executed.

Because of the aspect life cycle, aspect classes must be made serializable as described in this section.

This topic contains the following sections.

  • Default serialization strategy
  • Aspects without serialization
Default serialization strategy

Typically, aspects can be made serializable by adding a custom attribute to the class, which causes all fields of the class to be serialized. Fields that do not need to be serialized must be annotated with an opt-out custom attribute. PostSharp chooses the serialization strategy according these custom attributes. The serialization strategy is implemented in classes derived from the abstract class AspectSerializer according to the following table.

Target platform | Making the class serializable | Excluding fields | Aspect serializer
.NET Framework with full trust | SerializableAttribute | NonSerializedAttribute | BinaryAspectSerializer, backed by BinaryFormatter
Any platform | PSerializableAttribute | PNonSerializedAttribute | PortableAspectSerializer, backed by PortableFormatter
Aspects without serialization

In some situations, serializing and deserializing the aspect may be a suboptimal solution. In case aspect field values are a pure function of constructor arguments and properties, it may be more efficient to emit code that instantiates these aspects at runtime instead of serializing-deserializing them. This is the case, typically, if the aspect does not implement the CompileTimeInitialize method.

In this situation, it is better to use a different serializer: MsilAspectSerializer.

Note Note

MsilAspectSerializer is actually not a serializer. When you use this implementation instead of a real serializer, the aspect is not serialized, but the weaver generates MSIL instructions to build the aspect instance at runtime, by calling the aspect class constructor and by setting its fields and properties.

You can specify which serializer should be used for a specific aspect class by setting the property AspectConfigurationSerializerType of the configuration of this aspect class or instance.

See section Configuring Aspects for details.

The following code shows how to choose the serializer type for an OnMethodBoundaryAspect:

C#
Copy
[OnMethodBoundaryAspectConfiguration(SerializerType=typeof(MsilAspectSerializer))]
public sealed MyAspect : OnMethodBoundaryAspect
See Also

Reference

AspectSerializer
BinaryAspectSerializer
PortableAspectSerializer
MsilAspectSerializer
AspectConfigurationSerializerType

Other Resources

Configuring Aspects


Advanced

Advanced


Coping with Custom Object Serializers

Coping with Custom Object Serializers

Some aspects need to be initialized when a new instance of the class to which they are applied is created. For instance, instance-scoped aspect must be cloned from the prototype; members imported into the through ImportMemberAttribute must be bound to aspect fields.

PostSharp enhances every constructor of every enhanced class so that aspects are properly initialized.

However, it is possible to create new instances of classes by bypassing the constructor. This happens, for instance, when classes are deserialized by the BinaryFormatter or the DataContractSerializer. These formatters use the method FormatterServices.GetUnitializedObject(Type) to create new instances, but this method bypasses all constructors.

PostSharp implements a workaround for the deserializers BinaryFormatter and DataContractSerializer: it creates or modifies a method annotated by the custom attribute OnDeserializingAttribute, so that aspects are initialized properly.

However, if you are using a custom deserializer, or for any reason create instances using the method the method FormatterServices.GetUnitializedObject(Type), you will have to initialize aspects manually.

Initializing Aspects Manually

There are many possible ways to initialize an aspect from user code.

By Defining a Method InitializeAspects

You can define in your classes (typically in one of the root classes of your class hierarchy) a method with the following name and signature:

C#
Copy
protected virtual void InitializeAspects();

When PostSharp discovers this method, it will insert its own initialization logic at the beginning of the InitializeAspects method. The original logic is not deleted. This method can safely have an empty implementation.

The following constraints apply:

  • The method should be virtual unless the class is sealed.

  • The method should be protected or public, unless the class is internal.

For instance, the following class would enable aspects (applied on this class or on derived classes) to be initialized after deserialization (note that PostSharp automatically generates this code for BinaryFormatter and DataContractSerializer; you only need to do it manually for a custom serializer).

C#
Copy
[DataContract]
public abstract class BaseClass
{
  protected virtual void InitializeAspects()
  {
  }

  [OnDeserializing]
  private void OnDeserializingInitializeAspects()
  {
    this.InitializeAspects();
  }
}

By Invoking AspectUtilities.InitializeCurrentAspects

Instead of providing an empty method InitializeAspects, it is possible to invoke the method AspectUtilitiesInitializeCurrentAspects. A call to this method will be translated into a call to InitializeAspects. It has to be invoked from a non-static method of an enhanced class.

If the class from which InitializeCurrentAspects is invoked has not been enhanced by an aspect requiring initialization, the call to this method is simply ignored.

Note Note

Using this approach may be brittle in some situations: calls to InitializeCurrentAspects will have no effect if aspects are applied to derived classes, but not to the calling class. In this scenario, it is preferable to define the method InitializeAspects.


Configuring Aspects

Configuring Aspects

Configuration settings of aspects determine how they should be processed by their weaver. Configuration settings are always evaluated at build time. Most aspects have one or many of them. For instance, the aspect type OnExceptionAspect has a configuration setting determining the type of exceptions handled with this aspect.

There are two ways to configure an aspect: declarative and imperative.

Declarative Configuration

You can configure an aspect declaratively by applying the appropriate custom attribute on the aspect class. Aspect configuration attributes are in the namespace PostSharp.Aspects.Configuration. Every aspect type has its corresponding type of configuration attribute. The name of the custom attribute starts with the name of the aspect and has the suffix ConfigurationAttribute. For instance, the configuration attribute of the aspect class OnExceptionAspect is OnExceptionAspectConfigurationAttribute.

Declarative configuration has always precedence over imperative configuration: if some property of the configuration custom attribute is set on the aspect class, or on any parent, the corresponding imperative semantic will not be evaluated.

Once a configuration property has been set in a parent class, it cannot be overwritten in a child class.

Note that these restrictions are enforced at the level of properties. If a property of a configuration custom attribute is not set in a parent class, it can still be overwritten in a child class or by an imperative semantic.

Imperative Configuration

A second way to configure an aspect class is to override its configuration methods or set its configuration property.

Note Note

Imperative configuration is only available when you target the full .NET Framework. It is not available for Silverlight or the Compact Framework.

Benefits of Imperative Configuration

The advantage of imperative configuration is that it can be arbitrarily complex (since the code of the configuration method is executed inside the weaver). Specifically, it allows the configuration to be dependent on how the aspect is actually used, for instance the configuration can depend on the value of a property of the aspect custom attribute.

Implementation Note

Under the hood, aspects implement the method IAspectBuildSemanticsGetAspectConfiguration(Object). This method should return a configuration object, derived from the class AspectConfiguration. Every aspect class has its own aspect configuration class. For instance, the configuration attribute of the aspect class OnExceptionAspect is OnExceptionAspectConfiguration. The aspect type OnExceptionAspect implements IAspectBuildSemanticsGetAspectConfiguration(Object) by creating an instance of OnExceptionAspectConfiguration, then it invokes the method OnExceptionAspectGetExceptionType(MethodBase) and copies the return value of this method to the property OnExceptionAspectConfigurationExceptionType. Therefore, there are two ways to configure an aspect: either by overriding configuration methods and setting configuration properties (these methods and properties are provided by the framework for convenience only), or by implementing the method IAspectBuildSemanticsGetAspectConfiguration(Object). If your aspect does not derive from the aspect class OnExceptionAspect, but directly implements the aspect interface IOnExceptionAspect, you can use only the later method.


Examples

Examples


Example: Tracing Method Execution

Example: Tracing Method Execution

This code implements an aspect that writes a trace message before and after the execution of the methods to which the aspect is applied.

Requirements

PostSharp 2.0 Community Edition or higher

Demonstrates

The example demonstrates the use of OnMethodBoundaryAspect, and shows how to use RuntimeInitialize(MethodBase) to improve runtime performance.

Example
C#
Copy
using System;
using System.Diagnostics;
using System.Reflection;
using PostSharp.Aspects;

namespace Samples
{
    [Serializable]
    public sealed class TraceAttribute : OnMethodBoundaryAspect
    {
        // This field is initialized and serialized at build time, then deserialized at runtime.
        private readonly string category;

        // These fields are initialized at runtime. They do not need to be serialized.
        [NonSerialized] private string enteringMessage;
        [NonSerialized] private string exitingMessage;

        // Default constructor, invoked at build time.
        public TraceAttribute()
        {
        }

        // Constructor specifying the tracing category, invoked at build time.
        public TraceAttribute(string category)
        {
            this.category = category;
        }

        // Invoked only once at runtime from the static constructor of type declaring the target method.
        public override void RuntimeInitialize(MethodBase method)
        {
            string methodName = method.DeclaringType.FullName + method.Name;
            this.enteringMessage = "Entering " + methodName;
            this.exitingMessage = "Exiting " + methodName;
        }

        // Invoked at runtime before that target method is invoked.
        public override void OnEntry(MethodExecutionArgs args)
        {
            Trace.WriteLine(this.enteringMessage, this.category);
        }

        // Invoked at runtime after the target method is invoked (in a finally block).
        public override void OnExit(MethodExecutionArgs args)
        {
            Trace.WriteLine(this.exitingMessage, this.category);
        }
    }
}
Remarks

Note that fields enteringMessage and exitingMessage are initialized from method RuntimeInitialize. This method is invoked only once, before the aspect instance is used for the first time. It may have been possible to format the trace message from methods OnEntry and OnExit, but doing so would hurt performance for two reasons:

  1. Getting the reflection object (MethodBase) is rather expensive.

  2. Concatenating a string creates a new string instance, which causes an overhead to memory allocation and garbage collection.

The aspect results in instructions that can be inlined by the JIT/NGen compiler, which makes the aspect almost as fast as hand-written code.


Example: Handling Exceptions

Example: Handling Exceptions

This code is an aspect that handles exceptions by opening a message box. It is useful in WPF applications to handle specific exceptions, for instance of type IOException

Requirements

PostSharp 2.0 Community Edition or higher

Demonstrates

This example demonstrates the aspect type OnExceptionAspect.

Example
C#
Copy
using System;
using System.Reflection;
using System.Windows;
using PostSharp.Aspects;

namespace Samples
{
    [Serializable]
    public sealed class ExceptionDialogAttribute : OnExceptionAspect
    {
        // We don't need this field at runtime, so we don't serialize it.
        [NonSerialized] private readonly Type exceptionType;

        public ExceptionDialogAttribute() : this(null)
        {
        }

        public ExceptionDialogAttribute(Type exceptionType)
        {
            this.exceptionType = exceptionType;

            // Set the default value for the dialog box.
            this.Message = "{0}";
            this.Caption = "Error";
        }

        public string Message { get; set; }
        public string Caption { get; set; }

        // Method invoked at build time. Should return the type of exceptions to be handled.
        public override Type GetExceptionType(MethodBase method)
        {
            return this.exceptionType;
        }

        // Method invoked at run time.
        public override void OnException(MethodExecutionArgs args)
        {
            // Format the exception message.
            string message = string.Format(this.Message, args.Exception.Message);

            // Finds the parent window of the dialog box.
            DependencyObject dependencyObject = args.Instance as DependencyObject;
            Window window = null;
            if (dependencyObject != null)
            {
                window = Window.GetWindow(dependencyObject);
            }

            if (window != null)
            {
                // Display the error dialog with a parent window.
                MessageBox.Show(window, message, this.Caption, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                // Display the error dialog without a parent window.
                MessageBox.Show(message, this.Caption, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            // Do not rethrow the exception.
            args.FlowBehavior = FlowBehavior.Return;
        }
    }
}


Example: Caching the Result of a Method

Example: Caching the Result of a Method

The following class implements an aspect that caches the return value of methods to which it is applied.

Requirements

PostSharp 2.0 Community Edition or higher

Demonstrates

The example demonstrates the use of OnMethodBoundaryAspect, and shows how to use FlowBehavior to skip the execution of a method when its value is found in cache. The property MethodExecutionTag is used to store the cache key between the OnEntry and OnSuccess advices.

Example
C#
Copy
using System;
using System.Reflection;
using System.Text;
using System.Web;
using PostSharp.Aspects;

namespace Samples
{
    [Serializable]
    public sealed class CacheAttribute : OnMethodBoundaryAspect
    {
        // This field will be set by CompileTimeInitialize and serialized at build time,
        // then deserialized at runtime.
        private string methodName;

        // Method executed at build time.
        public override void CompileTimeInitialize(MethodBase method, AspectInfo aspectInfo)
        {
            this.methodName = method.DeclaringType.FullName + "." + method.Name;
        }

        private string GetCacheKey(object instance, Arguments arguments)
        {
            // If we have no argument, return just the method name so we don't uselessly allocate memory.
            if (instance == null && arguments.Count == 0)
                return this.methodName;

            // Add all arguments to the cache key. Note that generic arguments are not part of the cache
            // key, so method calls that differ only by generic arguments will have conflicting cache keys.
            StringBuilder stringBuilder = new StringBuilder(this.methodName);
            stringBuilder.Append('(');
            if (instance != null)
            {
                stringBuilder.Append(instance);
                stringBuilder.Append("; ");
            }

            for (int i = 0; i < arguments.Count; i++)
            {
                stringBuilder.Append(arguments.GetArgument(i) ?? "null");
                stringBuilder.Append(", ");
            }

            return stringBuilder.ToString();
        }

        // This method is executed before the execution of target methods of this aspect.
        public override void OnEntry(MethodExecutionArgs args)
        {
            // Compute the cache key.
            string cacheKey = GetCacheKey(args.Instance, args.Arguments);

            // Fetch the value from the cache.
            object value = HttpRuntime.Cache[cacheKey];

            if (value != null)
            {
                // The value was found in cache. Don't execute the method. Return immediately.
                args.ReturnValue = value;
                args.FlowBehavior = FlowBehavior.Return;
            }
            else
            {
                // The value was NOT found in cache. Continue with method execution, but store
                // the cache key so that we don't have to compute it in OnSuccess.
                args.MethodExecutionTag = cacheKey;
            }
        }

        // This method is executed upon successful completion of target methods of this aspect.
        public override void OnSuccess(MethodExecutionArgs args)
        {
            string cacheKey = (string) args.MethodExecutionTag;
            HttpRuntime.Cache[cacheKey] = args.ReturnValue;
        }
    }
}
Remarks

Note that the field methodName is initialized from method CompileTimeInitialize(MethodBase, AspectInfo). This method is invoked at build time, then the value of the field is serialized into the assembly. Thanks to this mechanism, no reflection is needed at runtime.

See Also

Reference

OnMethodBoundaryAspect
MethodExecutionArgsFlowBehavior
MethodLevelAspectCompileTimeInitialize(MethodBase, AspectInfo)


Example: Dispatching a Method Execution to the GUI Thread

Example: Dispatching a Method Execution to the GUI Thread

This code implements an aspect that causes methods to which it is applied to be invoked on the GUI thread. Indeed, properties and methods of WPF objects can be accessed only from the thread from which the object was created. Other threads must use the Dispatcher of this object to dispatch the invocation of the method to the GUI thread. The Asynchronous property of this aspect allows the developer to specify that the method should be invoked asynchronously; in this case, the current thread will not wait until completion of the intercepted method.

Requirements

PostSharp 2.0 Community Edition or higher

Demonstrates

This example demonstrates the use of MethodInterceptionAspect to intercept invocations of method. Additionally, it shows bow to use CompileTimeValidate(MethodBase) to check that the aspect has been applied on a valid method.

Example
C#
Copy
using System;
using System.Linq;
using System.Reflection;
using System.Windows.Threading;
using PostSharp.Aspects;
using PostSharp.Extensibility;

namespace Samples
{
    [Serializable]
    [MulticastAttributeUsage(MulticastTargets.Method, TargetMemberAttributes = MulticastAttributes.Instance)]
    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
    public class GuiThreadAttribute : MethodInterceptionAspect
    {
        public bool Asynchronous { get; set; }

        // Method invoked at build time. It validates that the aspect has been applied to an acceptable method.
        public override bool CompileTimeValidate(MethodBase method)
        {
            // The method must be in a type derived from DispatcherObject.
            if (!typeof (DispatcherObject).IsAssignableFrom(method.DeclaringType))
            {
                Message.Write(SeverityType.Error, "CUSTOM02",
                              "Cannot apply [GuiThread] to method {0} because it is not a member of a type " +
                              "derived from DispatcherObject.", method);
                return false;
            }

            // If the call is asynchronous, there should not be any return value or ByRef parameter.
            if (this.Asynchronous)
            {
                if (((MethodInfo) method).ReturnType == typeof (void) ||
                    method.GetParameters().Any(parameter => parameter.ParameterType.IsByRef))
                {
                    Message.Write(SeverityType.Error, "CUSTOM02",
                                  "Cannot apply [GuiThread(Asynchronous=true)] to method {0} because it is not a member " +
                                  "of a type derived from DispatcherObject.", method);
                    return false;
                }
            }

            return true;
        }

        // Method invoked at run time _instead_ of the intercepted method.
        public override void OnInvoke(MethodInterceptionArgs args)
        {
            // Get the graphic object.
            DispatcherObject dispatcherObject = (DispatcherObject) args.Instance;

            // Check whether the current thread has access to this object.
            if (dispatcherObject.CheckAccess())
            {
                // We have access. Proceed with invocation.
                args.Proceed();
            }
            else
            {
                // We don't have access. Invoke the method synchronously.
                if (this.Asynchronous)
                {
                    dispatcherObject.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(args.Proceed));
                }
                else
                {
                    dispatcherObject.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(args.Proceed));
                }
            }
        }
    }
}
See Also

Reference

MethodInterceptionAspect
CompileTimeValidate(MethodBase)


Example: Backing a Property with a Registry Value

Example: Backing a Property with a Registry Value

This code is an aspect that binds a field or a property with a registry value. The first time the field or property is read, its value is retrieved from registry. Whenever the field or property is written, its value is written to registry.

Requirements

PostSharp 2.0 Community Edition or higher

Demonstrates

This example illustrates the use of the aspect type LocationInterceptionAspect in a situation where the location getter invokes the setter. It shows how the aspect can implement IInstanceScopedAspect to get the same scope (static or instance) than the location to which it is applied; thanks to this, we can use an aspect field (fetchedFromRegistry) to store the information whether the value has already been fetched from registry.

Example
C#
Copy
using System;
using Microsoft.Win32;
using PostSharp.Aspects;

namespace Samples
{
    public sealed class RegistryValueAttribute : LocationInterceptionAspect, IInstanceScopedAspect
    {
        // True if the the value has already been fetched from registry and stored in the field or property.
        // It is not serialize since we don't need it at build time.
        [NonSerialized] private bool fetchedFromRegistry;

        public RegistryValueAttribute(string keyName, string valueName)
        {
            this.KeyName = keyName;
            this.ValueName = valueName;
        }

        public string KeyName { get; private set; }
        public string ValueName { get; private set; }
        public object DefaultValue { get; set; }

        // Invoked at runtime whenever someone gets the value of the field or property.
        public override void OnGetValue(LocationInterceptionArgs args)
        {
            if (!this.fetchedFromRegistry)
            {
                // We have not fetched the value from registry. Do it now.
                object value = Registry.GetValue(this.KeyName, this.ValueName, this.DefaultValue);

                // Store this value in the target field/property.
                args.SetNewValue(value);

                // Return this value (we don't even need to call the underlying getter).
                args.Value = value;
            }
            else
            {
                // The value is already stored in the field/property, so just call the
                // underlying getter.
                args.ProceedGetValue();
            }
        }

        // Invoked at runtime whenever someone gets the value of the field or property.
        public override void OnSetValue(LocationInterceptionArgs args)
        {
            // Store the new value in registry if it has changed.
            if (Equals(args.Value, args.GetCurrentValue()))
            {
                Registry.SetValue(this.KeyName, this.ValueName, args.Value);
            }

            // Call the underlying setter.
            base.OnSetValue(args);

            // Sets that the underlying field/property already stores the field.
            this.fetchedFromRegistry = true;
        }

        #region Implementation of IInstanceScopedAspect

        object IInstanceScopedAspect.CreateInstance(AdviceArgs adviceArgs)
        {
            return this.MemberwiseClone();
        }

        void IInstanceScopedAspect.RuntimeInitializeInstance()
        {
        }

        #endregion
    }
}
See Also

Reference

LocationInterceptionAspect
IInstanceScopedAspect


Example: Making an Event Asynchronous

Example: Making an Event Asynchronous

This code is an aspect making an event asynchronous. When an event enhanced with this aspect is fired, subscribed handlers are invoked asynchronously. Whenever a subscribed handler fails with an exception, it is removed from the list of subscribers of this event.

Requirements

PostSharp 2.0 Professional Edition or higher

Demonstrates

This example illustrates the use of the aspect type EventInterceptionAspect.

Example
C#
Copy
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using PostSharp.Aspects;

namespace Samples
{
    [Serializable]
    public sealed class AsyncEventAttribute : EventInterceptionAspect
    {
        public override void OnInvokeHandler(EventInterceptionArgs args)
        {
            // Invoke the event handler asynchronously.
            Task.Factory.StartNew(() => Invoke(args)).Start();
        }

        private static void Invoke(EventInterceptionArgs args)
        {
            try
            {
                // Invoke the event handler.
                args.ProceedInvokeHandler();
            }
            catch (Exception e)
            {
                // Remove the event handler if it failed.
                Trace.TraceError(e.ToString());
                args.ProceedRemoveHandler();
            }
        }
    }
}
See Also

Reference

EventInterceptionAspect


Example: Dynamically Introducing an Interface

Example: Dynamically Introducing an Interface

This aspect implement a very general way to compose types using a custom attribute. The custom attribute has two parameters: the type of the interface to be introduced, and the type of the class implementing the interface. This class should have a default constructor.

Requirements

PostSharp 2.0 Community Edition or higher

Demonstrates

This example demonstrates the use of CompositionAspect.

Example
C#
Copy
using System;
using System.Collections;
using PostSharp;
using PostSharp.Aspects;

namespace Samples
{
    [Serializable]
    public sealed class GeneralComposeAttribute : CompositionAspect
    {
        // We don't need this field at runtime, so we mark it as non-serialized.
        [NonSerialized] private readonly Type interfaceType;

        private readonly Type implementationType;

        public GeneralComposeAttribute(Type interfaceType, Type implementationType)
        {
            this.interfaceType = interfaceType;
            this.implementationType = implementationType;
        }

        // Invoked at build time. We return the interface we want to implement.
        protected override Type[] GetPublicInterfaces(Type targetType)
        {
            return new[] {this.interfaceType};
        }

        // Invoked at run time.
        public override object CreateImplementationObject(AdviceArgs args)
        {
            return Activator.CreateInstance(this.implementationType);
        }
    }

    [GeneralCompose(typeof (IList), typeof (ArrayList))]
    internal class TestCompose
    {
        public TestCompose()
        {
            // Note the use of the Post.Cast method to get the implemented interface.
            IList list = Post.Cast<TestCompose, IList>(this);
            list.Add("apple");
            list.Add("orange");
            list.Add("banana");
        }
    }
}
See Also

Reference

CompositionAspect


Example: Automatically Adding DataContract and DataMember Attributes

Example: Automatically Adding DataContract and DataMember Attributes

This aspect automatically adds custom attributes DataContract and DataMember to classes so they can be serialized by the WCF formatter. Properties that must not be serialized must be annotated with the custom attribute NotDataMemberAttribute.

Requirements

PostSharp 2.0 Professional Edition or higher

Demonstrates

This example demonstrates how CustomAttributeIntroductionAspect can be used together with IAspectProvider.

Example
C#
Copy
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using PostSharp.Aspects;
using PostSharp.Extensibility;
using PostSharp.Reflection;

namespace Samples
{
    // We set up multicast inheritance so  the aspect is automatically added to children types.
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
    [Serializable]
    public sealed class AutoDataContractAttribute : TypeLevelAspect, IAspectProvider
    {
        // This method is called at build time and should just provide other aspects.
        public IEnumerable<AspectInstance> ProvideAspects(object targetElement)
        {
            Type targetType = (Type) targetElement;

            CustomAttributeIntroductionAspect introduceDataContractAspect =
                new CustomAttributeIntroductionAspect(
                    new ObjectConstruction(typeof (DataContractAttribute).GetConstructor(Type.EmptyTypes)));
            CustomAttributeIntroductionAspect introduceDataMemberAspect =
                new CustomAttributeIntroductionAspect(
                    new ObjectConstruction(typeof (DataMemberAttribute).GetConstructor(Type.EmptyTypes)));

            // Add the DataContract attribute to the type.
            yield return new AspectInstance(targetType, introduceDataContractAspect);

            // Add a DataMember attribute to every relevant property.
            foreach (PropertyInfo property in
                targetType.GetProperties(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance))
            {
                if (property.CanWrite && !property.IsDefined(typeof (NotDataMemberAttribute), false))
                    yield return new AspectInstance(property, introduceDataMemberAspect);
            }
        }
    }

    [AttributeUsage(AttributeTargets.Property)]
    public sealed class NotDataMemberAttribute : Attribute
    {
    }
}
See Also

Reference

CustomAttributeIntroductionAspect
IAspectProvider


Example: Raising an Event When the Object is Finalized

Example: Raising an Event When the Object is Finalized

This example shows an aspect that raises an event when instances of the target class is finalized (during garbage collection).

Requirements

PostSharp 2.0 Professional Edition or higher

Demonstrates

This example demonstrates how a composite aspect can be used to integrate an aspect with another implementation pattern, here IDisposable. It demonstrates that the lifetime of an instance-scoped aspect is bound to the lifetime of its target class.

Example
C#
Copy
using System;
using PostSharp;
using PostSharp.Aspects;
using PostSharp.Aspects.Advices;
using PostSharp.Reflection;

namespace Samples
{
    // The aspect will introduce and implement this interface.
    public interface IObservableLifetime
    {
        // Event raised when the object is disposed.
        event EventHandler Disposed;

        // Event raised when the object is finialized.
        event EventHandler Finalized;
    }

    // The annotation IntroduceInterface specifies that the aspect introduces this interface.
    [Serializable]
    [IntroduceInterface(typeof (IObservableLifetime), OverrideAction = InterfaceOverrideAction.Fail)]
    public class ObservableLifetimeAttribute : InstanceLevelAspect, IObservableLifetime
    {
        // True if the aspect instance is a 'real' instance, false if it is the prototype instance.
        // We do not want to raise the Finalize event on prototype instances.
        [NonSerialized] private bool notPrototype;

        // True if the aspect has already been invoked.
        [NonSerialized] private bool disposed;

        // Initializes the aspect instance.
        public override void RuntimeInitializeInstance()
        {
            this.notPrototype = true;
        }

        // At runtime, this field is set to a delegate of the method Dispose(bool) before we override it.
        [ImportMember("Dispose", IsRequired = true, Order = ImportMemberOrder.BeforeIntroductions)] public Action<bool>
            BaseDisposeMethod;

        // Overrides the method Dispose(bool) of the target type.
        [IntroduceMember(IsVirtual = true, OverrideAction = MemberOverrideAction.OverrideOrFail,
            Visibility = Visibility.Family)]
        public void Dispose(bool disposing)
        {
            // Ignore subsequent calls of this method.
            if (this.disposed)
                return;

            this.disposed = true;

            // Invoke the Dispose(bool) method of the base type.
            this.BaseDisposeMethod(disposing);

            // Raise the Disposed event.
            if (this.Disposed != null)
                this.Disposed(this.Instance, EventArgs.Empty);

            // Unlist this object from finalization.
            if (disposing)
            {
                GC.SuppressFinalize(this);
            }
        }

        // Introduces the event Disposed in the target type.
        [IntroduceMember(OverrideAction = MemberOverrideAction.Fail)]
        public event EventHandler Disposed;

        // Introduces the event Finalized in the target type.
        [IntroduceMember(OverrideAction = MemberOverrideAction.Fail)]
        public event EventHandler Finalized;

        // Finalizer.
        ~ObservableLifetimeAttribute()
        {
            // Ignore the finalizer if we are a prototype instance.
            if (!this.notPrototype)
                return;

            // Call the Dispose method of the target type.
            this.BaseDisposeMethod(false);

            // Raise the Finalized event.
            if (this.Finalized != null)
            {
                this.Finalized(this.Instance, EventArgs.Empty);
            }
        }
    }

    // A sample object.
    [ObservableLifetime]
    internal class DomainObject : IDisposable
    {
        private readonly string tag;

        public DomainObject(string tag)
        {
            this.tag = tag;
        }

        protected virtual void Dispose(bool disposing)
        {
            Console.WriteLine("Dispose({0})", disposing);
        }

        public void Dispose()
        {
            this.Dispose(true);
        }

        public override string ToString()
        {
            return "{" + tag + "}";
        }
    }

    internal class Program
    {
        private static void Main(string[] args)
        {
            DomainObject f1 = new DomainObject("f1");
            IObservableLifetime fe1 = Post.Cast<DomainObject, IObservableLifetime>(f1);
            fe1.Finalized += OnFinalized;
            f1.Dispose();

            DomainObject f2 = new DomainObject("f2");
            IObservableLifetime fe2 = Post.Cast<DomainObject, IObservableLifetime>(f2);
            fe2.Finalized += OnFinalized;
            f2 = null;
            fe2 = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }

        private static void OnFinalized(object sender, EventArgs e)
        {
            Console.WriteLine("OnFinalized: " + sender);
        }
    }
}

The output of this program is:

Copy
Dispose(True)
Dispose(False)
OnFinalized: {f2}
Remarks

This example is made more complex by the fact that it understands the disposable pattern. The aspect requires the target class to implement the disposable pattern properly, i.e. to define the method protected virtual void Dispose(bool). PostSharp will fail if the user tries to apply this aspect to a class that implements the pattern incorrectly.

The aspect overrides the Dispose(bool) method by defining a method of the same name and signature, and annotating it with the custom attribute IntroduceMemberAttribute.

In order to be able to invoke the original implementation of Dispose(bool), the aspect defines the field BaseDisposeMethod, whose type Action<bool> is a delegate compatible with the signature of the method Dispose(bool). The custom attribute ImportMemberAttribute tells PostSharp to bind this field to the Dispose method.

Because the aspect class derives from InstanceLevelAspect, which implements IInstanceScopedAspect, aspect instances have the same lifetime as instances of the target class: both instances are garbage collected at the same time. Thanks to this, the aspect can reliably raise the Finalized event on the class instance when the aspect instance itself is collected.

See Also

Reference

InstanceLevelAspect
ImportMemberAttribute
IntroduceMemberAttribute
IntroduceInterfaceAttribute

Other Resources

Understanding Aspect Lifetime and Scope


Testing and Debugging Aspects

Testing and Debugging Aspects

Aspects should be tested as any piece of code. However, testing techniques for aspects differ from testing techniques for normal class libraries because of a number of reasons:

  • Aspects instantiation is not user-controlled.

  • Aspects partially execute at build time.

  • Aspects can emit build errors. Logic that emits build errors should be tested too.

These characteristics are no obstacle to proper testing of aspects.

This chapter contains the following sections:

  • Writing Simple Tests explains how to test the behavior of an aspect.

  • Testing that an Aspect has been Applied shows how to test that an aspect has been applied to the expected set of code artifacts.

  • Consuming Dependencies from the Aspect describes several ways for aspects to consume dependencies from dependency-injection containers and service locators.

  • Attaching a Debugger at Build Time explains how to debug build-time logic.


Writing Simple Tests

Writing Simple Tests

When designing a test strategy for aspects, it is fundamental to understand that aspects cannot be used in isolation. They are always used in the context of the code artefact to which it has been applied. Therefore, when writing an aspect, two kinds of test artifacts must be written:

  • Test target code to which the aspect will be applied.

  • Test invocation code that invokes the target code and verifies that the combination of the aspect and the target code exhibits the intended behavior.

Achieving large test coverage

As with other code, you have to test the aspect with input context that varies enough to produce a large code coverage.

In the case of aspects, the input context is composed of the following items:

  • Arguments of the aspect itself, i.e. constructor arguments and property values. If the aspect behavior depends of aspect arguments, high code coverage of the aspect requires varying aspect arguments.

  • Target code can be considered as conceptually being a part of the input arguments of the aspect. For instance, if an aspect contains logic that depends on the method being static or non-static, you should test the aspect against both static and non-static methods.

  • Arguments of the target code can affect the run-time behavior of the aspect. For instance, a buggy aspects may incorrectly handle null arguments.

Example: testing a caching aspect

The following example demonstrates how to test the caching aspect illustrated in section Caching the Result of a Method. High code coverage is achieved by varying the target code and testing with null and non-null parameters.

C#
Copy
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Samples
{
    [TestClass]
    public class TestCacheAspect
    {
        private static int invocations;

        // Instance method without parameters

        [TestMethod]
        public void TestInstanceMethodWithoutParameter()
        {
            int call1 = this.InstanceMethodWithoutParameter();
            int call2 = this.InstanceMethodWithoutParameter();

            Assert.AreEqual(call1, call2);
        }

        [Cache]
        private int InstanceMethodWithoutParameter()
        {
            return invocations++;
        }

        // Static method without parameters

        [TestMethod]
        public void TestStaticMethodWithoutParameter()
        {
            int call1 = StaticMethodWithoutParameter();
            int call2 = StaticMethodWithoutParameter();

            Assert.AreEqual(call1, call2);
        }

        [Cache]
        private static int StaticMethodWithoutParameter()
        {
            return invocations++;
        }

        //  Instance method with parameters

        [TestMethod]
        public void TestInstanceMethodWithParameter()
        {
            int call1a = this.InstanceMethodWithParameter("foo");
            int call2a = this.InstanceMethodWithParameter(null);
            int call1b = this.InstanceMethodWithParameter("foo");
            int call2b = this.InstanceMethodWithParameter(null);

            Assert.AreEqual(call1a, call1b);
            Assert.AreEqual(call2a, call2b);
            Assert.AreNotEqual(call1a, call2a);
        }

        [Cache]
        private int InstanceMethodWithParameter(string param)
        {
            return invocations++;
        }
    }
}


Testing that an Aspect has been Applied

Testing that an Aspect has been Applied

In the previous section, we have seen how to test the aspect behavior itself. Now, let's see how we can test that the aspect has been applied to the expected set of targets. This can also be called testing the pointcut.

Why to test that the aspect has been property applied?

You may need to test whether an aspect has been applied to specific targets for one of the following reasons:

  • The aspect is applied using non-trivial regular expressions with MulticastAttribute.

  • The aspect is silently filtered out using CompileTimeValidate.

  • The aspect is applied using an IAspectProvider.

Testing that the aspect behavior is exhibited

The most obvious way to test that the aspect has been applied on to an element of code is to execute that code and ensure that the code actually exhibits the aspect behavior. This approach does not differ from the one described in section Writing Simple Tests.

Testing that the aspect custom attribute is present

You can check that an aspect has been applied to a target by reflecting the custom attributes present on this element of code.

However, custom attributes representing aspects are stripped by default. If you want PostSharp to emit custom attributes, follow instructions of section Reflecting Aspect Instances at Runtime.

Note Note

Aspects added by IAspectProvider are not represented by custom attributes, so their presence cannot be tested by this approach.

Parsing the PostSharp symbol file

PostSharp generates a symbol file named bin\Debug\MyAssembly.psssym, where MyAssembly is the name of the assembly. In theory, you could use this file to determine which elements of code have been modified by aspects in your project.

Caution note Caution

The PostSharp symbol file format is undocumented and unsupported. It means that PostSharp support team cannot answer questions related to this file format.


Consuming Dependencies from the Aspect

Consuming Dependencies from the Aspect

Aspects, as other components, may have dependencies to other application services. Aspects may be bound to the abstract interface to this service, and may need to resolve the dependency at runtime.

However, two reasons prevent us from the following approaches that are usual with dependency injection containers:

  • Aspects are instantiated at build time, and dependency-injection containers only exist at run-time.

  • Aspects typically have a static scope. Unless they implement the IInstanceScopedAspect, aspect instances are stored in static fields, even when applied to instance members.

These characteristics are not an obstacle to using service containers, but different patterns must be followed.

This section presents several ways to consume dependencies from an aspect:

  • Using a Global Composition Container

  • Using a Global Service Locator

  • Using Dynamic Dependency Resolution

  • Using Contextual Dependency Resolution

  • Importing Dependencies from the Target Object


Using a Global Composition Container

Using a Global Composition Container

Although the aspect cannot be instantiated by the dependency injection container, it is possible to initialize the aspect from an ambient container at runtime. An ambient container is one that is exposed as a static member and that is global to the whole application.

Dependency injection containers typically offer methods to initialize objects that have been instantiated externally. For instance, the Managed Extensibility Framework offers the SatisfyImportsOnce method.

The dependency injection method can be invoked from the RuntimeInitialize method.

Note Note

User code has no control over the time when and the thread on which an aspect is initialized. Therefore, using ThreadStaticAttribute to make the container local to the current thread is not a reliable approach.

Important note Important

The service container must be initialized before the execution of any class that is enhanced by the aspect. It means that it is not possible to use the aspect on test classes themselves. To relax this constraint, it is possible to initialize the dependency lazily, when the first advice is hit.

Example: testable logging aspect with a global MEF service container

The following code snippet shows a logging aspect and how it could be used in production code:

C#
Copy
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using System.Reflection;
using PostSharp.Aspects;
using PostSharp.Extensibility;

namespace DependencyResolution.GlobalServiceContainer
{
    public interface ILogger
    {
        void Log(string message);
    }

    public static class AspectServiceInjector
    {
        private static CompositionContainer container;

        public static void Initialize(ComposablePartCatalog catalog)
        {
            container = new CompositionContainer(catalog);
        }

        public static void BuildObject(object o)
        {
            if (container == null)
                throw new InvalidOperationException();

            container.SatisfyImportsOnce(o);
        }
    }

    [Serializable]
    public class LogAspect : OnMethodBoundaryAspect
    {
        [Import] private ILogger logger;

        public override void RuntimeInitialize(MethodBase method)
        {
            AspectServiceInjector.BuildObject(this);
        }

        public override void OnEntry(MethodExecutionArgs args)
        {
            logger.Log("OnEntry");
        }
    }

    internal class Program
    {
        private static void Main(string[] args)
        {
            AspectServiceInjector.Initialize(new TypeCatalog(typeof (ConsoleLogger)));

            // The static constructor of LogAspect is called before the static constructor of the type
            // containing target methods. This is why we cannot use the aspect in the Program class.
            Foo.LoggedMethod();
        }
    }

    internal class Foo
    {
        [LogAspect]
        public static void LoggedMethod()
        {
            Console.WriteLine("Hello, world.");
        }
    }

    [Export(typeof (ILogger))]
    internal class ConsoleLogger : ILogger
    {
        public void Log(string message)
        {
            Console.WriteLine(message);
        }
    }
}

The following code snippet shows how the logging aspect can be tested:

C#
Copy
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DependencyResolution.GlobalServiceContainer.Test
{
    [TestClass]
    public class TestLogAspect
    {
        static TestLogAspect()
        {
            AspectServiceInjector.Initialize(new TypeCatalog(typeof (TestLogger)));
        }

        [TestMethod]
        public void TestMethod()
        {
            TestLogger.Clear();
            new TargetClass().TargetMethod();
            Assert.AreEqual("OnEntry" + Environment.NewLine, TestLogger.GetLog());
        }

        private class TargetClass
        {
            [LogAspect]
            public void TargetMethod()
            {
            }
        }
    }

    [Export(typeof (ILogger))]
    internal class TestLogger : ILogger
    {
        public static readonly StringBuilder stringBuilder = new StringBuilder();

        public void Log(string message)
        {
            stringBuilder.AppendLine(message);
        }

        public static string GetLog()
        {
            return stringBuilder.ToString();
        }

        public static void Clear()
        {
            stringBuilder.Clear();
        }
    }
}


Using a Global Service Locator

Using a Global Service Locator

If all aspect instances are using the same global dependency injection container, it is likely that dependencies of all instances will resolve to the same service implementation. Therefore, storing dependencies in an instance field may be a waste of memory, especially for aspects that are applied to a very high number of code elements.

Alternatively, dependencies can be stored in static fields and initialized in the aspect static constructor.

Tip Tip

Use the PostSharpEnvironmentIsPostSharpRunning property to make sure that this part of the static constructor is executed at runtime only, when PostSharp is not running.

In this case, dependency injection method such as SatisfyImportsOnce cannot be used. Instead, the container must be used as a service locator. For instance, MEF exposes the method ExportProviderGetExport.

Important note Important

The service locator must be initialized before the execution of any class that is enhanced by the aspect. It means that it is not possible to use the aspect on the entry-point class (Program or App, typically). To relax this constraint, it is possible to initialize the dependency on demand, for instance using the Lazy construct.

Example: testable aspect with a global MEF service locator

The following code snippet shows a logging aspect and how it could be used in production code:

C#
Copy
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using PostSharp.Aspects;
using PostSharp.Extensibility;

namespace DependencyResolution.GlobalServiceLocator
{
    public interface ILogger
    {
        void Log(string message);
    }

    public static class AspectServiceLocator
    {
        private static CompositionContainer container;

        public static void Initialize(ComposablePartCatalog catalog)
        {
            container = new CompositionContainer(catalog);
        }

        public static Lazy<T> GetService<T>() where T : class
        {
            return new Lazy<T>(GetServiceImpl<T>);
        }

        private static T GetServiceImpl<T>()
        {
            if (container == null)
                throw new InvalidOperationException();

            return container.GetExport<T>().Value;
        }
    }

    [Serializable]
    public class LogAspect : OnMethodBoundaryAspect
    {
        private static readonly Lazy<ILogger> logger;

        static LogAspect()
        {
            if (!PostSharpEnvironment.IsPostSharpRunning)
            {
                logger = AspectServiceLocator.GetService<ILogger>();
            }
        }

        public override void OnEntry(MethodExecutionArgs args)
        {
            logger.Value.Log("OnEntry");
        }
    }

    internal class Program
    {
        private static void Main(string[] args)
        {
            AspectServiceLocator.Initialize(new TypeCatalog(typeof (ConsoleLogger)));

            LoggedMethod();
        }

        [LogAspect]
        public static void LoggedMethod()
        {
            Console.WriteLine("Hello, world.");
        }
    }

    [Export(typeof (ILogger))]
    internal class ConsoleLogger : ILogger
    {
        public void Log(string message)
        {
            Console.WriteLine(message);
        }
    }
}

The following code snippet shows how the logging aspect can be tested:

C#
Copy
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DependencyResolution.GlobalServiceLocator.Test
{
    [TestClass]
    public class TestLogAspect
    {
        static TestLogAspect()
        {
            AspectServiceLocator.Initialize(new TypeCatalog(typeof (TestLogger)));
        }

        [TestMethod]
        public void TestMethod()
        {
            TestLogger.Clear();
            TargetMethod();
            Assert.AreEqual("OnEntry" + Environment.NewLine, TestLogger.GetLog());
        }

        [LogAspect]
        private void TargetMethod()
        {
        }
    }

    [Export(typeof (ILogger))]
    internal class TestLogger : ILogger
    {
        public static readonly StringBuilder stringBuilder = new StringBuilder();

        public void Log(string message)
        {
            stringBuilder.AppendLine(message);
        }

        public static string GetLog()
        {
            return stringBuilder.ToString();
        }

        public static void Clear()
        {
            stringBuilder.Clear();
        }
    }
}


Using Dynamic Dependency Resolution

Using Dynamic Dependency Resolution

Both previous approaches have a static dependency resolution strategy: it cannot be changed over time. Therefore, these strategies could be unsuitable in cases where several tests need different configurations of the dependency container.

A possible solution is to resolve dependencies dynamically each time they are needed, and not only at aspect initialization. Although this solution is ideal for the sake of testing, it may be too inefficient for production. Therefore, the solution would still need to provide dependency caching for production mode. Caching would neutralize the dynamic characteristics of dependency resolution.

This solution would be based on the following elements:

  1. The service locator can be initialized in two modes: production (the resolution strategy is immutable) and testing (the resolution strategy can be modified).

  2. The service locator returns a delegate (Func<T>, where T is the dependency type), instead of the dependency itself (T or Lazy<T>).

  3. The aspect calls the service locator during aspect initialization and stores the delegate.

  4. The aspect calls the delegate at runtime.

Example: testable logging aspect with a global MEF service container with dynamic resolution

The following code snippet shows a logging aspect and how it could be used in production code:

C#
Copy
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using PostSharp.Aspects;
using PostSharp.Extensibility;

namespace DependencyResolution.Dynamic
{
    public interface ILogger
    {
        void Log(string message);
    }

    public static class AspectServiceLocator
    {
        private static CompositionContainer container;
        private static bool isCacheable;

        public static void Initialize(ComposablePartCatalog catalog, bool isCacheable)
        {
            if (AspectServiceLocator.isCacheable && container != null)
                throw new InvalidOperationException();

            container = new CompositionContainer(catalog);
            AspectServiceLocator.isCacheable = isCacheable;
        }

        public static Func<T> GetService<T>() where T : class
        {
            if (isCacheable)
            {
                return () => new Lazy<T>(GetServiceImpl<T>).Value;
            }
            else
            {
                return GetServiceImpl<T>;
            }
        }

        private static T GetServiceImpl<T>()
        {
            if (container == null)
                throw new InvalidOperationException();

            return container.GetExport<T>().Value;
        }
    }

    [Serializable]
    public class LogAspect : OnMethodBoundaryAspect
    {
        private static readonly Func<ILogger> logger;

        static LogAspect()
        {
            if (!PostSharpEnvironment.IsPostSharpRunning)
            {
                logger = AspectServiceLocator.GetService<ILogger>();
            }
        }

        public override void OnEntry(MethodExecutionArgs args)
        {
            logger().Log("OnEntry");
        }
    }

    internal class Program
    {
        private static void Main(string[] args)
        {
            AspectServiceLocator.Initialize(new TypeCatalog(typeof (ConsoleLogger)), true);

            LoggedMethod();
        }

        [LogAspect]
        public static void LoggedMethod()
        {
            Console.WriteLine("Hello, world.");
        }
    }

    [Export(typeof (ILogger))]
    internal class ConsoleLogger : ILogger
    {
        public void Log(string message)
        {
            Console.WriteLine(message);
        }
    }
}

The following code snippet shows how the logging aspect can be tested:

C#
Copy
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DependencyResolution.Dynamic.Test
{
    [TestClass]
    public class TestLogAspect
    {
        [TestMethod]
        public void TestMethod()
        {
            // The ServiceLocator can be initialized for each test.
            AspectServiceLocator.Initialize(new TypeCatalog(typeof (TestLogger)), false);

            TestLogger.Clear();
            TargetMethod();
            Assert.AreEqual("OnEntry" + Environment.NewLine, TestLogger.GetLog());
        }

        [LogAspect]
        private void TargetMethod()
        {
        }
    }

    [Export(typeof (ILogger))]
    internal class TestLogger : ILogger
    {
        public static readonly StringBuilder stringBuilder = new StringBuilder();

        public void Log(string message)
        {
            stringBuilder.AppendLine(message);
        }

        public static string GetLog()
        {
            return stringBuilder.ToString();
        }

        public static void Clear()
        {
            stringBuilder.Clear();
        }
    }
}


Using Contextual Dependency Resolution

Using Contextual Dependency Resolution

The dependency resolution strategy does not necessarily need to resolve to the same service implementation for all occurrences of the dependency. It is possible to design a strategy that depends on the context. For instance, the service locator could accept the aspect type and the target element of code as parameters. Test code could configure the service locator to resolve dependencies to specific implementations for a given context.

Evaluating context-sensitive rules maybe CPU-intensive, but it needs to be done only during testing. In production mode, dependency resolution can be delegated to a global service catalog.

Example: testable logging aspect with contextual dependency resolution

The following code snippet shows a logging aspect and how it could be used in production code:

C#
Copy
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using System.Reflection;
using PostSharp.Aspects;
using PostSharp.Extensibility;

namespace DependencyResolution.Contextual
{
    public interface ILogger
    {
        void Log(string message);
    }

    public static class AspectServiceLocator
    {
        private static CompositionContainer container;
        private static HashSet<object> rules = new HashSet<object>();

        public static void Initialize(ComposablePartCatalog catalog)
        {
            container = new CompositionContainer(catalog);
        }

        public static Lazy<T> GetService<T>(Type aspectType, MemberInfo targetElement) where T : class
        {
            return new Lazy<T>(() => GetServiceImpl<T>(aspectType, targetElement));
        }

        private static T GetServiceImpl<T>(Type aspectType, MemberInfo targetElement) where T : class
        {
            // The rule implementation is naive but this is for testing purpose only.
            foreach (object rule in rules)
            {
                DependencyRule<T> typedRule = rule as DependencyRule<T>;
                if (typedRule == null) continue;

                T service = typedRule.Rule(aspectType, targetElement);
                if (service != null) return service;
            }

            if (container == null)
                throw new InvalidOperationException();

            // Fallback to the container, which should be the default and production behavior.
            return container.GetExport<T>().Value;
        }

        public static IDisposable AddRule<T>(Func<Type, MemberInfo, T> rule)
        {
            DependencyRule<T> dependencyRule = new DependencyRule<T>(rule);
            rules.Add(dependencyRule);
            return dependencyRule;
        }

        private class DependencyRule<T> : IDisposable
        {
            public DependencyRule(Func<Type, MemberInfo, T> rule)
            {
                this.Rule = rule;
            }

            public Func<Type, MemberInfo, T> Rule { get; private set; }

            public void Dispose()
            {
                rules.Remove(this);
            }
        }
    }

    [Serializable]
    public class LogAspect : OnMethodBoundaryAspect
    {
        private Lazy<ILogger> logger;

        public override void RuntimeInitialize(MethodBase method)
        {
            logger = AspectServiceLocator.GetService<ILogger>(this.GetType(), method);
        }

        public override void OnEntry(MethodExecutionArgs args)
        {
            logger.Value.Log("OnEntry");
        }
    }

    internal class Program
    {
        private static void Main(string[] args)
        {
            AspectServiceLocator.Initialize(new TypeCatalog(typeof (ConsoleLogger)));

            LoggedMethod();
        }

        [LogAspect]
        public static void LoggedMethod()
        {
            Console.WriteLine("Hello, world.");
        }
    }

    [Export(typeof (ILogger))]
    internal class ConsoleLogger : ILogger
    {
        public void Log(string message)
        {
            Console.WriteLine(message);
        }
    }
}

The following code snippet shows how the logging aspect can be tested:

C#
Copy
using System;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DependencyResolution.Contextual.Test
{
    [TestClass]
    public class TestLogAspect
    {
        [TestMethod]
        public void TestMethod()
        {
            // The ServiceLocator can be initialized for each test.
            using (
                AspectServiceLocator.AddRule<ILogger>(
                    (type, member) =>
                    type == typeof (LogAspect) && member.Name == "TargetMethod" ? new TestLogger() : null)
                )
            {
                TestLogger.Clear();
                TargetMethod();
                Assert.AreEqual("OnEntry" + Environment.NewLine, TestLogger.GetLog());
            }
        }

        [LogAspect]
        public void TargetMethod()
        {
        }
    }

    internal class TestLogger : ILogger
    {
        public static readonly StringBuilder stringBuilder = new StringBuilder();

        public void Log(string message)
        {
            stringBuilder.AppendLine(message);
        }

        public static string GetLog()
        {
            return stringBuilder.ToString();
        }

        public static void Clear()
        {
            stringBuilder.Clear();
        }
    }
}


Importing Dependencies from the Target Object

Importing Dependencies from the Target Object

The principal reason why aspects are believed to be difficult to test is that they are statically scoped by default, i.e. aspect objects are stored in static fields. However, any aspect can be made instance-scoped if it implements the IInstanceScopedAspect interface. See Understanding Aspect Lifetime and Scope for more information about aspect scopes.

Instance-scoped aspects can consume dependencies from the objects to which they are applied. They can also add dependencies to the target objects.

For instance, an aspect can consume a service ILogger using the following procedure:

To consume a service from an instance-scoped aspect:

  1. Add a public property of name Logger and type ILogger to the aspect and add the IntroduceMemberAttribute custom attribute. This will cause the aspect to add a property to the target class. Use the parameter MemberOverrideAction.Ignore to ignore the property if it already exists in the target type of if it has been added by another aspect.

  2. Add two custom attributes ImportAttribute and CopyCustomAttributesAttribute to the Logger property. This will cause the aspect to add the [Import] custom attribute to the Logger property added to the target class.

  3. Add a public field of name LoggerProperty and type Property<ILogger> to the aspect class and add the ImportMemberAttribute custom attribute to this field, with "Logger" as parameter. This will allow the aspect to read the Logger property even if it has been defined from outside the aspect.

  4. The aspect can now consume the dependency by calling this.LoggerProperty.Get().

The procedure is illustrated in the next example.

Example: testable logging aspect that consumes the dependency from the target object

The following code snippet shows a logging aspect and how it could be used in production code:

Logging aspect and production code
Copy
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using System.ComponentModel.Design;
using System.Reflection;
using PostSharp.Aspects;
using PostSharp.Aspects.Advices;
using PostSharp.Extensibility;
using PostSharp.Reflection;

namespace DependencyResolution.InstanceScoped
{
    public interface ILogger
    {
        void Log(string message);
    }

    [Serializable]
    public class LogAspect : OnMethodBoundaryAspect, IInstanceScopedAspect
    {
        [IntroduceMember(Visibility = Visibility.Family, OverrideAction = MemberOverrideAction.Ignore)]
        [CopyCustomAttributes(typeof (ImportAttribute))]
        [Import(typeof(ILogger))]
        public ILogger Logger { get; set; }

        [ImportMember("Logger", IsRequired = true)]
        public Property<ILogger> LoggerProperty;

        public override void OnEntry(MethodExecutionArgs args)
        {
            this.LoggerProperty.Get().Log("OnEntry");
        }

        object IInstanceScopedAspect.CreateInstance(AdviceArgs adviceArgs)
        {
            return this.MemberwiseClone();
        }

        void IInstanceScopedAspect.RuntimeInitializeInstance()
        {
        }
    }

    [Export(typeof (MyServiceImpl))]
    internal class MyServiceImpl
    {
        [LogAspect]
        public void LoggedMethod()
        {
            Console.WriteLine("Hello, world.");
        }
    }

    internal class Program
    {
        private static void Main(string[] args)
        {
            AssemblyCatalog catalog = new AssemblyCatalog(typeof (Program).Assembly);
            CompositionContainer container = new CompositionContainer(catalog);
            MyServiceImpl service = container.GetExport<MyServiceImpl>().Value;
            service.LoggedMethod();
        }
    }

    [Export(typeof (ILogger))]
    internal class ConsoleLogger : ILogger
    {
        public void Log(string message)
        {
            Console.WriteLine(message);
        }
    }
}

The following code snippet shows how the logging aspect can be tested:

C#
Copy
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DependencyResolution.InstanceScoped.Test
{
    [TestClass]
    public class TestLogAspect
    {
        [TestMethod]
        public void TestMethod()
        {
            TypeCatalog catalog = new TypeCatalog(typeof (TestLogger), typeof (TestImpl));
            CompositionContainer container = new CompositionContainer(catalog);
            TestImpl service = container.GetExport<TestImpl>().Value;
            TestLogger.Clear();
            service.TargetMethod();
            Assert.AreEqual("OnEntry" + Environment.NewLine, TestLogger.GetLog());
        }

        [Export(typeof (TestImpl))]
        private class TestImpl
        {
            [LogAspect]
            public void TargetMethod()
            {
            }
        }
    }

    [Export(typeof (ILogger))]
    internal class TestLogger : ILogger
    {
        public static readonly StringBuilder stringBuilder = new StringBuilder();

        public void Log(string message)
        {
            stringBuilder.AppendLine(message);
        }

        public static string GetLog()
        {
            return stringBuilder.ToString();
        }

        public static void Clear()
        {
            stringBuilder.Clear();
        }
    }
}


Testing Build-Time Logic

Testing Build-Time Logic

Testing build-time logic of aspects has specific challenges:

  • Aspects can emit errors and warnings, which cannot be tested using a run-time testing framework. We need a mechanism to test error messages themselves.

  • When a project contains a large number of test cases (which are all compiled at the same time), it is difficult to isolate one specific case when the debugger is attached to the build process (see Attaching a Debugger at Build Time). We need a mechanism to run the build process on a single test case.

Therefore, we built a test framework specifically for the purpose of testing aspects.

This topic contains the following sections.

  • Creating an aspect unit test project
  • Executing a single test
  • Executing all tests from a directory
  • Executing all tests in the project directory
  • Test that messages are emitted
  • Allow unsafe code
  • Creating a reference assembly
Creating an aspect unit test project

To create an aspect unit test project:

  1. Create a console project and add all required references to it.

  2. Add PostSharp to this project

  3. Edit the project file using a text editor. The project file must import PostSharp.BuildTests.targets before Microsoft.CSharp.targets (download). File PostSharp.targets also needs to be included (which is the case if the PostSharp NuGet package is added to the project).

  4. Implement each test case as a standalone file having its own Program class and Main method. To avoid naming conflicts, every file should have a distinct namespace.

A test is considered successful in the following situations:

  • the test compiles using the C# or VB compiler, and

  • the test compiles using PostSharp without any unexpected message (see below), and

  • the output exe is valid according PEVERIFY, and

  • the output exe executes successfully and returns the exit code 0,

This default behavior can be altered by test directives, as described below.

Executing a single test

Execute the following line from the command prompt:

Copy
msbuild /t:TestOne /p:Source=MyFile.cs
Executing all tests from a directory

Execute the following line from the command prompt:

Copy
msbuild /t:Test /p:SourceDir=MyDirectory
Executing all tests in the project directory

Execute the following line from the command prompt:

Copy
msbuild /t:Test
Test that messages are emitted

If the test is expected to emit a message (error, warning, information), insert the text @ExpectedMessage(PS0001) in the test file as a comment line.

If this directive is present, the test will be valid if and only if all expected messages, and no other, have been emitted.

Allow unsafe code

To enable unsafe code and disable verification by PEVERIFY, insert the text @Unsafe in the test file as a comment line.

Creating a reference assembly

In case that a test requires a dependency assembly (typically, for tests that require two assemblies, for instance testing aspect inheritance that cross assembly boundaries), you can create a second file named MyTest.Dependency.cs, if the first file is named MyTest.cs. This will create an assembly MyTest.Dependency.dll, and main test will have a reference to this assembly.


Attaching a Debugger at Build Time

Attaching a Debugger at Build Time

It may seem unusual to debug compile-time logic, but like any process, it is perfectly legal and even simple to debug the build process!

Basically, what you will do is to attach a debugger to the PostSharp process. If you use the standard MSBuild targets for PostSharp, define the constant PostSharpAttachDebugger=True.

The trick is easier to explain when you have compile-time logic (your aspect, for instance) and the transformed assembly in different Visual Studio projects.

Suppose you have your aspects logic MyAspects.csproj and unit tests (i.e. the code to be transformed) in MyAspects.Test.csproj. The easiest way to debug MyAspects.csproj is to:

  1. Open MyAspects.csproj and MyAspects.Test.csproj in two different instances of Visual Studio.

  2. Open the Visual Studio Command Prompt and go to the directory containing MyAspects.Test.csproj.

  3. Build MyAspects.csproj using Visual Studio as usually .

  4. From the command prompt, type:

    msbuild MyAspects.Test.csproj /T:Rebuild /P:PostSharpAttachDebugger=True

  5. The build process will hit a break point. When it happens, attach the instance of MyAspects.csproj Visual Studio. Set up break points in your code and continue the program execution.


Validating Architecture

Validating Architecture

Besides aspect-oriented programming, you can use PostSharp to validate your source code against architecture and design rules named constraints. Constraints are piece of codes that validate the code against specific rules at build time.

PostSharp provides ready-made constraints for the following scenarios:

  • Restricting Interface Implementation

  • Controlling Component Visibility Beyond Private and Internal

Additionally, you can develop custom constraints to enforce your own design rules. For details, see Developing Custom Architectural Constraints.


Restricting Interface Implementation

Restricting Interface Implementation

Under some circumstances you may want to restrict users of an API to implement an interface. You may want to allow them to consume the interface but not to implement it in their own classes, so that, later, you can add new members to this interface without breaking the user's code. If retaining the interface as a public artifact is required, the programming language does not give you any option to enforce the desired restriction. Enter the InternalImplementAttribute from PostSharp.

This topic contains the following sections.

  • Adding the constraint to the interface
  • Emitting an error instead of a warning
  • Ignoring warnings
Adding the constraint to the interface

To restrict implementation of publicly declared interfaces you simply need to add [InternalImplementAttribute] to that interface.

  1. Place the caret over the interface that you want to add the attribute select the "Add architectural constraint..."

    Internal Implement 1

  2. Select "Prevent interface implementation in a different assembly" and select Next.

    Internal Implement 2

  3. Verify that you will be adding the InternalImplementAttribute attribute to the correct piece of code.

    Internal Implement 3

  4. Once the download, installation and configuration of PostSharp has finished you can close the wizard and look at the changes that were made to your codebase.

    Internal Implement 4

  5. You'll notice that the only thing that has changed in the code is the addition of the [InternalImplementAttribute] attribute.

    C#
    Copy
    [InternalImplement]
public interface ICustomerRepository
{
    IEnumerable<Customer> FetchAll();
}

Once that is done, implementing the interface that was decorated with the InternalImplementAttribute from another assembly will create a compile time warning.

Internal Implement Warning
Note Note

To perform this architectural validation the project that is trying to implement the interface will need to be processed by PostSharp.

Emitting an error instead of a warning

If a warning isn't strong enough for your environment you can change the output to a compile time error by setting the InternalImplementAttribute to have a Severity type of Error.

C#
Copy
[InternalImplement(Severity = SeverityType.Error)]
public interface ICustomerRepository
{
    IEnumerable<Customer> FetchAll();
}

Now any reference to the decorated interface from another assembly will generate an error and fail the compilation of your project.

Internal Implement Error
Ignoring warnings

If you are trying to implement a constrained interface in a separate assembly and you want to override the warning being generated there is a solution available for you. The IgnoreWarningAttribute attribute can be applied to stop warnings from being generated.

Note Note

The IgnoreWarningAttribute attribute will only suppress warnings. If you have escalated the warnings to be errors, those errors will still be generated even if the IgnoreWarningAttribute attribute is present.

To suppress warnings all that you need to do is add the IgnoreWarningAttribute attribute to the offending piece of code. In this example we would suppress the warning being generated by adding the attribute to the class that is implementing the constrained interface. Once we have done that, the warning generated for that specific implementation would be suppressed. All other locations that are implementing this interface will continue to generate their warnings.

Note Note

You may wonder where the identifier AR0101 comes from. IgnoreWarningAttribute actually works with any PostSharp warning and not just this one. Any build error, whether from MSBuild, C# or PostSharp, has an identifier. To see error identifiers in Visual Studio, open the View menu and click on the Output item, select "Show output from: Build". You will see warnings including their identifiers.

C#
Copy
[IgnoreWarning("AR0101")]
public class PreferredCustomerRepository : ICustomerRepository
{
    public IEnumerable<Customer> FetchAll()
    {
        return null;
    }
}
See Also

Reference

InternalImplementAttribute
IgnoreWarningAttribute

Other Resources

Controlling Component Visibility Beyond Private and Internal


Controlling Component Visibility Beyond Private and Internal

Controlling Component Visibility Beyond Private and Internal

When you are working on applications it's common to run across situations where you want to restrict access to a component you have written. Usually you control this access using the private and/or internal keywords when defining the component. A class marked as internal can be accessed by any other class in the same assembly, but that may not be the level of restriction needed within the codebase. Access to a private class is restricted to those components that are inside the same class or struct that contains the private class, which prevents any other classes from accessing it. In one situation we are restricting access to the component to only the class or struct that contains it. In the other situation we are allowing access to the component from any other component that is in the same assembly. What if needed something in between?

PostSharp offers the ability to define component access rules that exist between the scope of the internal and private keywords. This gives us the opportunity to restrict access to a component only from other components in the same namespace. We can also restrict access to a select few other components.

As an example let's look at a data access related class. As a precaution against developer's circumventing our data access structure we want to limit access to this repository class.

This topic contains the following sections.

  • Restricting access to specific namespaces
  • Restricting access to specific types
  • Controlling component visibility outside of the containing assembly
  • Emitting errors instead of warnings
  • Ignoring warnings
Restricting access to specific namespaces

Our first step is to limit access to this class only to other classes within the validation namespace.

  1. Put the caret on the internal class that should have restricted access. Select "Add architectural constraint..." from the smart tag options.

    Component Internal 1

  2. Select "Prohibit use outside of given types" from the list of options.

    Component Internal 2

  3. Verify that you will be adding the ComponentInternalAttribute attribute to the correct piece of code.

    Component Internal 3

  4. Once the download, installation and configuration of PostSharp has finished you can close the wizard and look at the changes that were made to your codebase.

    Component Internal 4

  5. You'll notice that the only thing that has changed in the code is the addition of the [ComponentInternalAttribute] attribute.

    C#
    Copy
     namespace Sharpcrafters.Crm.Console.Repositories
{
    public class InvoiceRepository
    {
            [ComponentInternal]
            internal IEnumerable<Invoice> FetchAllForCustomer(Guid id)
            {
                //dostuff
                return null;
            }
     }
}

  6. The [ComponentInternalAttribute] attribute is templated to accept a string for the namespace that should be able to access this method. There are two options that you could use. The first is to pass the attribute an array of typeof(...) values that represents the types that can access this method. The second option is to pass in an array of strings that contain the namespaces of the code that should be able to access this method. For our example, replace the typeof(TODO) with a string for the validation namespace.

  7. If you try to access this component from a namespace that hasn't been granted access you will see a compile time warning in the Output window.

    C#
    Copy
     namespace Sharpcrafters.Crm.Console.Services
{
    public class InvoiceServices
    {
          public IEnumerable<InvoiceForList> FetchAllInvoicesForCustomer(Guid id)
          {
              var invoiceRepository = new InvoiceRepository();

              var allInvoices = invoiceRepository.FetchAllForCustomer(id);
              return
                  allInvoices.Where(x => !x.PaidInFull).Select(
                      x => new InvoiceForList
                          {
                              PurchaseDate = x.PurchaseDate,
                              ShipDate = x.ShipDate,
                              TotalAmount = x.Total
                           });
          }
      }
}
    Component Internal Warning
    Note Note

    If you are trying to access the component from a namespace that is in a different project you will need PostSharp to process that project for the validation to occur.

Restricting access to specific types

Under some circumstances namespace level restrictions may not be tight enough for your needs. In that situation you have the ability to apply this constraint at a type level.

  1. To restrict access at a component type level you need to explicitly define which component types will have access. This is done by passing types into the constructor of the ComponentInternalAttribute attribute's constructor. The construct accepts an array of Type which allows you to define many different component types that should be granted access.

    C#
    Copy
     public class InvoiceRepository
{
    [ComponentInternal(typeof(Sharpcrafters.Crm.Console.Services.InvoiceServices))]
    internal IEnumerable<Invoice> FetchAllForCustomer(Guid id)
    {
        //dostuff
        return null;
    }
}

  2. Now if you try to access this component from a type that hasn't been granted access you will see a compile time warning in the Output window.

    C#
    Copy
     public class CustomerServices
{
    public IEnumerable<Customer> FetchAll()
    {
        var invoiceRepository = new InvoiceRepository();
        var allInvoices = invoiceRepository.FetchAllForCustomer(Guid.NewGuid());
    }
}
    Component Internal Warning
Controlling component visibility outside of the containing assembly

Because of framework limitations or automated testing requirements you sometimes need to declare components as public so that you can perform the desired tasks or testing. For some of those components you probably don't want external applications accessing them. For instance, WPF controls need a default constructor for use in the designer, but sometimes you want another constructor to be used at runtime, so you want to prevent the default constructor to be used from code.

PostSharp offers you the ability to decorate a publically declared component in such a way that it is not accessible by applications that reference its assembly. All you need to do is apply the InternalAttribute attribute.

  1. Let's mark the Customer class so that it can only be accessed from the assembly it resides in.

    C#
    Copy
     namespace Sharpcrafters.Crm.Core
{
    public class Customer
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}

  2. Place the caret on the publically declared component that you want to restrict external access to and expand the smart tag. Select "Add architectural constraint".

  3. When prompted to select a constraint, choose to "Prohibit use outside of the project".

  4. The summary page gives you the opportunity to review the selections that you have made. If you notice that the configuration is not what you wanted you can click the Previous button and adjust your selections. If the configuration meets your needs click Next. In this demo you will see that the [InternalAttribute] attribute is being added to the Customer class.

  5. Once the download, installation and configuration of PostSharp has finished you can close the wizard and look at the changes that were made to your codebase.

  6. You'll notice that the only thing that has changed in the code is the addition of the [InternalAttribute] attribute.

    C#
    Copy
     namespace Sharpcrafters.Crm.Core
{
    [Internal]
    public class Customer
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}

  7. When you attempt to make use of that public component in a different assembly a compile time warning will appear in the Output window.

    C#
    Copy
     namespace Sharpcrafters.Crm.Console.Repositories
{
    public class CustomerRepository:ICustomerRepository
    {
        public IEnumerable<Customer> FetchAll()
        {
            return new List<Customer>{new Customer{Id=1,Name="Joe Johnson"}};
        }
    }
}
    Note Note

    The assembly that is attempting to use the public component will need to reference PostSharp for this validation to occur.

Emitting errors instead of warnings

By default any situation that breaks the access rules defined by the application of the ComponentInternalAttribute or InternalAttribute attribute will generate a compile time warning. It's possible to escalate this warning to the error level.

  1. Changing the output warning to an error requires you to set the Severity level.

    C#
    Copy
    [ComponentInternal(typeof (InvoiceServices), Severity = SeverityType.Error)]
public IEnumerable<Invoice> FetchAllForCustomer(Guid id)
{
    //dostuff
    return null;
}

  2. Now when you try to access the component when access hasn't been granted the Output window will display an error message.

    Component Internal Error
Ignoring warnings

There may be specific situations where you want to supress the warning message that is being generated at compile time. In those cases you can apply the IgnoreWarningAttribute attribute to the locations where you want to allow access to the component.

Note Note

The IgnoreWarningAttribute attribute will only suppress warnings. If you have escalated the warnings to be errors, those errors will still be generated even if the IgnoreWarningAttribute attribute is present.

If you wanted to allow access to the constrained component in a specific method you could add the IgnoreWarningAttribute attribute to that method.

C#
Copy
 public class CustomerServices
{
    [IgnoreWarning("AR0102")]
    public IEnumerable<Customer> FetchAll()
    {
        var invoiceRepository = new InvoiceRepository();
        var allInvoices = invoiceRepository.FetchAllForCustomer(Guid.NewGuid());
    }
}
Note Note

AR0102 is the identifier of the warning emitted by ComponentInternalAttribute. To ignore warnings emitted by Internal, use the identifier AR0104.

You may wonder where these identifiers come from. IgnoreWarningAttribute actually works with any PostSharp warning and not just this one. Any build error, whether from MSBuild, C# or PostSharp, has an identifier. To see error identifiers in Visual Studio, open the View menu and click on the Output item, select "Show output from: Build". You will see warnings including their identifiers.

If you wanted to allow access in an entire class you could add the IgnoreWarningAttribute attribute at the class level. Any access to the constrained component within the class would have its warning suppressed.

C#
Copy
[IgnoreWarning("AR0102")]
public class CustomerServices
{
    public IEnumerable<Customer> FetchAll()
    {
        var invoiceRepository = new InvoiceRepository();
        var allInvoices = invoiceRepository.FetchAllForCustomer(Guid.NewGuid());
    }
}
See Also

Reference

IgnoreWarningAttribute
ComponentInternalAttribute
InternalAttribute

Other Resources

Developing Custom Architectural Constraints


Developing Custom Architectural Constraints

Developing Custom Architectural Constraints

When you are creating your applications it is common to adopt custom design patterns that must be respected across all modules. Custom design patterns have the same benefits as standard ones, but they are specific to your application. For instance, the team could decide that every class derived from BusinessRule must have a nested class named Factory, derived from BusinessRulesFactory, with a public default constructor.

Even performing line-by-line code reviews can miss violations of the pattern. Is there a better way to ensure that this doesn't happen? PostSharp offers the ability create custom architectural constraints. The constraints that you write are able to verify anything that you can query using reflection.

There are two kinds of constraints: scalar constraints and referential constraints.

This topic contains the following sections.

  • Creating a scalar constraint
  • Creating a referential constraint
  • Validating the constraint itself
  • Ignoring warnings
Creating a scalar constraint

Scalar constraints typically validate an element of code, while referential constraints validate how an element of code is being used.

Let's start with a scalar constraint and create a constraint that verifies the first condition our BusinessRule design pattern: that any class derived from BusinessRule must have a nested class named Factory. We can model this condition as a scalar constraint that applies to any class derived from BusinessRule. Therefore, we will create a type-level scalar constraint, apply it to the BusinessRule class, and use attribute inheritance to have the constraint automatically applied to all derived classes.

  1. Create a class that inherits from the ScalarConstraint class in PostSharp.

    C#
    Copy
     using System;
public class BusinessRulePatternValidation : ScalarConstraint
{
}

  2. Designate what code construct type this validation aspect should work for by adding the MulticastAttributeUsageAttribute attribute. In this case we want the validation to occur on types only, and we want to enable inheritance.

    C#
    Copy
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
public class BusinessRulePatternValidation : ScalarConstraint
{
}

  3. Override the ValidateCode(Object) method.

    C#
    Copy
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
public class BusinessRulePatternValidation : ScalarConstraint
{
    public override void ValidateCode(object target)
    {
    }
}

  4. Create a rule that checks that there's a nested type called Factory. You'll note that the target parameter for the ValidateCode(Object) method is an object type. Depending on which target type you declare in the MulticastAttributeUsageAttribute attribute, the value passed through this parameter will change. For MulticastTargets.Type the type passed is Type. To make use of the target for validation you must cast to that type first.

    C#
    Copy
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
public class BusinessRulePatternValidation : ScalarConstraint
{
    public override void ValidateCode(object target)
    {
        var targetType = (Type) target;

        if ( targetType.GetNestedType("Factory") == null )
        {
           // Error
        }
    }
}
    Note Note

    Valid types for the target parameter of the ValidateCode(Object) method include Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, and ParameterInfo.

  5. Write a warning that the rule being broken to the Output window in Visual Studio.

    C#
    Copy
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
public class BusinessRulePatternValidation : ScalarConstraint
{
    public override void ValidateCode(object target)
    {
        var targetType = (Type)target;

        if (targetType.GetNestedType("Factory") == null)
        {
            Message.Write(
                targetType, SeverityType.Warning,
                "2001",
                "The {0} type does not have a nested type named 'Factory'.",
                targetType.DeclaringType,
                 targetType.Name);
        }
    }
}

  6. Attach the rule to the code that needs to be protected. For this example we want to add this rule to the BusinessRule class.

    C#
    Copy
    [BusinessRulePatternValidation]
public class BusinessRule
{
    // No Factory class here.
}
    Note Note

    This example shows applying the constraint to only one class. If you want to apply a constraint to large portions of your codebase, read the section on Adding Aspects to Multiple Declarations

  7. Now if you compile the project you will see an error in the Output window of Visual Studio when you run a build.

    Custom Arch Constraint warning

  8. In some circumstances you may determine that a warning isn't aggressive enough. We can alter the rule that you have created so that it outputs a compile time error instead. All that you need to do is change the SeverityType in the Message.Write to Error.

    C#
    Copy
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
public class BusinessRulePatternValidation : ScalarConstraint
{
    public override void ValidateCode(object target)
    {
        var targetType = (Type)target;

        if (targetType.GetNestedType("Factory") == null)
        {
            Message.Write(
            targetType, SeverityType.Error,
            "2001",
            "The {0} type does not have a nested type named 'Factory'.",
            targetType.DeclaringType,
            targetType.Name);
        }
    }
}
    Custom Arch Constraint error

Using this technique it is possible to create rules or restrictions based on a number of different criteria and implement validation for several design patterns.

When you are working on projects you need to ensure that they adhere to the ideals and principles that our project teams hold dear. As with any process in software development, manual verification is guaranteed to fail at some point in time. As you do in other areas of the development process, you should look to automate the verification and enforcement of our ideals. The ability to create custom architectural constraints provides both the flexibility and verification that you need to achieve this goal.

Creating a referential constraint

Now let's create a referential constraint that verifies the second condition our BusinessRule design pattern: that the BusinessRule class can only be used in the Controllers namespace. You can model this condition as a referential constraint and apply the constraint to any class in your codebase. If you apply this constraint to the entirety of your codebase you will ensure that the BusinessRule design pattern is only referenced in the Controllers namespace.

  1. Create a class that inherits from the ReferentialConstraint class in PostSharp.

    C#
    Copy
     public class BusinessRuleUseValidation : ReferentialConstraint
{
}

  2. Declare that this aspect should work only on types by adding the MulticastAttributeUsageAttribute attribute to the class.

    C#
    Copy
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
public class BusinessRuleUseValidation : ReferentialConstraint
{
}

  3. Override the ValidateCode(Object, Assembly) method.

    C#
    Copy
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
BusinessRuleUseValidation : ReferentialConstraint
{
    public override void ValidateCode(object target, Assembly assembly)
    {
    }
}

  4. Create the rule that checks for the use of the BusinessRule type in the target code.

    C#
    Copy
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
public class BusinessRulePatternValidation : ScalarConstraint
{
    public override void ValidateCode(object target, Assembly assembly)
    {
        var targetType = (Type) target;
        var usages = ReflectionSearch
                .GetMethodsUsingDeclaration(typeof (BusinessRule));

        if (usages !=null)
        {
            // Warning
        }
    }
}
    Note Note

    The rule here makes use of the ReflectionSearch helper class that is provided by the PostSharp framework. This class, along with others, is an extension to the built in reflection functionality of .NET and can be used outside of aspects as well.

  5. Write a warning message to be included in the Output window of Visual Studio.

    C#
    Copy
    [MulticastAttributeUsage(MulticastTargets.Class, Inheritance = MulticastInheritance.Strict)]
public class BusinessRulePatternValidation : ScalarConstraint
{
    public override void ValidateCode(object target, Assembly assembly)
    {
        var targetType = (Type) target;
        var usages = ReflectionSearch
        .GetMethodsUsingDeclaration(typeof (BusinessRule));

        if (usages !=null)
        {
            Message.Write(
                targetType, SeverityType.Warning,
                "2002",
                "The {0} type contains a reference to 'BusinessRule'" +
                "which should only be referenced from Controllers.",
                targetType.Name);
        }
    }
}

  6. Attach the referential constraint that you created to any code that needs to be checked. In this example, add an attribute to the AccountRepository class.

    C#
    Copy
     namespace PostSharp.Architecture.Repositories
{
    [BusinessRuleUseValidation]
    public class AccountRepository
    {
        public void AddAccount(string name)
        {
            var businessRule = new BusinessRule();
            businessRule.DoStuff();
        }
    }
}
    Note Note

    This example shows applying the constraint to only one class. If you want to apply this constraint to a larger portion of your codebase, read the section on Adding Aspects to Multiple Declarations.

  7. Now when you compile the project you will see a warning in the Output window in Visual Studio.

    Referential Constraint Warning
    Note Note

    If using a warning isn't aggressive enough you can change the SeverityType to Error. Now when the rule is broken an error will appear in the Output window of Visual Studio and the build will not be successful.

Caution note Caution

PostSharp constraints operate at the lowest level. For instance, checking relationships of a type with the rest of the code does not implicitly check the relationships of the methods of this type. Also, checking relationships of namespaces is not possible.

Custom attribute multicasting can be used to apply a constraint to a large number of types, for instance all types of a namespace. But this would result in one constraint instance for every type, method and field on this namespace. Altough this has no impact on run time, it could severely affect build time. For this reason, the current version of PostSharp Constraints is not suitable to check isolation (layering) of namespaces at large scale.

Referential constraints provide you with the ability to declare architectural design patterns right in your code. By documenting these patterns right in the codebase you are able to provide easy access for the development team as well as continual verification that your desired design patterns are being adhered to.

Validating the constraint itself

Now that you have created scalar and referential constraints you can be assured that certain architectural rules are being consistently implemented in your codebase. There is one thing that is missing though.

With what you have done thus far, it is possible to attach your architectural constraints to any code element in your projects. This may not be appropriate. For example, the scalar constraint that you created to perform the BusinessRulePatternValidation may be a valid constraint only on classes that exist in the Models namespace.

Let's look at how we can ensure that this constraint is only enforced on classes that exist in the Models namespace.

  1. Open the BusinessRulePatternValidation class that you created earlier.

  2. Override the ValidateConstraint(Object) method.

  3. Write the validation logic to ensure that this constraint is only applied to classes in the Models namespace.

    Note Note

    When the ValidateConstraint(Object) method returns true, it tells PostSharp that the constraint should be applied to that target code element. When the ValidateConstraint(Object) method returns false PostSharp will not apply the constraint to the target code element.

Now, when the BusinessRulePatternValidation attribute is applied to a class that is not in the Models namespace of your project, there will be no warning or error added to the Visual Studio Output window.

When the attribute is applied to a class in the Models namespace and that class doesn't pass the constraint's rules you will continue to see the warning or error indicating this architectural failure.

Ignoring warnings

There will be situations where a constraint is generating a warning that is of no concern. In these exceptional circumstances it is best if you remove the warning from the Visual Studio Output window.

To ignore these unnecessary warnings, find the target code that is responsible for generating the warning. Add the IgnoreWarningAttribute attribute to the target code entering the MessageId of the warning that you want to suppress.

The MessageId can be found in your constraint where you issue the Message.Write command. The Reason value performs no function during the suppression of the warning. It exists so that you can provide clear communication as to why the warning is being ignored.

Note Note

The IgnoreWarningAttribute attribute will only suppress the issuance of Message.Write statements that are assigned a SeverityType of Warning. If the SeverityType is set to Error the IgnoreWarningAttribute attribute will have no suppression effect on that statement.

See Also

Reference

MulticastAttributeUsageAttribute
ScalarConstraint
IgnoreWarningAttribute
MessageId
Reason
MulticastAttributeUsageAttribute

Other Resources

Adding Aspects to Multiple Declarations


API Reference

API Reference
PostSharp is a design pattern automation tool for Microsoft .NET.
Namespaces
Namespace | Description
PostSharp | The PostSharp namespace is the root namespace of PostSharp.
PostSharp.Aspects | The PostSharp.Aspects namespace provides the primitives of the PostSharp aspect-oriented framework, such as abstract aspect classes, aspect interfaces, and advise argument classes.
PostSharp.Aspects.Advices | The PostSharp.Aspects.Advices provides custom attributes that allow developing composite aspects with advices and pointcuts.
PostSharp.Aspects.Configuration | The PostSharp.Aspects.Configuration namespace contains classes and custom attributes configuring the aspects of the PostSharp.Aspects namespace.
PostSharp.Aspects.Dependencies | The PostSharp.Aspects.Dependencies namespace contains types and custom attributes that allow to define dependencies between aspects and advices, so that the aspect weaver behaves determistically even if the same element of code is the target of several aspects provided by multiple vendors.
PostSharp.Aspects.Serialization | The PostSharp.Aspects.Serialization namespace contains types taking care of the process of serializing aspects at build time and deserializing them at run time.
PostSharp.Collections | The PostSharp.Collections namespace contains collection types used by the PostSharp library.
PostSharp.Constraints | The PostSharp.Constraints namespace allows you to validate your code against predefined or custom design rules.
PostSharp.Extensibility | The PostSharp.Extensibility namespace defines the semantics of the attribute multicasting mechanism and exposes other types that allow user code to interact with the PostSharp,platform.
PostSharp.Patterns |
PostSharp.Patterns.Collections | The PostSharp.Patterns.Collections namespace defines collection classes that work with the Aggregatable pattern.
PostSharp.Patterns.Contracts | The PostSharp.Patterns.Contracts namespace contains ready-made contracts that validate fields, properties and parameters at runtime.
PostSharp.Patterns.Diagnostics | The PostSharp.Patterns.Diagnostics namespace contains a logging aspect.
PostSharp.Patterns.Model | The PostSharp.Patterns.Model namespace contains an implementation of the Observer, Aggregatable and Disposable patterns.
PostSharp.Patterns.Model.Controls |
PostSharp.Patterns.Recording | The PostSharp.Patterns.Recording namespace implements the undo/redo feature.
PostSharp.Patterns.Recording.Operations | The PostSharp.Patterns.Recording.Operations namespace defines recordable operations.
PostSharp.Patterns.Threading | The PostSharp.Patterns.Threading namespace contains an implementation of several threading models, and other thread dispatching aspects.
PostSharp.Patterns.Threading.Models |
PostSharp.Patterns.Utilities |
PostSharp.Reflection | The PostSharp.Reflection namespace complements the System.Reflection namespace.
PostSharp.Reflection.Syntax | The PostSharp.Reflection.Syntax namespace contains classes and interfaces that can represent the decompiled abstract syntax tree of method bodies.
PostSharp.Serialization | The PostSharp.Serialization namespace implements a portable serializer.


PostSharp Namespace

PostSharp Namespace
The PostSharp namespace is the root namespace of PostSharp.
Classes
 | Class | Description
Public class | IgnoreWarningAttribute | Instructs PostSharp to ignore warnings and information messages. Errors cannot be ignored.
Public class | MessageLocation | Represents the location of a message, which means, for the end-user, a line in a file of source code. From the aspect developer, the location can be known as an object representing an element of code (for instance a Type or MethodInfo). Such implicit locations are resolved by PostSharp to a file and line number.
Public class | Post | Provides some methods that are transformed during post-compilation.


IgnoreWarningAttribute Class

IgnoreWarningAttribute Class
Instructs PostSharp to ignore warnings and information messages. Errors cannot be ignored.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharpIgnoreWarningAttribute

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class IgnoreWarningAttribute : Attribute

The IgnoreWarningAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | IgnoreWarningAttribute | Creates a new instance of IgnoreWarningAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | MessageId | Gets the identifier of the ignored warning.
Public property | Reason | Gets or set the reason (a human-readable text) why the warning must be ignored.
Top
Remarks
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp Namespace


IgnoreWarningAttribute Constructor

IgnoreWarningAttribute Constructor
Creates a new instance of IgnoreWarningAttribute.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IgnoreWarningAttribute(
    string messageId
)

Parameters

messageId
Type: SystemString
Identifier of the ignored warning.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IgnoreWarningAttribute Class
PostSharp Namespace


IgnoreWarningAttribute Methods

IgnoreWarningAttribute Methods

The IgnoreWarningAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

IgnoreWarningAttribute Class
PostSharp Namespace


IgnoreWarningAttribute Properties

IgnoreWarningAttribute Properties

The IgnoreWarningAttribute type exposes the following members.

Properties
 | Name | Description
Public property | MessageId | Gets the identifier of the ignored warning.
Public property | Reason | Gets or set the reason (a human-readable text) why the warning must be ignored.
Top
See Also

Reference

IgnoreWarningAttribute Class
PostSharp Namespace


IgnoreWarningAttribute.MessageId Property

IgnoreWarningAttributeMessageId Property
Gets the identifier of the ignored warning.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string MessageId { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IgnoreWarningAttribute Class
PostSharp Namespace


IgnoreWarningAttribute.Reason Property

IgnoreWarningAttributeReason Property
Gets or set the reason (a human-readable text) why the warning must be ignored.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Reason { get; set; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IgnoreWarningAttribute Class
PostSharp Namespace


MessageLocation Class

MessageLocation Class
Represents the location of a message, which means, for the end-user, a line in a file of source code. From the aspect developer, the location can be known as an object representing an element of code (for instance a Type or MethodInfo). Such implicit locations are resolved by PostSharp to a file and line number.
Inheritance Hierarchy
SystemObject
PostSharpMessageLocation

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public class MessageLocation

The MessageLocation type exposes the following members.

Methods
Name | Description
Explicit(String) | Builds a MessageLocation explicitly by specifying a filename, when the
Explicit(String, Int32, Int32) | Builds a MessageLocation explicitly by specifying a filename, line, and column.
Explicit(String, Int32, Int32, Int32, Int32) | Builds a MessageLocation explicitly by specifying a filename, line, and column.
Of(Object) | Builds a MessageLocation from an object representing an element of code (Type, MethodInfo, ConstructorInfo, FieldInfo, Assembly, ParameterInfo, EventInfo, PropertyInfo or, if you are using PostSharp SDK, any Declaration).
Of(Assembly) | Builds a MessageLocation from an Assembly.
Of(MemberInfo) | Builds a MessageLocation from a MemberInfo (Type, MethodInfo, ConstructorInfo, FieldInfo, PropertyInfo, EventInfo).
Of(ParameterInfo) | Builds a MessageLocation from a ParameterInfo.
Of(LocationInfo) | Builds a MessageLocation from a LocationInfo.
Of(SymbolSequencePoint) | Builds a MessageLocation from a SymbolSequencePoint.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
Unknown | Represents an unknown or indeterminate location of the error message.
Top
Properties
 | Name | Description
Public property | CodeElement | Element of code (reflection object or Declaration) from which the location must be resolved.
Public property | EndColumn | Gets the ending column in the file that caused the message.
Public property | EndLine | Gets the ending line in the file that caused the message.
Public property | File | Gets the name of the file that caused the message.
Public property | StartColumn | Gets the starting column in the file that caused the message.
Public property | StartLine | Gets the starting line in the file that caused the message.
Top
Remarks

For unknown locations, prefer Unknown to null as it makes the code more readable.

\

Elements of code are mapped to locations asynchronously and out-of-process. The File, [!:Line] and [!:Column] may be unavailable by the thread or process emitting the message.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp Namespace


MessageLocation Fields

MessageLocation Fields

The MessageLocation type exposes the following members.

Fields
Name | Description
Unknown | Represents an unknown or indeterminate location of the error message.
Top
See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation.Unknown Field

MessageLocationUnknown Field
Represents an unknown or indeterminate location of the error message.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly MessageLocation Unknown

Field Value

Type: MessageLocation
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation Methods

MessageLocation Methods

The MessageLocation type exposes the following members.

Methods
Name | Description
Explicit(String) | Builds a MessageLocation explicitly by specifying a filename, when the
Explicit(String, Int32, Int32) | Builds a MessageLocation explicitly by specifying a filename, line, and column.
Explicit(String, Int32, Int32, Int32, Int32) | Builds a MessageLocation explicitly by specifying a filename, line, and column.
Of(Object) | Builds a MessageLocation from an object representing an element of code (Type, MethodInfo, ConstructorInfo, FieldInfo, Assembly, ParameterInfo, EventInfo, PropertyInfo or, if you are using PostSharp SDK, any Declaration).
Of(Assembly) | Builds a MessageLocation from an Assembly.
Of(MemberInfo) | Builds a MessageLocation from a MemberInfo (Type, MethodInfo, ConstructorInfo, FieldInfo, PropertyInfo, EventInfo).
Of(ParameterInfo) | Builds a MessageLocation from a ParameterInfo.
Of(LocationInfo) | Builds a MessageLocation from a LocationInfo.
Of(SymbolSequencePoint) | Builds a MessageLocation from a SymbolSequencePoint.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation.Explicit Method

MessageLocationExplicit Method
Overload List
Name | Description
Explicit(String) | Builds a MessageLocation explicitly by specifying a filename, when the
Explicit(String, Int32, Int32) | Builds a MessageLocation explicitly by specifying a filename, line, and column.
Explicit(String, Int32, Int32, Int32, Int32) | Builds a MessageLocation explicitly by specifying a filename, line, and column.
Top
See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation.Explicit Method (String)

MessageLocationExplicit Method (String)
Builds a MessageLocation explicitly by specifying a filename, when the

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MessageLocation Explicit(
    string file
)

Parameters

file
Type: SystemString
File name.

Return Value

Type: MessageLocation
A MessageLocation.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
Explicit Overload
PostSharp Namespace


MessageLocation.Explicit Method (String, Int32, Int32)

MessageLocationExplicit Method (String, Int32, Int32)
Builds a MessageLocation explicitly by specifying a filename, line, and column.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MessageLocation Explicit(
    string file,
    int line,
    int column
)

Parameters

file
Type: SystemString
File name.
line
Type: SystemInt32
Line number.
column
Type: SystemInt32
Column number.

Return Value

Type: MessageLocation
A MessageLocation.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
Explicit Overload
PostSharp Namespace


MessageLocation.Explicit Method (String, Int32, Int32, Int32, Int32)

MessageLocationExplicit Method (String, Int32, Int32, Int32, Int32)
Builds a MessageLocation explicitly by specifying a filename, line, and column.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MessageLocation Explicit(
    string file,
    int lineStart,
    int columnStart,
    int lineEnd,
    int columnEnd
)

Parameters

file
Type: SystemString
File name.
lineStart
Type: SystemInt32
Starting line number.
columnStart
Type: SystemInt32
Starting column number.
lineEnd
Type: SystemInt32
Ending line number.
columnEnd
Type: SystemInt32
Ending column number.

Return Value

Type: MessageLocation
A MessageLocation.
Version Information

Supported in: 4.1

See Also

Reference

MessageLocation Class
Explicit Overload
PostSharp Namespace


MessageLocation.Of Method

MessageLocationOf Method
Overload List
Name | Description
Of(Object) | Builds a MessageLocation from an object representing an element of code (Type, MethodInfo, ConstructorInfo, FieldInfo, Assembly, ParameterInfo, EventInfo, PropertyInfo or, if you are using PostSharp SDK, any Declaration).
Of(Assembly) | Builds a MessageLocation from an Assembly.
Of(MemberInfo) | Builds a MessageLocation from a MemberInfo (Type, MethodInfo, ConstructorInfo, FieldInfo, PropertyInfo, EventInfo).
Of(ParameterInfo) | Builds a MessageLocation from a ParameterInfo.
Of(LocationInfo) | Builds a MessageLocation from a LocationInfo.
Of(SymbolSequencePoint) | Builds a MessageLocation from a SymbolSequencePoint.
Top
See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation.Of Method (Object)

MessageLocationOf Method (Object)
Builds a MessageLocation from an object representing an element of code (Type, MethodInfo, ConstructorInfo, FieldInfo, Assembly, ParameterInfo, EventInfo, PropertyInfo or, if you are using PostSharp SDK, any Declaration).

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MessageLocation Of(
    Object codeElement
)

Parameters

codeElement
Type: SystemObject
an object representing an element of code (Type, MethodInfo, ConstructorInfo, FieldInfo, Assembly, ParameterInfo, EventInfo, PropertyInfo or, if you are using PostSharp SDK, any Declaration.

Return Value

Type: MessageLocation
A MessageLocation representing codeElement.
Remarks

If codeElement is null or cannot mapped to a location of code, this method silently returns Unknown.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
Of Overload
PostSharp Namespace


MessageLocation.Of Method (Assembly)

MessageLocationOf Method (Assembly)
Builds a MessageLocation from an Assembly.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MessageLocation Of(
    Assembly assembly
)

Parameters

assembly
Type: System.ReflectionAssembly
An Assembly (Assembly or its wrapper).

Return Value

Type: MessageLocation
A MessageLocation.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
Of Overload
PostSharp Namespace


MessageLocation.Of Method (MemberInfo)

MessageLocationOf Method (MemberInfo)
Builds a MessageLocation from a MemberInfo (Type, MethodInfo, ConstructorInfo, FieldInfo, PropertyInfo, EventInfo).

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MessageLocation Of(
    MemberInfo member
)

Parameters

member
Type: System.ReflectionMemberInfo
An element of code (Type, MethodInfo, ConstructorInfo, FieldInfo, PropertyInfo, EventInfo).

Return Value

Type: MessageLocation
A MessageLocation.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
Of Overload
PostSharp Namespace


MessageLocation.Of Method (ParameterInfo)

MessageLocationOf Method (ParameterInfo)
Builds a MessageLocation from a ParameterInfo.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MessageLocation Of(
    ParameterInfo parameter
)

Parameters

parameter
Type: System.ReflectionParameterInfo
A ParameterInfo.

Return Value

Type: MessageLocation
A MessageLocation.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
Of Overload
PostSharp Namespace


MessageLocation.Of Method (LocationInfo)

MessageLocationOf Method (LocationInfo)
Builds a MessageLocation from a LocationInfo.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MessageLocation Of(
    LocationInfo location
)

Parameters

location
Type: PostSharp.ReflectionLocationInfo
A LocationInfo.

Return Value

Type: MessageLocation
A MessageLocation.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
Of Overload
PostSharp Namespace


MessageLocation.Of Method (SymbolSequencePoint)

MessageLocationOf Method (SymbolSequencePoint)
Builds a MessageLocation from a SymbolSequencePoint.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MessageLocation Of(
    SymbolSequencePoint symbolSequencePoint
)

Parameters

symbolSequencePoint
Type: PostSharp.ReflectionSymbolSequencePoint
A SymbolSequencePoint.

Return Value

Type: MessageLocation
A MessageLocation corresponding to symbolSequencePoint.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
Of Overload
PostSharp Namespace


MessageLocation Properties

MessageLocation Properties

The MessageLocation type exposes the following members.

Properties
 | Name | Description
Public property | CodeElement | Element of code (reflection object or Declaration) from which the location must be resolved.
Public property | EndColumn | Gets the ending column in the file that caused the message.
Public property | EndLine | Gets the ending line in the file that caused the message.
Public property | File | Gets the name of the file that caused the message.
Public property | StartColumn | Gets the starting column in the file that caused the message.
Public property | StartLine | Gets the starting line in the file that caused the message.
Top
See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation.CodeElement Property

MessageLocationCodeElement Property
Element of code (reflection object or Declaration) from which the location must be resolved.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object CodeElement { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation.EndColumn Property

MessageLocationEndColumn Property
Gets the ending column in the file that caused the message.
An integer greater or equal to 1, or 0 if the column is unknown or does not apply.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int EndColumn { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1

See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation.EndLine Property

MessageLocationEndLine Property
Gets the ending line in the file that caused the message.
An integer greater or equal to 1, or 0 if the line is unknown or does not apply.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int EndLine { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1

See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation.File Property

MessageLocationFile Property
Gets the name of the file that caused the message.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string File { get; }

Property Value

Type: String
A full file name, or null if the file name is unknown or not applicable.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation.StartColumn Property

MessageLocationStartColumn Property
Gets the starting column in the file that caused the message.
An integer greater or equal to 1, or 0 if the column is unknown or does not apply.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int StartColumn { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1

See Also

Reference

MessageLocation Class
PostSharp Namespace


MessageLocation.StartLine Property

MessageLocationStartLine Property
Gets the starting line in the file that caused the message.
An integer greater or equal to 1, or 0 if the line is unknown or does not apply.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int StartLine { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1

See Also

Reference

MessageLocation Class
PostSharp Namespace


Post Class

Post Class
Provides some methods that are transformed during post-compilation.
Inheritance Hierarchy
SystemObject
PostSharpPost

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class Post

The Post type exposes the following members.

Methods
Name | Description
CastSourceType, TargetType | At post-compile time, casts an instance of a type into another. A post-compile time error is reported if the source type cannot be assigned to the target type.
GetValueT | When used to retrieve the value of a field, forces the compiler to retrieve a copy of the field value instead of an address to this field. This allows to call instance methods of value-type fields without loading the field address.
Top
Properties
Name | Description
IsTransformed | Determines whether the calling program has been transformed by PostSharp.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp Namespace


Post Methods

Post Methods

The Post type exposes the following members.

Methods
Name | Description
CastSourceType, TargetType | At post-compile time, casts an instance of a type into another. A post-compile time error is reported if the source type cannot be assigned to the target type.
GetValueT | When used to retrieve the value of a field, forces the compiler to retrieve a copy of the field value instead of an address to this field. This allows to call instance methods of value-type fields without loading the field address.
Top
See Also

Reference

Post Class
PostSharp Namespace


Post.Cast(SourceType, TargetType) Method

PostCastSourceType, TargetType Method
At post-compile time, casts an instance of a type into another. A post-compile time error is reported if the source type cannot be assigned to the target type.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static TargetType Cast<SourceType, TargetType>(
    SourceType o
)
where SourceType : class
where TargetType : class

Parameters

o
Type: SourceType
Instance to be casted.

Type Parameters

SourceType
Source type.
TargetType
Target type.

Return Value

Type: TargetType
The object o casted as TargetType.
Remarks
The purpose of this method is to make a source code compilable even when an interface will be implemented at post-compile time. PostSharp ensures that TargetType is assignable from SourceType. If yes, the call to this method is simply suppressed. If types are not assignable, a build error is issued.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Post Class
PostSharp Namespace


Post.GetValue(T) Method

PostGetValueT Method
When used to retrieve the value of a field, forces the compiler to retrieve a copy of the field value instead of an address to this field. This allows to call instance methods of value-type fields without loading the field address.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static T GetValue<T>(
    T value
)
where T : struct, new()

Parameters

value
Type: T
Value.

Type Parameters

T
Type of the value to retrieve (this type parameter can generally be omitted).

Return Value

Type: T
value, exactly.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Post Class
PostSharp Namespace


Post Properties

Post Properties

The Post type exposes the following members.

Properties
Name | Description
IsTransformed | Determines whether the calling program has been transformed by PostSharp.
Top
See Also

Reference

Post Class
PostSharp Namespace


Post.IsTransformed Property

PostIsTransformed Property
Determines whether the calling program has been transformed by PostSharp.

Namespace: PostSharp
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool IsTransformed { get; }

Property Value

Type: Boolean
true if the calling program has been transformed by PostSharp, otherwise false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Post Class
PostSharp Namespace


PostSharp.Aspects Namespace

PostSharp.Aspects Namespace
The PostSharp.Aspects namespace provides the primitives of the PostSharp aspect-oriented framework, such as abstract aspect classes, aspect interfaces, and advise argument classes.
Classes
 | Class | Description
Public class | AdviceArgs | Base class for arguments of all advices.
Public class | Arguments | Encapsulation of method arguments.
Public class | Aspect | Base class for all aspects that are declared using multicast custom attributes (MulticastAttribute).
Public class | AspectInfo | Reserved for future usage.
Public class | AspectInstance | Completely specifies an aspect instance, including its target code element. An AspectInstance contains either the aspect instance itself (Aspect property), either information allowing to construct the aspect (AspectConstruction) and configure the weaver (AspectConfiguration).
Public class | AspectSpecification | Completely specifies an aspect instance (but not its target). An AspectSpecification either the aspect instance itself (Aspect property), either information allowing to construct the aspect (AspectConstruction) and configure the weaver (AspectConfiguration).
Public class | AspectUtilities | Utility methods for PostSharp.Aspects.
Public class | AssemblyLevelAspect | Base class for all aspects applied on assemblies.
 | CompositionAspect | Aspect that, when applied on a type, introduces one or many new interfaces into that type.
 | CustomAttributeIntroductionAspect | Aspect that, when applied to a target, adds a custom attribute to this target.
Public class | EventInterceptionArgs | Arguments of handlers of aspects of the type EventInterceptionAspect.
 | EventInterceptionAspect | Aspect that, when applied on an event, intercepts invocations of its semantics Add (OnAddHandler(EventInterceptionArgs)), Remove (OnRemoveHandler(EventInterceptionArgs)) and Invoke (OnInvokeHandler(EventInterceptionArgs)).
Public class | EventLevelAspect | Base class for all aspects applied on events.
Public class | ExternalAspect | Obsolete. Aspect implemented in a different type (implementing the IExternalAspectImplementation interface), typically contained in an external assembly. Classes derived from ExternalAspect must be annotated by the custom attribute ExternalAspectConfigurationAttribute.
Public class | FieldLevelAspect | Base class for all aspects applied on fields.
Public class | InstanceLevelAspect | Base class for aspects applied on types, but having the same lifetime as instances of the type to which they are applied.
Public class | LocationBindingExtensions | Extension methods for the ILocationBinding interface.
Public class | LocationInterceptionArgs | Arguments of advices of aspect type LocationInterceptionAspect.
 | LocationInterceptionAspect | Aspect that, when applied on a location (field or property), intercepts invocations of the Get (OnGetValue(LocationInterceptionArgs)) and Set (OnSetValue(LocationInterceptionArgs)) semantics.
Public class | LocationLevelAspect | Base class for aspects defined in fields, properties, or parameters.
Public class | ManagedResourceIntroductionAspect | Aspect that, when applied to an assembly, adds a custom attribute to this assembly.
Public class | MethodExecutionArgs | Arguments of advices of aspects of type OnMethodBoundaryAspect and OnExceptionAspect
Public class | MethodImplementationAspect | Aspect that, when applied on an abstract or extern method, creates an implementation for this method.
Public class | MethodInterceptionArgs | Arguments of advices of aspect type MethodInterceptionAspect.
 | MethodInterceptionAspect | Aspect that, when applied on a method, intercepts invocations of this method.
Public class | MethodLevelAspect | Base class for all aspects applied on methods.
 | OnExceptionAspect | Aspect that, when applied to a method, defines an exception handler around the whole method and calls a custom method in this exception handler.
 | OnMethodBoundaryAspect | Aspect that, when applied to a method defined in the current assembly, inserts a piece of code before and after the body of these methods.
Public class | TypeIdentity | Wraps a Type or a type name.
Public class | TypeLevelAspect | Base class for all aspects applied on types.
Structures
 | Structure | Description
Public structure | ConstructorDepth | System type used in the implementation of the OnInstanceConstructedAdvice. Do not use in user code.
Public structure | InstanceCredentials | Obsolete. Credentials that give access to 'protected' semantics.
Interfaces
 | Interface | Description
Public interface | IAspect | Base interface for run-time semantics of all aspects.
Public interface | IAspectBuildSemantics | Compile-time semantics of IAspect.
Public interface | IAspectInstance | Represents an instance of an aspect applied to a declaration.
 | IAspectProvider | Interface that, when implemented by an aspect class, allows aspect instances to provide other aspects to the weaver.
Public interface | IAspectRepositoryService | Service that allows to determine which aspects have been applied to a given declaration, whether declaratively through custom attributes or MulticastAttribute, or programmatically using IAspectProvider.
Public interface | IAssemblyLevelAspect | Runtime semantics of aspects applied at assembly level.
Public interface | IAssemblyLevelAspectBuildSemantics | Build-time semantics of aspects applied at assembly level.
Public interface | ICloneAwareAspect | Defines the semantics of aspects that require to be notified after a target object is cloned using MemberwiseClone.
Public interface | IComposedT | Obsolete. Interface exposing the implementation of another interface introduced by a CompositionAspect.
Public interface | ICompositionAspect | Defines the semantics of an aspect that, when applied on a type, introduce one or many new interfaces into that type, and let these interfaces be implemented by an object created at runtime.
Public interface | ICustomAttributeIntroductionAspect | Semantics of an aspect that, when applied to a target, adds a custom attribute to this target.
Public interface | IEventBinding | Interface through which an event-level aspect or advice can invoke the next node in the chain of invocation.
Public interface | IEventInterceptionAspect | Runtime semantics of an aspect that, when applied on an event, intercepts invocations of its semantics Add (OnAddHandler(EventInterceptionArgs)), Remove (OnRemoveHandler(EventInterceptionArgs)) and Invoke (OnInvokeHandler(EventInterceptionArgs)) semantics.
Public interface | IEventLevelAspect | Runtime semantics of aspects that can be applied on events.
Public interface | IEventLevelAspectBuildSemantics | Build-time semantics of aspects that can be applied on events.
Public interface | IFieldLevelAspect | Run-time semantics of aspects applied to fields.
Public interface | IFieldLevelAspectBuildSemantics | Compile-time semantics of IFieldLevelAspect.
Public interface | IInstanceScopedAspect | Runtime semantics of aspects that have the same lifetime as instance of types to which their are applied (or instance of the declaring type of members to which they are applied).
Public interface | ILocationBinding | Interface through which a field- or property-level aspect or advice can invoke the next node in the chain of invocation.
Public interface | ILocationBindingT | A strongly-typed variant for ILocationBinding.
Public interface | ILocationInterceptionArgs | An interface for LocationInterceptionArgs.
Public interface | ILocationInterceptionArgsT | A strongly-typed specialization of the ILocationInterceptionArgs interface.
Public interface | ILocationInterceptionArgsActionTPayload | Exposes an ExecuteTValue(ILocationInterceptionArgsTValue, TPayload) method invoked by the ExecuteTPayload(ILocationInterceptionArgsActionTPayload, TPayload) method, which allows to execute strongly-typed operations and avoid boxing required by the weakly typed ILocationInterceptionArgs interface.
Public interface | ILocationInterceptionAspect | Runtime semantics of an aspect that, when applied on a location (field or property), intercepts invocations of the Get (OnGetValue(LocationInterceptionArgs)) and Set (OnSetValue(LocationInterceptionArgs)) semantics.
Public interface | ILocationLevelAspect | Runtime semantics of aspects defined on a field, property, or parameter.
Public interface | ILocationLevelAspectBuildSemantics | Compile-time semantics of ILocationLevelAspect.
Public interface | ILocationValidationAspect | Ancestor of ILocationValidationAspectT.
Public interface | ILocationValidationAspectT | Runtime semantics of an aspect that, when applied on a location (field, property, or parameter), validates the value assigned to this location using method ValidateValue(T, String, LocationKind), and throws the exception returned by this method if any.
Public interface | IManagedResourceIntroductionAspect | Semantics of an aspect that, when applied to an assembly, adds a managed resource to this assembly.
Public interface | IMethodBinding | Interface through which a method-level aspect or advice can invoke the next node in the chain of invocation.
Public interface | IMethodInterceptionAspect | Runtime semantics of an aspect that, when applied on a method, intercepts invocations of this method.
Public interface | IMethodLevelAspect | Runtime semantics of aspects applied to methods.
Public interface | IMethodLevelAspectBuildSemantics | Compile-time semantics of IMethodLevelAspect.
Public interface | IOnExceptionAspect | Runtime semantics of an aspect that, when applied on a method, defines an exception handler around the whole method body and let the implementation of this interface handle the exception.
Public interface | IOnMethodBoundaryAspect | Runtime semantics of OnMethodBoundaryAspect.
Public interface | IOnStateMachineBoundaryAspect | Extends the IOnMethodBoundaryAspect interface with two advises to be applied on state machines.
Public interface | IProtectedInterfaceT | Obsolete. Gives access to a 'protected' interface, typically introduced by a CompositionAspect or a IntroduceInterfaceAttribute
Public interface | ITypeLevelAspect | Run-time semantics of aspects applied to types.
Public interface | ITypeLevelAspectBuildSemantics | Compile-time semantics of ITypeLevelAspect.
Enumerations
 | Enumeration | Description
Public enumeration | FlowBehavior | Enumerates the possible behaviors of the calling method after the calling method has returned.


AdviceArgs Class

AdviceArgs Class
Base class for arguments of all advices.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsAdviceArgs
PostSharp.AspectsEventInterceptionArgs
PostSharp.AspectsLocationInterceptionArgs
PostSharp.AspectsMethodExecutionArgs
PostSharp.AspectsMethodInterceptionArgs

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class AdviceArgs

The AdviceArgs type exposes the following members.

Constructors
 | Name | Description
Public method | AdviceArgs | Initializes a new AdviceArgs.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration to which the advice has been applied.
Public property | Instance | Gets or sets the object instance on which the method is being executed.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


AdviceArgs Constructor

AdviceArgs Constructor
Initializes a new AdviceArgs.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdviceArgs(
    Object instance
)

Parameters

instance
Type: SystemObject
The instance related to the advice invocation, or null if the advice is associated to a static element of code.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AdviceArgs Class
PostSharp.Aspects Namespace


AdviceArgs Methods

AdviceArgs Methods

The AdviceArgs type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdviceArgs Class
PostSharp.Aspects Namespace


AdviceArgs Properties

AdviceArgs Properties

The AdviceArgs type exposes the following members.

Properties
 | Name | Description
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration to which the advice has been applied.
Public property | Instance | Gets or sets the object instance on which the method is being executed.
Top
See Also

Reference

AdviceArgs Class
PostSharp.Aspects Namespace


AdviceArgs.DeclarationIdentifier Property

AdviceArgsDeclarationIdentifier Property
Gets the DeclarationIdentifier of the declaration to which the advice has been applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeclarationIdentifier DeclarationIdentifier { get; set; }

Property Value

Type: DeclarationIdentifier
Remarks

For usage information, see the remarks of the DeclarationIdentifier type documentation.

Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: DeclarationIdentifier
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AdviceArgs Class
PostSharp.Aspects Namespace


AdviceArgs.Instance Property

AdviceArgsInstance Property
Gets or sets the object instance on which the method is being executed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Instance { get; set; }

Property Value

Type: Object
Remarks

This set may be set by user code only when the instance is a value type. As usually, user code is responsible for setting an object of the right type.

Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: Object
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AdviceArgs Class
PostSharp.Aspects Namespace


Arguments Class

Arguments Class
Encapsulation of method arguments.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsArguments

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class Arguments : IList<Object>,
    ICollection<Object>, IEnumerable<Object>, IEnumerable,
    ICloneable

The Arguments type exposes the following members.

Methods
 | Name | Description
Public method | Clone | Returns a shallow copy of the current object.
Public method | CopyFrom | Copies all the argument values from the elements of Array.
Public method | CopyTo | Copies all arguments values to the specified Array starting at the specified destination Array index.
 | Create(Object) | Creates a weakly-typed Arguments object representing any number of arguments.
 | CreateT(T) | Creates a strongly-typed Arguments object representing 1 argument.
 | CreateT0, T1(T0, T1) | Creates a strongly-typed Arguments object representing 2 arguments.
 | CreateT0, T1, T2(T0, T1, T2) | Creates a strongly-typed Arguments object representing 3 arguments.
 | CreateT0, T1, T2, T3(T0, T1, T2, T3) | Creates a strongly-typed Arguments object representing 4 arguments.
 | CreateT0, T1, T2, T3, T4(T0, T1, T2, T3, T4) | Creates a strongly-typed Arguments object representing 5 arguments.
 | CreateT0, T1, T2, T3, T4, T5(T0, T1, T2, T3, T4, T5) | Creates a strongly-typed Arguments object representing 6 arguments.
 | CreateT0, T1, T2, T3, T4, T5, T6(T0, T1, T2, T3, T4, T5, T6) | Creates a strongly-typed Arguments object representing 7 arguments.
 | CreateT0, T1, T2, T3, T4, T5, T6, T7(T0, T1, T2, T3, T4, T5, T6, T7) | Creates a strongly-typed Arguments object representing 8 arguments.
Public method | GetArgument | Gets the value of the argument at a given index.
Public method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public method | SetArgument | Sets the value of the argument at a given index.
Public method | ToArray | Converts the current argument list into an Array.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
Empty | Empty list of Arguments.
Top
Properties
 | Name | Description
Public property | Count | Gets the number of arguments encapsulated by the current object.
Public property | Item | Gets or sets the value of an argument.
Top
Remarks
Note Note
As a result of optimizations, an Arguments object may be shared between different advices. If an advice implementation needs to access an Arguments object after it has given over control, it should take a reference to a clone instead of the initial object itself.
Note Note
Implementations of this type should be considered an implementation detail and should not be accessed by user code.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


Arguments Fields

Arguments Fields

The Arguments type exposes the following members.

Fields
Name | Description
Empty | Empty list of Arguments.
Top
See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments.Empty Field

ArgumentsEmpty Field
Empty list of Arguments.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly Arguments Empty

Field Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments Methods

Arguments Methods

The Arguments type exposes the following members.

Methods
 | Name | Description
Public method | Clone | Returns a shallow copy of the current object.
Public method | CopyFrom | Copies all the argument values from the elements of Array.
Public method | CopyTo | Copies all arguments values to the specified Array starting at the specified destination Array index.
 | Create(Object) | Creates a weakly-typed Arguments object representing any number of arguments.
 | CreateT(T) | Creates a strongly-typed Arguments object representing 1 argument.
 | CreateT0, T1(T0, T1) | Creates a strongly-typed Arguments object representing 2 arguments.
 | CreateT0, T1, T2(T0, T1, T2) | Creates a strongly-typed Arguments object representing 3 arguments.
 | CreateT0, T1, T2, T3(T0, T1, T2, T3) | Creates a strongly-typed Arguments object representing 4 arguments.
 | CreateT0, T1, T2, T3, T4(T0, T1, T2, T3, T4) | Creates a strongly-typed Arguments object representing 5 arguments.
 | CreateT0, T1, T2, T3, T4, T5(T0, T1, T2, T3, T4, T5) | Creates a strongly-typed Arguments object representing 6 arguments.
 | CreateT0, T1, T2, T3, T4, T5, T6(T0, T1, T2, T3, T4, T5, T6) | Creates a strongly-typed Arguments object representing 7 arguments.
 | CreateT0, T1, T2, T3, T4, T5, T6, T7(T0, T1, T2, T3, T4, T5, T6, T7) | Creates a strongly-typed Arguments object representing 8 arguments.
Public method | GetArgument | Gets the value of the argument at a given index.
Public method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public method | SetArgument | Sets the value of the argument at a given index.
Public method | ToArray | Converts the current argument list into an Array.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments.Clone Method

ArgumentsClone Method
Returns a shallow copy of the current object.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Arguments Clone()

Return Value

Type: Arguments
A shallow copy of the current object.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments.CopyFrom Method

ArgumentsCopyFrom Method
Copies all the argument values from the elements of Array.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void CopyFrom(
    Object[] array,
    int index
)

Parameters

array
Type: SystemObject
The array that is the source of the argument values copied into the current Arguments.
index
Type: SystemInt32
An integer that represents the index in array at which copying begins.
Exceptions
Exception | Condition
ArgumentNullException | array is null.
ArgumentOutOfRangeException | index is lower than zero.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Arguments Class
PostSharp.Aspects Namespace
ArgumentsCopyTo(Object, Int32)


Arguments.CopyTo Method

ArgumentsCopyTo Method
Copies all arguments values to the specified Array starting at the specified destination Array index.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void CopyTo(
    Object[] array,
    int index
)

Parameters

array
Type: SystemObject
The array that is the destination of argument values copied from the current Arguments.
index
Type: SystemInt32
An integer that represents the index in array at which copying begins

Implements

ICollectionTCopyTo(T, Int32)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Arguments Class
PostSharp.Aspects Namespace
ArgumentsCopyFrom(Object, Int32)


Arguments.Create Method

ArgumentsCreate Method
Overload List
Name | Description
Create(Object) | Creates a weakly-typed Arguments object representing any number of arguments.
CreateT(T) | Creates a strongly-typed Arguments object representing 1 argument.
CreateT0, T1(T0, T1) | Creates a strongly-typed Arguments object representing 2 arguments.
CreateT0, T1, T2(T0, T1, T2) | Creates a strongly-typed Arguments object representing 3 arguments.
CreateT0, T1, T2, T3(T0, T1, T2, T3) | Creates a strongly-typed Arguments object representing 4 arguments.
CreateT0, T1, T2, T3, T4(T0, T1, T2, T3, T4) | Creates a strongly-typed Arguments object representing 5 arguments.
CreateT0, T1, T2, T3, T4, T5(T0, T1, T2, T3, T4, T5) | Creates a strongly-typed Arguments object representing 6 arguments.
CreateT0, T1, T2, T3, T4, T5, T6(T0, T1, T2, T3, T4, T5, T6) | Creates a strongly-typed Arguments object representing 7 arguments.
CreateT0, T1, T2, T3, T4, T5, T6, T7(T0, T1, T2, T3, T4, T5, T6, T7) | Creates a strongly-typed Arguments object representing 8 arguments.
Top
See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments.Create Method (Object[])

ArgumentsCreate Method (Object)
Creates a weakly-typed Arguments object representing any number of arguments.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Arguments Create(
    params Object[] array
)

Parameters

array
Type: SystemObject

Return Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Arguments Class
Create Overload
PostSharp.Aspects Namespace


Arguments.Create(T) Method (T)

ArgumentsCreateT Method (T)
Creates a strongly-typed Arguments object representing 1 argument.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Arguments Create<T>(
    T arg0
)

Parameters

arg0
Type: T

Type Parameters

T

Return Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Arguments Class
Create Overload
PostSharp.Aspects Namespace


Arguments.Create(T0, T1) Method (T0, T1)

ArgumentsCreateT0, T1 Method (T0, T1)
Creates a strongly-typed Arguments object representing 2 arguments.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Arguments Create<T0, T1>(
    T0 arg0,
    T1 arg1
)

Parameters

arg0
Type: T0
arg1
Type: T1

Type Parameters

T0
T1

Return Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Arguments Class
Create Overload
PostSharp.Aspects Namespace


Arguments.Create(T0, T1, T2) Method (T0, T1, T2)

ArgumentsCreateT0, T1, T2 Method (T0, T1, T2)
Creates a strongly-typed Arguments object representing 3 arguments.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Arguments Create<T0, T1, T2>(
    T0 arg0,
    T1 arg1,
    T2 arg2
)

Parameters

arg0
Type: T0
arg1
Type: T1
arg2
Type: T2

Type Parameters

T0
T1
T2

Return Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Arguments Class
Create Overload
PostSharp.Aspects Namespace


Arguments.Create(T0, T1, T2, T3) Method (T0, T1, T2, T3)

ArgumentsCreateT0, T1, T2, T3 Method (T0, T1, T2, T3)
Creates a strongly-typed Arguments object representing 4 arguments.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Arguments Create<T0, T1, T2, T3>(
    T0 arg0,
    T1 arg1,
    T2 arg2,
    T3 arg3
)

Parameters

arg0
Type: T0
arg1
Type: T1
arg2
Type: T2
arg3
Type: T3

Type Parameters

T0
T1
T2
T3

Return Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Arguments Class
Create Overload
PostSharp.Aspects Namespace


Arguments.Create(T0, T1, T2, T3, T4) Method (T0, T1, T2, T3, T4)

ArgumentsCreateT0, T1, T2, T3, T4 Method (T0, T1, T2, T3, T4)
Creates a strongly-typed Arguments object representing 5 arguments.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Arguments Create<T0, T1, T2, T3, T4>(
    T0 arg0,
    T1 arg1,
    T2 arg2,
    T3 arg3,
    T4 arg4
)

Parameters

arg0
Type: T0
arg1
Type: T1
arg2
Type: T2
arg3
Type: T3
arg4
Type: T4

Type Parameters

T0
T1
T2
T3
T4

Return Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Arguments Class
Create Overload
PostSharp.Aspects Namespace


Arguments.Create(T0, T1, T2, T3, T4, T5) Method (T0, T1, T2, T3, T4, T5)

ArgumentsCreateT0, T1, T2, T3, T4, T5 Method (T0, T1, T2, T3, T4, T5)
Creates a strongly-typed Arguments object representing 6 arguments.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Arguments Create<T0, T1, T2, T3, T4, T5>(
    T0 arg0,
    T1 arg1,
    T2 arg2,
    T3 arg3,
    T4 arg4,
    T5 args5
)

Parameters

arg0
Type: T0
arg1
Type: T1
arg2
Type: T2
arg3
Type: T3
arg4
Type: T4
args5
Type: T5

Type Parameters

T0
T1
T2
T3
T4
T5

Return Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Arguments Class
Create Overload
PostSharp.Aspects Namespace


Arguments.Create(T0, T1, T2, T3, T4, T5, T6) Method (T0, T1, T2, T3, T4, T5, T6)

ArgumentsCreateT0, T1, T2, T3, T4, T5, T6 Method (T0, T1, T2, T3, T4, T5, T6)
Creates a strongly-typed Arguments object representing 7 arguments.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Arguments Create<T0, T1, T2, T3, T4, T5, T6>(
    T0 arg0,
    T1 arg1,
    T2 arg2,
    T3 arg3,
    T4 arg4,
    T5 args5,
    T6 args6
)

Parameters

arg0
Type: T0
arg1
Type: T1
arg2
Type: T2
arg3
Type: T3
arg4
Type: T4
args5
Type: T5
args6
Type: T6

Type Parameters

T0
T1
T2
T3
T4
T5
T6

Return Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Arguments Class
Create Overload
PostSharp.Aspects Namespace


Arguments.Create(T0, T1, T2, T3, T4, T5, T6, T7) Method (T0, T1, T2, T3, T4, T5, T6, T7)

ArgumentsCreateT0, T1, T2, T3, T4, T5, T6, T7 Method (T0, T1, T2, T3, T4, T5, T6, T7)
Creates a strongly-typed Arguments object representing 8 arguments.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Arguments Create<T0, T1, T2, T3, T4, T5, T6, T7>(
    T0 arg0,
    T1 arg1,
    T2 arg2,
    T3 arg3,
    T4 arg4,
    T5 args5,
    T6 args6,
    T7 args7
)

Parameters

arg0
Type: T0
arg1
Type: T1
arg2
Type: T2
arg3
Type: T3
arg4
Type: T4
args5
Type: T5
args6
Type: T6
args7
Type: T7

Type Parameters

T0
T1
T2
T3
T4
T5
T6
T7

Return Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Arguments Class
Create Overload
PostSharp.Aspects Namespace


Arguments.GetArgument Method

ArgumentsGetArgument Method
Gets the value of the argument at a given index.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object GetArgument(
    int index
)

Parameters

index
Type: SystemInt32
Argument index.

Return Value

Type: Object
The value of the argument at position index.
Exceptions
Exception | Condition
ArgumentOutOfRangeException | index is lower than zero or greater or equal than Count.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments.GetEnumerator Method

ArgumentsGetEnumerator Method
Returns an enumerator that iterates through the collection.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IEnumerator<Object> GetEnumerator()

Return Value

Type: IEnumerator Object
A IEnumeratorT that can be used to iterate through the collection.

Implements

IEnumerableTGetEnumerator
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments.SetArgument Method

ArgumentsSetArgument Method
Sets the value of the argument at a given index.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void SetArgument(
    int index,
    Object value
)

Parameters

index
Type: SystemInt32
Argument index.
value
Type: SystemObject
New value of the argument at position index.
Exceptions
Exception | Condition
InvalidCastException | value is not assignable to parameter at position index.
ArgumentOutOfRangeException | index is lower than zero or greater or equal than Count.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments.ToArray Method

ArgumentsToArray Method
Converts the current argument list into an Array.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object[] ToArray()

Return Value

Type: Object
An Array whose elements are equal to the values encapsulated by the current Arguments.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments Properties

Arguments Properties

The Arguments type exposes the following members.

Properties
 | Name | Description
Public property | Count | Gets the number of arguments encapsulated by the current object.
Public property | Item | Gets or sets the value of an argument.
Top
See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments.Count Property

ArgumentsCount Property
Gets the number of arguments encapsulated by the current object.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int Count { get; }

Property Value

Type: Int32

Implements

ICollectionTCount
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Arguments.Item Property

ArgumentsItem Property
Gets or sets the value of an argument.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object this[
    int index
] { get; set; }

Parameters

index
Type: SystemInt32
Argument index.

Return Value

Type: Object
The argument value.

Implements

IListTItemInt32
Exceptions
Exception | Condition
ArgumentOutOfRangeException | index is lower than zero or greater or equal than Count.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Arguments Class
PostSharp.Aspects Namespace


Aspect Class

Aspect Class
Base class for all aspects that are declared using multicast custom attributes (MulticastAttribute).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
More...

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class Aspect : MulticastAttribute,
    IAspect, IAspectBuildSemantics, IValidableAnnotation

The Aspect type exposes the following members.

Constructors
 | Name | Description
Protected method | Aspect | Initializes a new instance of the Aspect class
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect.
Protected method | SetAspectConfiguration | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect.
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime.
Top
Remarks

This class is not specific to any kind of declaration (method, field, type, ...). Considering deriving your aspect from TypeLevelAspect, MethodLevelAspect, LocationLevelAspect, or EventLevelAspect if it should be applied to a specific kind of declarations.

Note Note
This class does not provide any advice. You may derive your aspect class from a class providing predefined advice , or build a composite aspect .

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Aspect Classes
Conceptual Documentation: Developing Complex Aspects
Conceptual Documentation: Aspect Serialization
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsAssemblyLevelAspect
PostSharp.AspectsEventLevelAspect
PostSharp.AspectsExternalAspect
PostSharp.AspectsFieldLevelAspect
PostSharp.AspectsLocationLevelAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.AspectsTypeLevelAspect


Aspect Constructor

Aspect Constructor
Initializes a new instance of the Aspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected Aspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Aspect Class
PostSharp.Aspects Namespace


Aspect Methods

Aspect Methods

The Aspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect.
Protected method | SetAspectConfiguration | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

Aspect Class
PostSharp.Aspects Namespace


Aspect.CompileTimeValidate Method

AspectCompileTimeValidate Method
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the aspect has been applied.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Aspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


Aspect.CreateAspectConfiguration Method

AspectCreateAspectConfiguration Method
Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the Aspect.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration, Object) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Aspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


Aspect.GetAspectConfiguration Method

AspectGetAspectConfiguration Method
Method invoked at build tome to get the imperative configuration of the current Aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectConfiguration GetAspectConfiguration(
    Object targetElement
)

Parameters

targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current Aspect has been applied.

Return Value

Type: AspectConfiguration
An AspectConfiguration representing the imperative configuration of the current Aspect.

Implements

IAspectBuildSemanticsGetAspectConfiguration(Object)
Remarks

This method can be customized by overriding CreateAspectConfiguration and/or SetAspectConfiguration(AspectConfiguration, Object)

.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Aspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


Aspect.SetAspectConfiguration Method

AspectSetAspectConfiguration Method
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    Object targetElement
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current Aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Aspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


Aspect Properties

Aspect Properties

The Aspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect.
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime.
Top
See Also

Reference

Aspect Class
PostSharp.Aspects Namespace


Aspect.AspectPriority Property

AspectAspectPriority Property
Gets or sets the weaving priority of the aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int AspectPriority { get; set; }

Property Value

Type: Int32
The aspect priority, or null if the aspect priority is not specified.
Remarks

Advices with lower priority are executed before in case of 'entry' semantics (entering or invoking a method, setting a field value), but this order is inverted for advices of 'exit' semantics (leaving a method, getting a field value).

This property must not be confused with AttributePriority, which solely influences the multicasting process.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Aspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Coping with Several Aspects on the Same Target


Aspect.SerializerType Property

AspectSerializerType Property
Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected Type SerializerType { get; set; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Aspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Aspect Serialization


AspectInfo Class

AspectInfo Class
Reserved for future usage.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsAspectInfo

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AspectInfo

The AspectInfo type exposes the following members.

Constructors
 | Name | Description
Public method | AspectInfo | Initializes a new instance of the AspectInfo class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


AspectInfo Constructor

AspectInfo Constructor
Initializes a new instance of the AspectInfo class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectInfo()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectInfo Class
PostSharp.Aspects Namespace


AspectInfo Methods

AspectInfo Methods

The AspectInfo type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectInfo Class
PostSharp.Aspects Namespace


AspectInstance Class

AspectInstance Class
Completely specifies an aspect instance, including its target code element. An AspectInstance contains either the aspect instance itself (Aspect property), either information allowing to construct the aspect (AspectConstruction) and configure the weaver (AspectConfiguration).
Inheritance Hierarchy
SystemObject
PostSharp.AspectsAspectSpecification
PostSharp.AspectsAspectInstance

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AspectInstance : AspectSpecification

The AspectInstance type exposes the following members.

Constructors
 | Name | Description
Public method | AspectInstance(Object, IAspect) | Initializes a new AspectInstance from a runtime aspect instance (IAspect).
Public method | AspectInstance(Object, IAspect, AspectConfiguration) | Initializes a new AspectInstance from a runtime aspect instance (IAspect) and its AspectConfiguration.
Public method | AspectInstance(Object, ObjectConstruction, AspectConfiguration) | Initializes a new AspectInstance from
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Aspect | Gets the aspect instance. (Inherited from AspectSpecification.)
Public property | AspectAssemblyQualifiedTypeName | Gets the assembly-qualified type name of the aspect. (Inherited from AspectSpecification.)
Public property | AspectConfiguration | Gets the aspect configuration. (Inherited from AspectSpecification.)
Public property | AspectConstruction | Gets the aspect construction. (Inherited from AspectSpecification.)
Public property | AspectTypeName | Gets the type name of the aspect. (Inherited from AspectSpecification.)
Public property | TargetElement | Gets the code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current AspectInstance is applied.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Adding Aspects Dynamically


AspectInstance Constructor

AspectInstance Constructor
Overload List
 | Name | Description
Public method | AspectInstance(Object, IAspect) | Initializes a new AspectInstance from a runtime aspect instance (IAspect).
Public method | AspectInstance(Object, IAspect, AspectConfiguration) | Initializes a new AspectInstance from a runtime aspect instance (IAspect) and its AspectConfiguration.
Public method | AspectInstance(Object, ObjectConstruction, AspectConfiguration) | Initializes a new AspectInstance from
Top
See Also

Reference

AspectInstance Class
PostSharp.Aspects Namespace


AspectInstance Constructor (Object, IAspect)

AspectInstance Constructor (Object, IAspect)
Initializes a new AspectInstance from a runtime aspect instance (IAspect).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectInstance(
    Object targetElement,
    IAspect aspect
)

Parameters

targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current AspectInstance is applied.
aspect
Type: PostSharp.AspectsIAspect
The aspect runtime instance.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectInstance Class
AspectInstance Overload
PostSharp.Aspects Namespace


AspectInstance Constructor (Object, IAspect, AspectConfiguration)

AspectInstance Constructor (Object, IAspect, AspectConfiguration)
Initializes a new AspectInstance from a runtime aspect instance (IAspect) and its AspectConfiguration.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectInstance(
    Object targetElement,
    IAspect aspect,
    AspectConfiguration aspectConfiguration
)

Parameters

targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current AspectInstance is applied.
aspect
Type: PostSharp.AspectsIAspect
The aspect runtime instance.
aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The aspect configuration (the type of this parameter should be equal to the type configuration objects expected by the concrete aspect).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectInstance Class
AspectInstance Overload
PostSharp.Aspects Namespace


AspectInstance Constructor (Object, ObjectConstruction, AspectConfiguration)

AspectInstance Constructor (Object, ObjectConstruction, AspectConfiguration)
Initializes a new AspectInstance from

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectInstance(
    Object targetElement,
    ObjectConstruction aspectConstruction,
    AspectConfiguration aspectConfiguration
)

Parameters

targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current AspectInstance is applied.
aspectConstruction
Type: PostSharp.ReflectionObjectConstruction
An ObjectConstruction instructing how the aspect instance should be constructed.
aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
An optional configuration object whose type corresponds to the aspect type.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectInstance Class
AspectInstance Overload
PostSharp.Aspects Namespace


AspectInstance Methods

AspectInstance Methods

The AspectInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectInstance Class
PostSharp.Aspects Namespace


AspectInstance Properties

AspectInstance Properties

The AspectInstance type exposes the following members.

Properties
 | Name | Description
Public property | Aspect | Gets the aspect instance. (Inherited from AspectSpecification.)
Public property | AspectAssemblyQualifiedTypeName | Gets the assembly-qualified type name of the aspect. (Inherited from AspectSpecification.)
Public property | AspectConfiguration | Gets the aspect configuration. (Inherited from AspectSpecification.)
Public property | AspectConstruction | Gets the aspect construction. (Inherited from AspectSpecification.)
Public property | AspectTypeName | Gets the type name of the aspect. (Inherited from AspectSpecification.)
Public property | TargetElement | Gets the code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current AspectInstance is applied.
Top
See Also

Reference

AspectInstance Class
PostSharp.Aspects Namespace


AspectInstance.TargetElement Property

AspectInstanceTargetElement Property
Gets the code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current AspectInstance is applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object TargetElement { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectInstance Class
PostSharp.Aspects Namespace


AspectSpecification Class

AspectSpecification Class
Completely specifies an aspect instance (but not its target). An AspectSpecification either the aspect instance itself (Aspect property), either information allowing to construct the aspect (AspectConstruction) and configure the weaver (AspectConfiguration).
Inheritance Hierarchy
SystemObject
PostSharp.AspectsAspectSpecification
PostSharp.AspectsAspectInstance

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class AspectSpecification

The AspectSpecification type exposes the following members.

Constructors
 | Name | Description
Protected method | AspectSpecification | Initializes a new AspectSpecification when one cannot provide an aspect instance, i.e. from an ObjectConstruction and a AspectConfiguration.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Aspect | Gets the aspect instance.
Public property | AspectAssemblyQualifiedTypeName | Gets the assembly-qualified type name of the aspect.
Public property | AspectConfiguration | Gets the aspect configuration.
Public property | AspectConstruction | Gets the aspect construction.
Public property | AspectTypeName | Gets the type name of the aspect.
Top
Remarks
User code cannot create an instance of the AspectSpecification class. Always create an instance of AspectInstance instead.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


AspectSpecification Constructor

AspectSpecification Constructor
Initializes a new AspectSpecification when one cannot provide an aspect instance, i.e. from an ObjectConstruction and a AspectConfiguration.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AspectSpecification(
    ObjectConstruction aspectConstruction,
    AspectConfiguration aspectConfiguration
)

Parameters

aspectConstruction
Type: PostSharp.ReflectionObjectConstruction
Aspect construction.
aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
Aspect configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectSpecification Class
PostSharp.Aspects Namespace


AspectSpecification Methods

AspectSpecification Methods

The AspectSpecification type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectSpecification Class
PostSharp.Aspects Namespace


AspectSpecification Properties

AspectSpecification Properties

The AspectSpecification type exposes the following members.

Properties
 | Name | Description
Public property | Aspect | Gets the aspect instance.
Public property | AspectAssemblyQualifiedTypeName | Gets the assembly-qualified type name of the aspect.
Public property | AspectConfiguration | Gets the aspect configuration.
Public property | AspectConstruction | Gets the aspect construction.
Public property | AspectTypeName | Gets the type name of the aspect.
Top
See Also

Reference

AspectSpecification Class
PostSharp.Aspects Namespace


AspectSpecification.Aspect Property

AspectSpecificationAspect Property
Gets the aspect instance.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IAspect Aspect { get; }

Property Value

Type: IAspect
The aspect instance, or null if the AspectConfiguration was provided instead.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectSpecification Class
PostSharp.Aspects Namespace


AspectSpecification.AspectAssemblyQualifiedTypeName Property

AspectSpecificationAspectAssemblyQualifiedTypeName Property
Gets the assembly-qualified type name of the aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string AspectAssemblyQualifiedTypeName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectSpecification Class
PostSharp.Aspects Namespace


AspectSpecification.AspectConfiguration Property

AspectSpecificationAspectConfiguration Property
Gets the aspect configuration.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectConfiguration AspectConfiguration { get; }

Property Value

Type: AspectConfiguration
The aspect configuration, or null if none was provided.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectSpecification Class
PostSharp.Aspects Namespace


AspectSpecification.AspectConstruction Property

AspectSpecificationAspectConstruction Property
Gets the aspect construction.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectConstruction AspectConstruction { get; }

Property Value

Type: ObjectConstruction
The aspect construction, or null if the aspect instance was provided instead.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectSpecification Class
PostSharp.Aspects Namespace


AspectSpecification.AspectTypeName Property

AspectSpecificationAspectTypeName Property
Gets the type name of the aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string AspectTypeName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectSpecification Class
PostSharp.Aspects Namespace


AspectUtilities Class

AspectUtilities Class
Utility methods for PostSharp.Aspects.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsAspectUtilities

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AspectUtilities

The AspectUtilities type exposes the following members.

Constructors
 | Name | Description
Public method | AspectUtilities | Initializes a new instance of the AspectUtilities class
Top
Methods
Name | Description
GetCurrentInstanceCredentials | Obsolete. Gets the InstanceCredentials of the calling instance. This method must be invoked from an instance method (not a static method) of a type that has been enhanced by an aspect.
InitializeCurrentAspects | Initializes the all the aspects of the calling instance. This method must be invoked from an instance method (not a static method) of a type that has been enhanced by an aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


AspectUtilities Constructor

AspectUtilities Constructor
Initializes a new instance of the AspectUtilities class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectUtilities()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectUtilities Class
PostSharp.Aspects Namespace


AspectUtilities Methods

AspectUtilities Methods

The AspectUtilities type exposes the following members.

Methods
Name | Description
GetCurrentInstanceCredentials | Obsolete. Gets the InstanceCredentials of the calling instance. This method must be invoked from an instance method (not a static method) of a type that has been enhanced by an aspect.
InitializeCurrentAspects | Initializes the all the aspects of the calling instance. This method must be invoked from an instance method (not a static method) of a type that has been enhanced by an aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectUtilities Class
PostSharp.Aspects Namespace


AspectUtilities.GetCurrentInstanceCredentials Method

AspectUtilitiesGetCurrentInstanceCredentials Method

Note: This API is now obsolete.

Gets the InstanceCredentials of the calling instance. This method must be invoked from an instance method (not a static method) of a type that has been enhanced by an aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute]
public static InstanceCredentials GetCurrentInstanceCredentials()

Return Value

Type: InstanceCredentials
The InstanceCredentials of the calling instance.
Remarks

Calls to this method are transformed, at build time, to calls to this.GetInstanceCredentials, a method that is typically generated by PostSharp. This is why the current method has actually no implementation.

Note Note
Aspect credentials are considered obsolete and their use should be avoided.
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

AspectUtilities Class
PostSharp.Aspects Namespace


AspectUtilities.InitializeCurrentAspects Method

AspectUtilitiesInitializeCurrentAspects Method
Initializes the all the aspects of the calling instance. This method must be invoked from an instance method (not a static method) of a type that has been enhanced by an aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void InitializeCurrentAspects()
Remarks

Calls to this method are transformed, at build time, to calls to this.InitializeAspects, a method that is typically generated by PostSharp. This is why the current method has actually no implementation.

The constructors of enhanced classes always initialize aspects. The only scenario where this method needs to be invoked manually is when instances are not built using the constructor, but for instance with the method GetUninitializedObject(Type).

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectUtilities Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Coping with Custom Serializers


AssemblyLevelAspect Class

AssemblyLevelAspect Class
Base class for all aspects applied on assemblies.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsAssemblyLevelAspect
PostSharp.Patterns.ThreadingDeadlockDetectionPolicy

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class AssemblyLevelAspect : Aspect,
    IAssemblyLevelAspect, IAssemblyLevelAspectBuildSemantics, IAspect

The AssemblyLevelAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | AssemblyLevelAspect | Initializes a new instance of the AssemblyLevelAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(Assembly) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, Assembly) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks
Note Note
This class does not provide any advice. You may derive your aspect class from a class providing predefined advice , or build a composite aspect .

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsIAssemblyLevelAspect

Other Resources

Conceptual Documentation: Aspect Classes
Conceptual Documentation: Developing Complex Aspects
Conceptual Documentation: Aspect Serialization


AssemblyLevelAspect Constructor

AssemblyLevelAspect Constructor
Initializes a new instance of the AssemblyLevelAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AssemblyLevelAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AssemblyLevelAspect Class
PostSharp.Aspects Namespace


AssemblyLevelAspect Methods

AssemblyLevelAspect Methods

The AssemblyLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(Assembly) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, Assembly) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AssemblyLevelAspect Class
PostSharp.Aspects Namespace


AssemblyLevelAspect.CompileTimeInitialize Method

AssemblyLevelAspectCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void CompileTimeInitialize(
    Assembly assembly,
    AspectInfo aspectInfo
)

Parameters

assembly
Type: System.ReflectionAssembly
Assembly to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.

Implements

IAssemblyLevelAspectBuildSemanticsCompileTimeInitialize(Assembly, AspectInfo)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AssemblyLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


AssemblyLevelAspect.CompileTimeValidate Method

AssemblyLevelAspectCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(Assembly) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
See Also

Reference

AssemblyLevelAspect Class
PostSharp.Aspects Namespace


AssemblyLevelAspect.CompileTimeValidate Method (Object)

AssemblyLevelAspectCompileTimeValidate Method (Object)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override sealed bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the aspect has been applied.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AssemblyLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


AssemblyLevelAspect.CompileTimeValidate Method (Assembly)

AssemblyLevelAspectCompileTimeValidate Method (Assembly)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual bool CompileTimeValidate(
    Assembly assembly
)

Parameters

assembly
Type: System.ReflectionAssembly
Assembly on which the current aspect is applied.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AssemblyLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


AssemblyLevelAspect.SetAspectConfiguration Method

AssemblyLevelAspectSetAspectConfiguration Method
Overload List
 | Name | Description
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, Assembly) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
See Also

Reference

AssemblyLevelAspect Class
PostSharp.Aspects Namespace


AssemblyLevelAspect.SetAspectConfiguration Method (AspectConfiguration, Object)

AssemblyLevelAspectSetAspectConfiguration Method (AspectConfiguration, Object)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    Object targetElement
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current Aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AssemblyLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


AssemblyLevelAspect.SetAspectConfiguration Method (AspectConfiguration, Assembly)

AssemblyLevelAspectSetAspectConfiguration Method (AspectConfiguration, Assembly)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    Assembly targetAssembly
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetAssembly
Type: System.ReflectionAssembly
Assembly to which the current aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AssemblyLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


AssemblyLevelAspect Properties

AssemblyLevelAspect Properties

The AssemblyLevelAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

AssemblyLevelAspect Class
PostSharp.Aspects Namespace


CompositionAspect Class

CompositionAspect Class
Aspect that, when applied on a type, introduces one or many new interfaces into that type.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsCompositionAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class CompositionAspect : TypeLevelAspect,
    ICompositionAspect, ITypeLevelAspect, IAspect

The CompositionAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | CompositionAspect | Initializes a new instance of the CompositionAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | CreateImplementationObject | Method invoked at runtime, during the initialization of instances of the target type, to create the composed object.
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | GetPublicInterfaces | Gets the array of interfaces that should be introduced publicly into the target type of the current aspect.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides TypeLevelAspectSetAspectConfiguration(AspectConfiguration, Type).)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Protected property | AncestorOverrideAction | Specifies the action (Fail or Ignore) to be overtaken when an ancestor of one of the interfaces returned by GetPublicInterfaces(Type) is already implemented by the type to which the current aspect is applied.
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | GenerateImplementationAccessor | Determines whether the interface IComposedT should be introduced into the type to which the aspect is applied for each interface returned by the GetPublicInterfaces(Type) method.
Protected property | NonSerializedImplementation | Determines whether the field containing the interface implementation (and storing the object returned by CreateImplementationObject(AdviceArgs)) should be excluded from serialization by BinaryFormatter. The same effect is typically obtained by applying the NonSerializedAttribute custom attribute to the field.
Protected property | OverrideAction | Specifies the action (Fail or Ignore) to be overtaken when one of the interfaces returned by GetPublicInterfaces(Type) or GetProtectedInterfaces(Type) is already implemented by the type to which the current aspect is applied.
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks
Note Note
Consider using a composite aspect introducing an interface instead of using a CompositionAspect. For details, see Introducing Interfaces.

Methods GetPublicInterfaces(Type) and GetProtectedInterfaces(Type) are invoked at build time. At runtime, the method CreateImplementationObject(AdviceArgs) should return an object implementing all interfaces.

Use the Post.CastSourceType, TargetType(SourceType) method to cast the enhanced type to the newly implemented interface. This cast is verified during post-compilation.

Properties OverrideAction and AncestorOverrideAction determine what should happen if the target type already implements the interface directly or indirectly.

By default, the object implementing the interface is stored as a serializable field. If the property NonSerializedImplementation is set to true, this field will be marked as NonSerializedAttribute.

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Examples

Example: Dynamically Introducing an Interface

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.Aspects.AdvicesIntroduceInterfaceAttribute

Other Resources

Conceptual Documentation: Aspect Serialization
Conceptual Documentation: Introducing Interfaces


CompositionAspect Constructor

CompositionAspect Constructor
Initializes a new instance of the CompositionAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected CompositionAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace


CompositionAspect Methods

CompositionAspect Methods

The CompositionAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | CreateImplementationObject | Method invoked at runtime, during the initialization of instances of the target type, to create the composed object.
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | GetPublicInterfaces | Gets the array of interfaces that should be introduced publicly into the target type of the current aspect.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides TypeLevelAspectSetAspectConfiguration(AspectConfiguration, Type).)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace


CompositionAspect.CreateAspectConfiguration Method

CompositionAspectCreateAspectConfiguration Method
Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the Aspect.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration, Object) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


CompositionAspect.CreateImplementationObject Method

CompositionAspectCreateImplementationObject Method
Method invoked at runtime, during the initialization of instances of the target type, to create the composed object.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract Object CreateImplementationObject(
    AdviceArgs args
)

Parameters

args
Type: PostSharp.AspectsAdviceArgs

Return Value

Type: Object
The composed object. This interface should implement the interfaces specified by the GetPublicInterfaces(Type) and GetProtectedInterfaces(Type) methods.

Implements

ICompositionAspectCreateImplementationObject(AdviceArgs)
Remarks
This method is invoked during at runtime after the base constructor has executed, and before the constructor of the current type is executed.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace


CompositionAspect.GetPublicInterfaces Method

CompositionAspectGetPublicInterfaces Method
Gets the array of interfaces that should be introduced publicly into the target type of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual Type[] GetPublicInterfaces(
    Type targetType
)

Parameters

targetType
Type: SystemType
Type to which the current aspect is applied.

Return Value

Type: Type
The array of interfaces that should be introduced publicly into Type targetType, or null if no interface should be introduced publicly.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace


CompositionAspect.SetAspectConfiguration Method

CompositionAspectSetAspectConfiguration Method
Overload List
 | Name | Description
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides TypeLevelAspectSetAspectConfiguration(AspectConfiguration, Type).)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace


CompositionAspect.SetAspectConfiguration Method (AspectConfiguration, Type)

CompositionAspectSetAspectConfiguration Method (AspectConfiguration, Type)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    Type targetType
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetType
Type: SystemType
Type to which the current aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


CompositionAspect Properties

CompositionAspect Properties

The CompositionAspect type exposes the following members.

Properties
 | Name | Description
Protected property | AncestorOverrideAction | Specifies the action (Fail or Ignore) to be overtaken when an ancestor of one of the interfaces returned by GetPublicInterfaces(Type) is already implemented by the type to which the current aspect is applied.
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | GenerateImplementationAccessor | Determines whether the interface IComposedT should be introduced into the type to which the aspect is applied for each interface returned by the GetPublicInterfaces(Type) method.
Protected property | NonSerializedImplementation | Determines whether the field containing the interface implementation (and storing the object returned by CreateImplementationObject(AdviceArgs)) should be excluded from serialization by BinaryFormatter. The same effect is typically obtained by applying the NonSerializedAttribute custom attribute to the field.
Protected property | OverrideAction | Specifies the action (Fail or Ignore) to be overtaken when one of the interfaces returned by GetPublicInterfaces(Type) or GetProtectedInterfaces(Type) is already implemented by the type to which the current aspect is applied.
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace


CompositionAspect.AncestorOverrideAction Property

CompositionAspectAncestorOverrideAction Property
Specifies the action (Fail or Ignore) to be overtaken when an ancestor of one of the interfaces returned by GetPublicInterfaces(Type) is already implemented by the type to which the current aspect is applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected InterfaceOverrideAction AncestorOverrideAction { get; set; }

Property Value

Type: InterfaceOverrideAction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace
CompositionAspectOverrideAction


CompositionAspect.GenerateImplementationAccessor Property

CompositionAspectGenerateImplementationAccessor Property
Determines whether the interface IComposedT should be introduced into the type to which the aspect is applied for each interface returned by the GetPublicInterfaces(Type) method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected bool GenerateImplementationAccessor { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace


CompositionAspect.NonSerializedImplementation Property

CompositionAspectNonSerializedImplementation Property
Determines whether the field containing the interface implementation (and storing the object returned by CreateImplementationObject(AdviceArgs)) should be excluded from serialization by BinaryFormatter. The same effect is typically obtained by applying the NonSerializedAttribute custom attribute to the field.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected bool NonSerializedImplementation { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace


CompositionAspect.OverrideAction Property

CompositionAspectOverrideAction Property
Specifies the action (Fail or Ignore) to be overtaken when one of the interfaces returned by GetPublicInterfaces(Type) or GetProtectedInterfaces(Type) is already implemented by the type to which the current aspect is applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected InterfaceOverrideAction OverrideAction { get; set; }

Property Value

Type: InterfaceOverrideAction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspect Class
PostSharp.Aspects Namespace
CompositionAspectAncestorOverrideAction


ConstructorDepth Structure

ConstructorDepth Structure
System type used in the implementation of the OnInstanceConstructedAdvice. Do not use in user code.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public struct ConstructorDepth

The ConstructorDepth type exposes the following members.

Methods
 | Name | Description
Public method | Increment | Creates a new instance of the ConstructorDepth type with a depth level that is one more than the current one.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsZero | Determines whether the current depth is zero.
 | Zero | Gets a ConstructorDepth instance representing zero.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects Namespace


ConstructorDepth Methods

ConstructorDepth Methods

The ConstructorDepth type exposes the following members.

Methods
 | Name | Description
Public method | Increment | Creates a new instance of the ConstructorDepth type with a depth level that is one more than the current one.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ConstructorDepth Structure
PostSharp.Aspects Namespace


ConstructorDepth.Increment Method

ConstructorDepthIncrement Method
Creates a new instance of the ConstructorDepth type with a depth level that is one more than the current one.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ConstructorDepth Increment()

Return Value

Type: ConstructorDepth
A new ConstructorDepth, incremented of one from the current ConstructorDepth.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ConstructorDepth Structure
PostSharp.Aspects Namespace


ConstructorDepth Properties

ConstructorDepth Properties

The ConstructorDepth type exposes the following members.

Properties
 | Name | Description
Public property | IsZero | Determines whether the current depth is zero.
 | Zero | Gets a ConstructorDepth instance representing zero.
Top
See Also

Reference

ConstructorDepth Structure
PostSharp.Aspects Namespace


ConstructorDepth.IsZero Property

ConstructorDepthIsZero Property
Determines whether the current depth is zero.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsZero { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ConstructorDepth Structure
PostSharp.Aspects Namespace


ConstructorDepth.Zero Property

ConstructorDepthZero Property
Gets a ConstructorDepth instance representing zero.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static ConstructorDepth Zero { get; }

Property Value

Type: ConstructorDepth
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ConstructorDepth Structure
PostSharp.Aspects Namespace


CustomAttributeIntroductionAspect Class

CustomAttributeIntroductionAspect Class
Aspect that, when applied to a target, adds a custom attribute to this target.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsCustomAttributeIntroductionAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class CustomAttributeIntroductionAspect : ICustomAttributeIntroductionAspect,
    IAspect, IAspectBuildSemantics, IValidableAnnotation

The CustomAttributeIntroductionAspect type exposes the following members.

Constructors
 | Name | Description
Public method | CustomAttributeIntroductionAspect(CustomAttributeData) | Initializes a new CustomAttributeIntroductionAspect by specifying a CustomAttributeData.
Public method | CustomAttributeIntroductionAspect(ObjectConstruction) | Initializes a new CustomAttributeIntroductionAspect by specifying an ObjectConstruction.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | CustomAttribute | Gets the construction of the custom attribute that must be applied to the target of this aspect.
Top
Remarks

There are two ways to specify a custom attribute: either using an ObjectConstruction (to construct a new custom attribute), either a CustomAttributeData (to copy a custom attribute reflected using one of the overload of the method GetCustomAttributes(Assembly)/

Note Note
This aspect is not a custom attribute. You have to create another aspect implementing IAspectProvider and have the method ProvideAspects(Object) return instances of this aspect.
Examples

Example: Automatically Adding DataContract and DataMember Attributes

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Adding Aspects Dynamically


CustomAttributeIntroductionAspect Constructor

CustomAttributeIntroductionAspect Constructor
Overload List
 | Name | Description
Public method | CustomAttributeIntroductionAspect(CustomAttributeData) | Initializes a new CustomAttributeIntroductionAspect by specifying a CustomAttributeData.
Public method | CustomAttributeIntroductionAspect(ObjectConstruction) | Initializes a new CustomAttributeIntroductionAspect by specifying an ObjectConstruction.
Top
See Also

Reference

CustomAttributeIntroductionAspect Class
PostSharp.Aspects Namespace


CustomAttributeIntroductionAspect Constructor (CustomAttributeData)

CustomAttributeIntroductionAspect Constructor (CustomAttributeData)
Initializes a new CustomAttributeIntroductionAspect by specifying a CustomAttributeData.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public CustomAttributeIntroductionAspect(
    CustomAttributeData customAttributeData
)

Parameters

customAttributeData
Type: System.ReflectionCustomAttributeData
Construction of the custom attribute to be added to the target.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomAttributeIntroductionAspect Class
CustomAttributeIntroductionAspect Overload
PostSharp.Aspects Namespace


CustomAttributeIntroductionAspect Constructor (ObjectConstruction)

CustomAttributeIntroductionAspect Constructor (ObjectConstruction)
Initializes a new CustomAttributeIntroductionAspect by specifying an ObjectConstruction.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public CustomAttributeIntroductionAspect(
    ObjectConstruction attribute
)

Parameters

attribute
Type: PostSharp.ReflectionObjectConstruction
Construction of the custom attribute to be added to the target.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomAttributeIntroductionAspect Class
CustomAttributeIntroductionAspect Overload
PostSharp.Aspects Namespace


CustomAttributeIntroductionAspect Methods

CustomAttributeIntroductionAspect Methods

The CustomAttributeIntroductionAspect type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CustomAttributeIntroductionAspect Class
PostSharp.Aspects Namespace


CustomAttributeIntroductionAspect Properties

CustomAttributeIntroductionAspect Properties

The CustomAttributeIntroductionAspect type exposes the following members.

Properties
 | Name | Description
Public property | CustomAttribute | Gets the construction of the custom attribute that must be applied to the target of this aspect.
Top
See Also

Reference

CustomAttributeIntroductionAspect Class
PostSharp.Aspects Namespace


CustomAttributeIntroductionAspect.CustomAttribute Property

CustomAttributeIntroductionAspectCustomAttribute Property
Gets the construction of the custom attribute that must be applied to the target of this aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectConstruction CustomAttribute { get; }

Property Value

Type: ObjectConstruction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomAttributeIntroductionAspect Class
PostSharp.Aspects Namespace


EventInterceptionArgs Class

EventInterceptionArgs Class
Arguments of handlers of aspects of the type EventInterceptionAspect.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsAdviceArgs
PostSharp.AspectsEventInterceptionArgs

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class EventInterceptionArgs : AdviceArgs

The EventInterceptionArgs type exposes the following members.

Methods
 | Name | Description
Public method | AddHandler | Adds a handler to the event by invoking the Add semantic of the next node in the chain of invocation.
Public method | InvokeHandler | Invokes a handler by calling the Invoke semantic of the next node in the chain of invocation.
Public method | ProceedAddHandler | Proceeds with adding the Delegate to the event to which the current aspect. This method invokes the next handler in chain. It is typically invoked from the implementation of OnAddHandler(EventInterceptionArgs).
Public method | ProceedInvokeHandler | Proceeds with invoking the Delegate with the arguments specified in the Arguments property. The delegate may change the Arguments and set the ReturnValue. This method invokes the next handler in chain. It is typically invoked from the implementation of OnInvokeHandler(EventInterceptionArgs).
Public method | ProceedRemoveHandler | Proceeds with removing the Delegate from the event to which the current aspect. This method invokes the next handler in chain. It is typically invoked from the implementation of OnRemoveHandler(EventInterceptionArgs).
Public method | RemoveHandler | Removes a handler from the event by invoking the Remove semantic of the next node in the chain of invocation.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Arguments | Gets the delegate arguments.
Public property | Binding | Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration to which the advice has been applied. (Inherited from AdviceArgs.)
Public property | Event | Gets the event to which the current aspect has been applied.
Public property | Handler | Gets the delegate being added, removed, or invoked.
Public property | Instance | Gets or sets the object instance on which the method is being executed. (Inherited from AdviceArgs.)
Public property | ReturnValue | Gets the return value of the delegate.
Top
Remarks
Note Note
As a result of weaving optimizations, instances of classes derived from AdviceArgs may be shared among different aspects. Therefore, aspect code should not attempt to access this object once the control has been given over to the next node in the chain of invocation. Consider working with aspect bindings if you need such deferred execution.
Note Note
Aspect weaving optimizations may also cause an advice parameter of this type to be seen

Field Value

Type:
null when inspecting it in a debugger. If you need to inspect the instance in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsEventInterceptionAspect
PostSharp.AspectsEventInterceptionAspect

Other Resources

Conceptual Documentation: Aspect Bindings


EventInterceptionArgs Methods

EventInterceptionArgs Methods

The EventInterceptionArgs type exposes the following members.

Methods
 | Name | Description
Public method | AddHandler | Adds a handler to the event by invoking the Add semantic of the next node in the chain of invocation.
Public method | InvokeHandler | Invokes a handler by calling the Invoke semantic of the next node in the chain of invocation.
Public method | ProceedAddHandler | Proceeds with adding the Delegate to the event to which the current aspect. This method invokes the next handler in chain. It is typically invoked from the implementation of OnAddHandler(EventInterceptionArgs).
Public method | ProceedInvokeHandler | Proceeds with invoking the Delegate with the arguments specified in the Arguments property. The delegate may change the Arguments and set the ReturnValue. This method invokes the next handler in chain. It is typically invoked from the implementation of OnInvokeHandler(EventInterceptionArgs).
Public method | ProceedRemoveHandler | Proceeds with removing the Delegate from the event to which the current aspect. This method invokes the next handler in chain. It is typically invoked from the implementation of OnRemoveHandler(EventInterceptionArgs).
Public method | RemoveHandler | Removes a handler from the event by invoking the Remove semantic of the next node in the chain of invocation.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs.AddHandler Method

EventInterceptionArgsAddHandler Method
Adds a handler to the event by invoking the Add semantic of the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void AddHandler(
    Delegate handler
)

Parameters

handler
Type: SystemDelegate
The handler to add to the event.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs.InvokeHandler Method

EventInterceptionArgsInvokeHandler Method
Invokes a handler by calling the Invoke semantic of the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract Object InvokeHandler(
    Delegate handler,
    Arguments arguments
)

Parameters

handler
Type: SystemDelegate
Handler to be invoked.
arguments
Type: PostSharp.AspectsArguments
Arguments passed to the handler.

Return Value

Type: Object
Return value of the handler.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs.ProceedAddHandler Method

EventInterceptionArgsProceedAddHandler Method
Proceeds with adding the Delegate to the event to which the current aspect. This method invokes the next handler in chain. It is typically invoked from the implementation of OnAddHandler(EventInterceptionArgs).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void ProceedAddHandler()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs.ProceedInvokeHandler Method

EventInterceptionArgsProceedInvokeHandler Method
Proceeds with invoking the Delegate with the arguments specified in the Arguments property. The delegate may change the Arguments and set the ReturnValue. This method invokes the next handler in chain. It is typically invoked from the implementation of OnInvokeHandler(EventInterceptionArgs).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void ProceedInvokeHandler()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs.ProceedRemoveHandler Method

EventInterceptionArgsProceedRemoveHandler Method
Proceeds with removing the Delegate from the event to which the current aspect. This method invokes the next handler in chain. It is typically invoked from the implementation of OnRemoveHandler(EventInterceptionArgs).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void ProceedRemoveHandler()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs.RemoveHandler Method

EventInterceptionArgsRemoveHandler Method
Removes a handler from the event by invoking the Remove semantic of the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void RemoveHandler(
    Delegate handler
)

Parameters

handler
Type: SystemDelegate
Handler to be removed.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs Properties

EventInterceptionArgs Properties

The EventInterceptionArgs type exposes the following members.

Properties
 | Name | Description
Public property | Arguments | Gets the delegate arguments.
Public property | Binding | Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration to which the advice has been applied. (Inherited from AdviceArgs.)
Public property | Event | Gets the event to which the current aspect has been applied.
Public property | Handler | Gets the delegate being added, removed, or invoked.
Public property | Instance | Gets or sets the object instance on which the method is being executed. (Inherited from AdviceArgs.)
Public property | ReturnValue | Gets the return value of the delegate.
Top
See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs.Arguments Property

EventInterceptionArgsArguments Property
Gets the delegate arguments.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Arguments Arguments { get; }

Property Value

Type: Arguments
Remarks

This property is meaningful only during a delegate invocation (not during an addition or removal).

This property is typically accessed by the ProceedInvokeHandler method. Implementations of OnInvokeHandler(EventInterceptionArgs) can also get or change the value of this property.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs.Binding Property

EventInterceptionArgsBinding Property
Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract IEventBinding Binding { get; }

Property Value

Type: IEventBinding
Remarks

Bindings are thread-safe and context-free singleton instances exposing the next node in the chain of invocation.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Aspect Bindings


EventInterceptionArgs.Event Property

EventInterceptionArgsEvent Property
Gets the event to which the current aspect has been applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EventInfo Event { get; set; }

Property Value

Type: EventInfo
Remarks
Note Note
Using this property causes the aspect weaver to generate code that has non-trivial runtime overhead. Avoid using this property whenever possible. One of the possible solution is to use compile-time initialization of aspect instances and to make use of reflection only at build time.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs.Handler Property

EventInterceptionArgsHandler Property
Gets the delegate being added, removed, or invoked.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Delegate Handler { get; }

Property Value

Type: Delegate
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionArgs.ReturnValue Property

EventInterceptionArgsReturnValue Property
Gets the return value of the delegate.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object ReturnValue { get; set; }

Property Value

Type: Object
Remarks

This property is meaningful only during a delegate invocation (not during an addition or removal).

This property is typically set by the ProceedInvokeHandler method. It is also legal for an implementation of OnInvokeHandler(EventInterceptionArgs) to change the value of this property.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionArgs Class
PostSharp.Aspects Namespace


EventInterceptionAspect Class

EventInterceptionAspect Class
Aspect that, when applied on an event, intercepts invocations of its semantics Add (OnAddHandler(EventInterceptionArgs)), Remove (OnRemoveHandler(EventInterceptionArgs)) and Invoke (OnInvokeHandler(EventInterceptionArgs)).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsEventLevelAspect
PostSharp.AspectsEventInterceptionAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class EventInterceptionAspect : EventLevelAspect,
    IEventInterceptionAspect, IEventLevelAspect, IAspect

The EventInterceptionAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | EventInterceptionAspect | Initializes a new instance of the EventInterceptionAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from EventLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from EventLevelAspect.)
Public method | CompileTimeValidate(EventInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from EventLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnAddHandler | Method invoked instead of the Add semantic of the event to which the current aspect is applied, i.e. when a new delegate is added to this event.
Public method | OnInvokeHandler | Method invoked when the event to which the current aspect is applied is fired, for each delegate of this event, and instead of invoking this delegate.
Public method | OnRemoveHandler | Method invoked instead of the Remove semantic of the event to which the current aspect is applied, i.e. when a delegate is removed from this event.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from EventLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from EventLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, EventInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from EventLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

Applying an aspect of type EventInterceptionAspect to an event results in the add and remove methods of the event to be replaced by a call to OnAddHandler(EventInterceptionArgs) and OnRemoveHandler(EventInterceptionArgs), respectively. The original accessor body is moved into new methods, which the aspect code can call by invoking ProceedAddHandler or ProceedRemoveHandler.

The method OnInvokeHandler(EventInterceptionArgs), if defined, is called instead when the event is raised, once for every handler that has been added to the list. When you define OnInvokeHandler(EventInterceptionArgs) method, PostSharp will use a broker object to control access to the event; this broker object will be the unique subscriber of the event, and maintains its own list of subscribers.

For details about the implementation of this aspect, see Interception Aspects.

Note Note
The aspect works only when caller code access the event through its add/remove semantics. It does not work when the caller code bypasses the event semantics and accesses directly its implementation (the underlying field of the event, typically). The C# compiler is known to bypass the semantics when the event is accessed directly from the class declaring it (it accesses directly the private field whenever it can).

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Note Note
PostSharp Professional Edition is required for this feature.
Examples

Example: Making an Event Asynchronous

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Aspect Serialization
Conceptual Documentation: Interception Aspects


EventInterceptionAspect Constructor

EventInterceptionAspect Constructor
Initializes a new instance of the EventInterceptionAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected EventInterceptionAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionAspect Class
PostSharp.Aspects Namespace


EventInterceptionAspect Methods

EventInterceptionAspect Methods

The EventInterceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from EventLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from EventLevelAspect.)
Public method | CompileTimeValidate(EventInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from EventLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnAddHandler | Method invoked instead of the Add semantic of the event to which the current aspect is applied, i.e. when a new delegate is added to this event.
Public method | OnInvokeHandler | Method invoked when the event to which the current aspect is applied is fired, for each delegate of this event, and instead of invoking this delegate.
Public method | OnRemoveHandler | Method invoked instead of the Remove semantic of the event to which the current aspect is applied, i.e. when a delegate is removed from this event.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from EventLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from EventLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, EventInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from EventLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EventInterceptionAspect Class
PostSharp.Aspects Namespace


EventInterceptionAspect.CreateAspectConfiguration Method

EventInterceptionAspectCreateAspectConfiguration Method
Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the Aspect.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration, Object) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


EventInterceptionAspect.OnAddHandler Method

EventInterceptionAspectOnAddHandler Method
Method invoked instead of the Add semantic of the event to which the current aspect is applied, i.e. when a new delegate is added to this event.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnAddHandler(
    EventInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsEventInterceptionArgs
Handler arguments.

Implements

IEventInterceptionAspectOnAddHandler(EventInterceptionArgs)
Remarks
Note Note
Because of the way how the C# compiler implements automatic events (i.e. events where you don't implement the Add and Remove semantics manually), the Invoke Event Handler semantic ( OnInvokeHandler(EventInterceptionArgs) or equivalent) shall not be invoked for delegates that have been added from inside the class that declares this event.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionAspect Class
PostSharp.Aspects Namespace


EventInterceptionAspect.OnInvokeHandler Method

EventInterceptionAspectOnInvokeHandler Method
Method invoked when the event to which the current aspect is applied is fired, for each delegate of this event, and instead of invoking this delegate.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnInvokeHandler(
    EventInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsEventInterceptionArgs
Handler arguments.

Implements

IEventInterceptionAspectOnInvokeHandler(EventInterceptionArgs)
Remarks
Note Note
Because of the way how the C# compiler implements automatic events (i.e. events where you don't implement the Add and Remove semantics manually), the Invoke Event Handler semantic ( OnInvokeHandler(EventInterceptionArgs) or equivalent) shall not be invoked for delegates that have been added from inside the class that declares this event.

Note Note
The Invoke Event Handler semantic is different from normal event firing. Indeed, when you fire an event, all handlers that were added to this event are fired. However, the current method invokes only a single handler: the one passed to the handler parameter.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionAspect Class
PostSharp.Aspects Namespace


EventInterceptionAspect.OnRemoveHandler Method

EventInterceptionAspectOnRemoveHandler Method
Method invoked instead of the Remove semantic of the event to which the current aspect is applied, i.e. when a delegate is removed from this event.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnRemoveHandler(
    EventInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsEventInterceptionArgs
Handler arguments.

Implements

IEventInterceptionAspectOnRemoveHandler(EventInterceptionArgs)
Remarks
Note Note
Because of the way how the C# compiler implements automatic events (i.e. events where you don't implement the Add and Remove semantics manually), the Invoke Event Handler semantic ( OnInvokeHandler(EventInterceptionArgs) or equivalent) shall not be invoked for delegates that have been added from inside the class that declares this event.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionAspect Class
PostSharp.Aspects Namespace


EventInterceptionAspect Properties

EventInterceptionAspect Properties

The EventInterceptionAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

EventInterceptionAspect Class
PostSharp.Aspects Namespace


EventLevelAspect Class

EventLevelAspect Class
Base class for all aspects applied on events.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsEventLevelAspect
PostSharp.AspectsEventInterceptionAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class EventLevelAspect : Aspect,
    IEventLevelAspect, IAspect, IEventLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation

The EventLevelAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | EventLevelAspect | Initializes a new instance of the EventLevelAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(EventInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, EventInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks
Note Note
This class does not provide any advice. You may derive your aspect class from a class providing predefined advice , or build a composite aspect .

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsIEventLevelAspect

Other Resources

Conceptual Documentation: Aspect Classes
Conceptual Documentation: Developing Complex Aspects
Conceptual Documentation: Aspect Serialization


EventLevelAspect Constructor

EventLevelAspect Constructor
Initializes a new instance of the EventLevelAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected EventLevelAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventLevelAspect Class
PostSharp.Aspects Namespace


EventLevelAspect Methods

EventLevelAspect Methods

The EventLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(EventInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, EventInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EventLevelAspect Class
PostSharp.Aspects Namespace


EventLevelAspect.CompileTimeInitialize Method

EventLevelAspectCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void CompileTimeInitialize(
    EventInfo targetEvent,
    AspectInfo aspectInfo
)

Parameters

targetEvent
Type: System.ReflectionEventInfo
Event to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.

Implements

IEventLevelAspectBuildSemanticsCompileTimeInitialize(EventInfo, AspectInfo)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


EventLevelAspect.CompileTimeValidate Method

EventLevelAspectCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(EventInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
See Also

Reference

EventLevelAspect Class
PostSharp.Aspects Namespace


EventLevelAspect.CompileTimeValidate Method (Object)

EventLevelAspectCompileTimeValidate Method (Object)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override sealed bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the aspect has been applied.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.

Implements

IValidableAnnotationCompileTimeValidate(Object)
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


EventLevelAspect.CompileTimeValidate Method (EventInfo)

EventLevelAspectCompileTimeValidate Method (EventInfo)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual bool CompileTimeValidate(
    EventInfo targetEvent
)

Parameters

targetEvent
Type: System.ReflectionEventInfo
Event to which the aspect has been applied

Return Value

Type: Boolean
true if the aspect was applied to an acceptable event, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


EventLevelAspect.RuntimeInitialize Method

EventLevelAspectRuntimeInitialize Method
Initializes the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void RuntimeInitialize(
    EventInfo eventInfo
)

Parameters

eventInfo
Type: System.ReflectionEventInfo
Event to which the current aspect is applied.

Implements

IEventLevelAspectRuntimeInitialize(EventInfo)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


EventLevelAspect.SetAspectConfiguration Method

EventLevelAspectSetAspectConfiguration Method
Overload List
 | Name | Description
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, EventInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
See Also

Reference

EventLevelAspect Class
PostSharp.Aspects Namespace


EventLevelAspect.SetAspectConfiguration Method (AspectConfiguration, Object)

EventLevelAspectSetAspectConfiguration Method (AspectConfiguration, Object)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    Object targetElement
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current Aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


EventLevelAspect.SetAspectConfiguration Method (AspectConfiguration, EventInfo)

EventLevelAspectSetAspectConfiguration Method (AspectConfiguration, EventInfo)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    EventInfo targetEvent
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetEvent
Type: System.ReflectionEventInfo
Event to which the current aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


EventLevelAspect Properties

EventLevelAspect Properties

The EventLevelAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

EventLevelAspect Class
PostSharp.Aspects Namespace


ExternalAspect Class

ExternalAspect Class

Note: This API is now obsolete.

Aspect implemented in a different type (implementing the IExternalAspectImplementation interface), typically contained in an external assembly. Classes derived from ExternalAspect must be annotated by the custom attribute ExternalAspectConfigurationAttribute.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsExternalAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Build-time semantics are now supported for Silverlight, Windows Phone, and WinRT.")]
public abstract class ExternalAspect : Aspect,
    IExternalAspect, IAspect

The ExternalAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | ExternalAspect | Initializes a new instance of the ExternalAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from Aspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | SetAspectConfiguration | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from Aspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

External aspects are useful when you develop for Silverlight or the .NET Compact Framework. Indeed, aspects cannot have build-time semantics on these platforms. If you need to execute logic at build time on these platforms, you need to implement this logic in an assembly linked with the normal .NET Framework (so not Silverlight or Compact Framework). You must relate an aspect with its implementation using the custom attribute ExternalAspectConfigurationAttribute.

Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Using PostSharp with Silverlight, Windows Phone, and the Compact .NET Framework


ExternalAspect Constructor

ExternalAspect Constructor
Initializes a new instance of the ExternalAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected ExternalAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ExternalAspect Class
PostSharp.Aspects Namespace


ExternalAspect Methods

ExternalAspect Methods

The ExternalAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from Aspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | SetAspectConfiguration | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from Aspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ExternalAspect Class
PostSharp.Aspects Namespace


ExternalAspect Properties

ExternalAspect Properties

The ExternalAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

ExternalAspect Class
PostSharp.Aspects Namespace


FieldLevelAspect Class

FieldLevelAspect Class
Base class for all aspects applied on fields.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsFieldLevelAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class FieldLevelAspect : Aspect,
    IFieldLevelAspect, IAspect, IFieldLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation

The FieldLevelAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | FieldLevelAspect | Initializes a new instance of the FieldLevelAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(FieldInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Method invoked at runtime before any other method of the aspect is invoked.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, FieldInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks
Note Note
Consider deriving your aspects from LocationLevelAspect; locations can abstract both fields and properties, making it possible to apply the same aspect to both.
Note Note
This class does not provide any advice. You may derive your aspect class from a class providing predefined advice , or build a composite aspect .

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsIFieldLevelAspect
PostSharp.AspectsLocationLevelAspect

Other Resources

Conceptual Documentation: Aspect Classes
Conceptual Documentation: Developing Complex Aspects
Conceptual Documentation: Aspect Serialization


FieldLevelAspect Constructor

FieldLevelAspect Constructor
Initializes a new instance of the FieldLevelAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected FieldLevelAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FieldLevelAspect Class
PostSharp.Aspects Namespace


FieldLevelAspect Methods

FieldLevelAspect Methods

The FieldLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(FieldInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Method invoked at runtime before any other method of the aspect is invoked.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, FieldInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

FieldLevelAspect Class
PostSharp.Aspects Namespace


FieldLevelAspect.CompileTimeInitialize Method

FieldLevelAspectCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void CompileTimeInitialize(
    FieldInfo field,
    AspectInfo aspectInfo
)

Parameters

field
Type: System.ReflectionFieldInfo
Field to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.

Implements

IFieldLevelAspectBuildSemanticsCompileTimeInitialize(FieldInfo, AspectInfo)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FieldLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


FieldLevelAspect.CompileTimeValidate Method

FieldLevelAspectCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(FieldInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
See Also

Reference

FieldLevelAspect Class
PostSharp.Aspects Namespace


FieldLevelAspect.CompileTimeValidate Method (Object)

FieldLevelAspectCompileTimeValidate Method (Object)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override sealed bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the aspect has been applied.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.

Implements

IValidableAnnotationCompileTimeValidate(Object)
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FieldLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


FieldLevelAspect.CompileTimeValidate Method (FieldInfo)

FieldLevelAspectCompileTimeValidate Method (FieldInfo)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual bool CompileTimeValidate(
    FieldInfo field
)

Parameters

field
Type: System.ReflectionFieldInfo
Field to which the aspect has been applied

Return Value

Type: Boolean
true if the aspect was applied to an acceptable field, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FieldLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


FieldLevelAspect.RuntimeInitialize Method

FieldLevelAspectRuntimeInitialize Method
Method invoked at runtime before any other method of the aspect is invoked.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void RuntimeInitialize(
    FieldInfo field
)

Parameters

field
Type: System.ReflectionFieldInfo
Field on which this instance is applied.

Implements

IFieldLevelAspectRuntimeInitialize(FieldInfo)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FieldLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


FieldLevelAspect.SetAspectConfiguration Method

FieldLevelAspectSetAspectConfiguration Method
Overload List
 | Name | Description
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, FieldInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
See Also

Reference

FieldLevelAspect Class
PostSharp.Aspects Namespace


FieldLevelAspect.SetAspectConfiguration Method (AspectConfiguration, Object)

FieldLevelAspectSetAspectConfiguration Method (AspectConfiguration, Object)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    Object targetElement
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current Aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FieldLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


FieldLevelAspect.SetAspectConfiguration Method (AspectConfiguration, FieldInfo)

FieldLevelAspectSetAspectConfiguration Method (AspectConfiguration, FieldInfo)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    FieldInfo targetField
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetField
Type: System.ReflectionFieldInfo
Field to which the current aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FieldLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


FieldLevelAspect Properties

FieldLevelAspect Properties

The FieldLevelAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

FieldLevelAspect Class
PostSharp.Aspects Namespace


FlowBehavior Enumeration

FlowBehavior Enumeration
Enumerates the possible behaviors of the calling method after the calling method has returned.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum FlowBehavior
Members
Member name | Value | Description
Default | 0 | Default flow behavior for the current method. For OnEntry(MethodExecutionArgs), OnExit(MethodExecutionArgs) and OnSuccess(MethodExecutionArgs), the fault flow is Continue, for OnException(MethodExecutionArgs) it is RethrowException.
Continue | 1 | Continue normally. In an OnException(MethodExecutionArgs) advice, the Continue behavior does not rethrow the exception, but continues the normal execution flow after the block protected by the advise. If there is another OnMethodBoundaryAspect aspect before the current OnMethodBoundaryAspect aspect on the current method, the Continue behavior calls the OnSuccess(MethodExecutionArgs) method of the other aspect.
RethrowException | 2 | The current exception will be rethrown. Available only for OnException(MethodExecutionArgs).
Return | 3 | Return immediately from the current method. Available only for OnEntry(MethodExecutionArgs) and OnException(MethodExecutionArgs). Note that you may want to set the ReturnValue property, otherwise you may get a NullReferenceException. If there is another OnMethodBoundaryAspect aspect before the current OnMethodBoundaryAspect aspect on the current method, the Return behavior skips the OnSuccess(MethodExecutionArgs) method of the other aspect. However, the OnExit(MethodExecutionArgs) method of the other aspect will be invoked.
ThrowException | 4 | Throws the exception contained in the Exception property. Available only for OnException(MethodExecutionArgs).
Remarks

This enumeration is used by the MethodExecutionArgs class.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


IAspect Interface

IAspect Interface
Base interface for run-time semantics of all aspects.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAspect
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsIAspectBuildSemantics
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.AspectsAspect


IAspectBuildSemantics Interface

IAspectBuildSemantics Interface
Compile-time semantics of IAspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAspectBuildSemantics : IValidableAnnotation

The IAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


IAspectBuildSemantics Methods

IAspectBuildSemantics Methods

The IAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect.
Top
See Also

Reference

IAspectBuildSemantics Interface
PostSharp.Aspects Namespace


IAspectBuildSemantics.GetAspectConfiguration Method

IAspectBuildSemanticsGetAspectConfiguration Method
Method invoked at build time to get the imperative configuration of the current Aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
AspectConfiguration GetAspectConfiguration(
    Object targetElement
)

Parameters

targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current aspect has been applied.

Return Value

Type: AspectConfiguration
An AspectConfiguration representing the imperative configuration of the current Aspect.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAspectBuildSemantics Interface
PostSharp.Aspects Namespace


IAspectInstance Interface

IAspectInstance Interface
Represents an instance of an aspect applied to a declaration.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAspectInstance

The IAspectInstance type exposes the following members.

Properties
 | Name | Description
Public property | Aspect | Gets the aspect instance.
Public property | AspectConfiguration | Gets the aspect configuration.
Public property | AspectConstruction | Gets the aspect construction.
Public property | AspectType | Gets the type of the aspect.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects Namespace


IAspectInstance Properties

IAspectInstance Properties

The IAspectInstance type exposes the following members.

Properties
 | Name | Description
Public property | Aspect | Gets the aspect instance.
Public property | AspectConfiguration | Gets the aspect configuration.
Public property | AspectConstruction | Gets the aspect construction.
Public property | AspectType | Gets the type of the aspect.
Top
See Also

Reference

IAspectInstance Interface
PostSharp.Aspects Namespace


IAspectInstance.Aspect Property

IAspectInstanceAspect Property
Gets the aspect instance.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IAspect Aspect { get; }

Property Value

Type: IAspect
The aspect instance, or null if the AspectConfiguration was provided instead.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IAspectInstance Interface
PostSharp.Aspects Namespace


IAspectInstance.AspectConfiguration Property

IAspectInstanceAspectConfiguration Property
Gets the aspect configuration.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
AspectConfiguration AspectConfiguration { get; }

Property Value

Type: AspectConfiguration
The aspect configuration, or null if none was provided.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IAspectInstance Interface
PostSharp.Aspects Namespace


IAspectInstance.AspectConstruction Property

IAspectInstanceAspectConstruction Property
Gets the aspect construction.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ObjectConstruction AspectConstruction { get; }

Property Value

Type: ObjectConstruction
The aspect construction, or null if the aspect instance was provided instead.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IAspectInstance Interface
PostSharp.Aspects Namespace


IAspectInstance.AspectType Property

IAspectInstanceAspectType Property
Gets the type of the aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Type AspectType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IAspectInstance Interface
PostSharp.Aspects Namespace


IAspectProvider Interface

IAspectProvider Interface
Interface that, when implemented by an aspect class, allows aspect instances to provide other aspects to the weaver.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAspectProvider : IAspect,
    IService

The IAspectProvider type exposes the following members.

Methods
 | Name | Description
Public method | ProvideAspects | Provides new aspects.
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Examples

Example: Automatically Adding DataContract and DataMember Attributes

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


IAspectProvider Methods

IAspectProvider Methods

The IAspectProvider type exposes the following members.

Methods
 | Name | Description
Public method | ProvideAspects | Provides new aspects.
Top
See Also

Reference

IAspectProvider Interface
PostSharp.Aspects Namespace


IAspectProvider.ProvideAspects Method

IAspectProviderProvideAspects Method
Provides new aspects.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IEnumerable<AspectInstance> ProvideAspects(
    Object targetElement
)

Parameters

targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current aspect has been applied.

Return Value

Type: IEnumerable AspectInstance
A set of aspect instances.
Remarks

Implementations of this method are only allowed to return aspect instances applied on elements of code located under the target element of code (targetElement). For instance, a type-level IAspectProvider can provide aspects on methods of the current type, but not of other types.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAspectProvider Interface
PostSharp.Aspects Namespace


IAspectRepositoryService Interface

IAspectRepositoryService Interface
Service that allows to determine which aspects have been applied to a given declaration, whether declaratively through custom attributes or MulticastAttribute, or programmatically using IAspectProvider.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAspectRepositoryService : IService

The IAspectRepositoryService type exposes the following members.

Methods
 | Name | Description
Public method | GetAspectInstances | Gets the list of aspect instances on a given declaration.
Public method | HasAspect | Determines whether an aspect of a given type has been applied to a given declaration.
Top
Events
 | Name | Description
Public event | AspectDiscoveryCompleted | Event invoked after all the aspects in the current project have been discovered and initialized.
Top
Remarks

To get an instance of this service, use the GetServiceT(Boolean) method from PostSharpEnvironment.CurrentProject.GetService.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects Namespace


IAspectRepositoryService Methods

IAspectRepositoryService Methods

The IAspectRepositoryService type exposes the following members.

Methods
 | Name | Description
Public method | GetAspectInstances | Gets the list of aspect instances on a given declaration.
Public method | HasAspect | Determines whether an aspect of a given type has been applied to a given declaration.
Top
See Also

Reference

IAspectRepositoryService Interface
PostSharp.Aspects Namespace


IAspectRepositoryService.GetAspectInstances Method

IAspectRepositoryServiceGetAspectInstances Method
Gets the list of aspect instances on a given declaration.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IAspectInstance[] GetAspectInstances(
    Object declaration
)

Parameters

declaration
Type: SystemObject
The declaration (in the current assembly) for which the list of aspect instances is required.

Return Value

Type: IAspectInstance
The list of aspect instances applied on declaration.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IAspectRepositoryService Interface
PostSharp.Aspects Namespace


IAspectRepositoryService.HasAspect Method

IAspectRepositoryServiceHasAspect Method
Determines whether an aspect of a given type has been applied to a given declaration.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool HasAspect(
    Object declaration,
    Type aspectType
)

Parameters

declaration
Type: SystemObject
The declaration on which the presence of the aspect must be checked.
aspectType
Type: SystemType
The type of aspect.

Return Value

Type: Boolean
true if an aspect of type aspectType has been applied to declaration, otherwise false.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IAspectRepositoryService Interface
PostSharp.Aspects Namespace


IAspectRepositoryService Events

IAspectRepositoryService Events

The IAspectRepositoryService type exposes the following members.

Events
 | Name | Description
Public event | AspectDiscoveryCompleted | Event invoked after all the aspects in the current project have been discovered and initialized.
Top
See Also

Reference

IAspectRepositoryService Interface
PostSharp.Aspects Namespace


IAspectRepositoryService.AspectDiscoveryCompleted Event

IAspectRepositoryServiceAspectDiscoveryCompleted Event
Event invoked after all the aspects in the current project have been discovered and initialized.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
event EventHandler AspectDiscoveryCompleted

Value

Type: SystemEventHandler
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IAspectRepositoryService Interface
PostSharp.Aspects Namespace


IAssemblyLevelAspect Interface

IAssemblyLevelAspect Interface
Runtime semantics of aspects applied at assembly level.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAssemblyLevelAspect : IAspect
Remarks
An assembly-level aspect has no equivalent to RuntimeInitialize since assemblies are never initialized.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsIAssemblyLevelAspectBuildSemantics
PostSharp.AspectsAssemblyLevelAspect


IAssemblyLevelAspectBuildSemantics Interface

IAssemblyLevelAspectBuildSemantics Interface
Build-time semantics of aspects applied at assembly level.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAssemblyLevelAspectBuildSemantics : IAspect

The IAssemblyLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsAssemblyLevelAspect


IAssemblyLevelAspectBuildSemantics Methods

IAssemblyLevelAspectBuildSemantics Methods

The IAssemblyLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Top
See Also

Reference

IAssemblyLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace


IAssemblyLevelAspectBuildSemantics.CompileTimeInitialize Method

IAssemblyLevelAspectBuildSemanticsCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void CompileTimeInitialize(
    Assembly assembly,
    AspectInfo aspectInfo
)

Parameters

assembly
Type: System.ReflectionAssembly
Assembly to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAssemblyLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects
Conceptual Documentation: Initializing Aspects


ICloneAwareAspect Interface

ICloneAwareAspect Interface
Defines the semantics of aspects that require to be notified after a target object is cloned using MemberwiseClone.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ICloneAwareAspect : IInstanceScopedAspect,
    IAspect

The ICloneAwareAspect type exposes the following members.

Methods
 | Name | Description
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from IInstanceScopedAspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object.
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from IInstanceScopedAspect.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


ICloneAwareAspect Methods

ICloneAwareAspect Methods

The ICloneAwareAspect type exposes the following members.

Methods
 | Name | Description
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from IInstanceScopedAspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object.
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from IInstanceScopedAspect.)
Top
See Also

Reference

ICloneAwareAspect Interface
PostSharp.Aspects Namespace


ICloneAwareAspect.OnCloned Method

ICloneAwareAspectOnCloned Method
Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnCloned(
    ICloneAwareAspect source
)

Parameters

source
Type: PostSharp.AspectsICloneAwareAspect
Aspect instance corresponding to the current aspect instance in the cloned target object.
Remarks

Prior to calling the current method, the aspect framework initializes the source object using CreateInstance(AdviceArgs) and RuntimeInitializeInstance. That is, the aspect instance in the cloned object is not cloned from the source aspect instance, but from the prototype aspect instance.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ICloneAwareAspect Interface
PostSharp.Aspects Namespace


ICompositionAspect Interface

ICompositionAspect Interface
Defines the semantics of an aspect that, when applied on a type, introduce one or many new interfaces into that type, and let these interfaces be implemented by an object created at runtime.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ICompositionAspect : ITypeLevelAspect,
    IAspect

The ICompositionAspect type exposes the following members.

Methods
 | Name | Description
Public method | CreateImplementationObject | Method invoked at runtime, during the initialization of instances of the target type, to create the composed object.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from ITypeLevelAspect.)
Top
Remarks
See CompositionAspect for details.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsCompositionAspect


ICompositionAspect Methods

ICompositionAspect Methods

The ICompositionAspect type exposes the following members.

Methods
 | Name | Description
Public method | CreateImplementationObject | Method invoked at runtime, during the initialization of instances of the target type, to create the composed object.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from ITypeLevelAspect.)
Top
See Also

Reference

ICompositionAspect Interface
PostSharp.Aspects Namespace


ICompositionAspect.CreateImplementationObject Method

ICompositionAspectCreateImplementationObject Method
Method invoked at runtime, during the initialization of instances of the target type, to create the composed object.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object CreateImplementationObject(
    AdviceArgs args
)

Parameters

args
Type: PostSharp.AspectsAdviceArgs

Return Value

Type: Object
The composed object. This interface should implement the interfaces specified by the PublicInterfaces and ProtectedInterfaces collections.
Remarks
This method is invoked during at runtime after the base constructor has executed, and before the constructor of the current type is executed.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ICompositionAspect Interface
PostSharp.Aspects Namespace


ICustomAttributeIntroductionAspect Interface

ICustomAttributeIntroductionAspect Interface
Semantics of an aspect that, when applied to a target, adds a custom attribute to this target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ICustomAttributeIntroductionAspect : IAspect
Remarks
See CustomAttributeIntroductionAspect for details.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsCustomAttributeIntroductionAspect
PostSharp.Aspects.ConfigurationCustomAttributeIntroductionAspectConfiguration


IEventBinding Interface

IEventBinding Interface
Interface through which an event-level aspect or advice can invoke the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IEventBinding

The IEventBinding type exposes the following members.

Methods
 | Name | Description
Public method | AddHandler | Invoke the Add semantic on the next node in the chain of invocation.
Public method | InvokeHandler | Invoke the Invoke semantic on the next node in the chain of invocation.
Public method | RemoveHandler | Invoke the Remove semantic on the next node in the chain of invocation.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.Aspects.AdvicesImportMemberAttribute

Other Resources

Conceptual Documentation: Aspect Bindings


IEventBinding Methods

IEventBinding Methods

The IEventBinding type exposes the following members.

Methods
 | Name | Description
Public method | AddHandler | Invoke the Add semantic on the next node in the chain of invocation.
Public method | InvokeHandler | Invoke the Invoke semantic on the next node in the chain of invocation.
Public method | RemoveHandler | Invoke the Remove semantic on the next node in the chain of invocation.
Top
See Also

Reference

IEventBinding Interface
PostSharp.Aspects Namespace


IEventBinding.AddHandler Method

IEventBindingAddHandler Method
Invoke the Add semantic on the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void AddHandler(
    ref Object instance,
    Delegate handler
)

Parameters

instance
Type: SystemObject
Target instance on which the event is defined (null if the event is static).
handler
Type: SystemDelegate
Handler to be added to the event.
Remarks

The instance parameter is passed by reference so that instance methods of value types ( struct in C#) are allowed to change the value of the instance.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IEventBinding Interface
PostSharp.Aspects Namespace


IEventBinding.InvokeHandler Method

IEventBindingInvokeHandler Method
Invoke the Invoke semantic on the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object InvokeHandler(
    ref Object instance,
    Delegate handler,
    Arguments arguments
)

Parameters

instance
Type: SystemObject
Target instance on which the event is defined (null if the event is static).
handler
Type: SystemDelegate
Handler to be removed from the event.
arguments
Type: PostSharp.AspectsArguments
Arguments with which the handler should be invoked.

Return Value

Type: Object
The value returned by the handler.
Remarks

The instance parameter is passed by reference so that instance methods of value types ( struct in C#) are allowed to change the value of the instance.

Note Note
The Invoke Event Handler semantic is different from normal event firing. Indeed, when you fire an event, all handlers that were added to this event are fired. However, the current method invokes only a single handler: the one passed to the handler parameter.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IEventBinding Interface
PostSharp.Aspects Namespace


IEventBinding.RemoveHandler Method

IEventBindingRemoveHandler Method
Invoke the Remove semantic on the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void RemoveHandler(
    ref Object instance,
    Delegate handler
)

Parameters

instance
Type: SystemObject
Target instance on which the event is defined (null if the event is static).
handler
Type: SystemDelegate
Handler to be removed from the event.
Remarks

The instance parameter is passed by reference so that instance methods of value types ( struct in C#) are allowed to change the value of the instance.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IEventBinding Interface
PostSharp.Aspects Namespace


IEventInterceptionAspect Interface

IEventInterceptionAspect Interface
Runtime semantics of an aspect that, when applied on an event, intercepts invocations of its semantics Add (OnAddHandler(EventInterceptionArgs)), Remove (OnRemoveHandler(EventInterceptionArgs)) and Invoke (OnInvokeHandler(EventInterceptionArgs)) semantics.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IEventInterceptionAspect : IEventLevelAspect,
    IAspect

The IEventInterceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnAddHandler | Method invoked instead of the Add semantic of the event to which the current aspect is applied, i.e. when a new delegate is added to this event.
Public method | OnInvokeHandler | Method invoked when the event to which the current aspect is applied is fired, for each delegate of this event, and instead of invoking this delegate.
Public method | OnRemoveHandler | Method invoked instead of the Remove semantic of the event to which the current aspect is applied, i.e. when a delegate is removed from this event.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from IEventLevelAspect.)
Top
Remarks

For details, see EventInterceptionAspect

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


IEventInterceptionAspect Methods

IEventInterceptionAspect Methods

The IEventInterceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnAddHandler | Method invoked instead of the Add semantic of the event to which the current aspect is applied, i.e. when a new delegate is added to this event.
Public method | OnInvokeHandler | Method invoked when the event to which the current aspect is applied is fired, for each delegate of this event, and instead of invoking this delegate.
Public method | OnRemoveHandler | Method invoked instead of the Remove semantic of the event to which the current aspect is applied, i.e. when a delegate is removed from this event.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from IEventLevelAspect.)
Top
See Also

Reference

IEventInterceptionAspect Interface
PostSharp.Aspects Namespace


IEventInterceptionAspect.OnAddHandler Method

IEventInterceptionAspectOnAddHandler Method
Method invoked instead of the Add semantic of the event to which the current aspect is applied, i.e. when a new delegate is added to this event.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnAddHandler(
    EventInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsEventInterceptionArgs
Handler arguments.
Remarks
Note Note
Because of the way how the C# compiler implements automatic events (i.e. events where you don't implement the Add and Remove semantics manually), the Invoke Event Handler semantic ( OnInvokeHandler(EventInterceptionArgs) or equivalent) shall not be invoked for delegates that have been added from inside the class that declares this event.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IEventInterceptionAspect Interface
PostSharp.Aspects Namespace


IEventInterceptionAspect.OnInvokeHandler Method

IEventInterceptionAspectOnInvokeHandler Method
Method invoked when the event to which the current aspect is applied is fired, for each delegate of this event, and instead of invoking this delegate.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnInvokeHandler(
    EventInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsEventInterceptionArgs
Handler arguments.
Remarks
Note Note
Because of the way how the C# compiler implements automatic events (i.e. events where you don't implement the Add and Remove semantics manually), the Invoke Event Handler semantic ( OnInvokeHandler(EventInterceptionArgs) or equivalent) shall not be invoked for delegates that have been added from inside the class that declares this event.

Note Note
The Invoke Event Handler semantic is different from normal event firing. Indeed, when you fire an event, all handlers that were added to this event are fired. However, the current method invokes only a single handler: the one passed to the handler parameter.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IEventInterceptionAspect Interface
PostSharp.Aspects Namespace


IEventInterceptionAspect.OnRemoveHandler Method

IEventInterceptionAspectOnRemoveHandler Method
Method invoked instead of the Remove semantic of the event to which the current aspect is applied, i.e. when a delegate is removed from this event.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnRemoveHandler(
    EventInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsEventInterceptionArgs
Handler arguments.
Remarks
Note Note
Because of the way how the C# compiler implements automatic events (i.e. events where you don't implement the Add and Remove semantics manually), the Invoke Event Handler semantic ( OnInvokeHandler(EventInterceptionArgs) or equivalent) shall not be invoked for delegates that have been added from inside the class that declares this event.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IEventInterceptionAspect Interface
PostSharp.Aspects Namespace


IEventLevelAspect Interface

IEventLevelAspect Interface
Runtime semantics of aspects that can be applied on events.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IEventLevelAspect : IAspect

The IEventLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | RuntimeInitialize | Initializes the current aspect.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsEventLevelAspect
PostSharp.AspectsIEventLevelAspectBuildSemantics


IEventLevelAspect Methods

IEventLevelAspect Methods

The IEventLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | RuntimeInitialize | Initializes the current aspect.
Top
See Also

Reference

IEventLevelAspect Interface
PostSharp.Aspects Namespace


IEventLevelAspect.RuntimeInitialize Method

IEventLevelAspectRuntimeInitialize Method
Initializes the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void RuntimeInitialize(
    EventInfo eventInfo
)

Parameters

eventInfo
Type: System.ReflectionEventInfo
Event to which the current aspect is applied.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IEventLevelAspect Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


IEventLevelAspectBuildSemantics Interface

IEventLevelAspectBuildSemantics Interface
Build-time semantics of aspects that can be applied on events.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IEventLevelAspectBuildSemantics : IAspectBuildSemantics,
    IValidableAnnotation

The IEventLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect. (Inherited from IAspectBuildSemantics.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsEventLevelAspect
PostSharp.AspectsIEventLevelAspect


IEventLevelAspectBuildSemantics Methods

IEventLevelAspectBuildSemantics Methods

The IEventLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect. (Inherited from IAspectBuildSemantics.)
Top
See Also

Reference

IEventLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace


IEventLevelAspectBuildSemantics.CompileTimeInitialize Method

IEventLevelAspectBuildSemanticsCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void CompileTimeInitialize(
    EventInfo targetEvent,
    AspectInfo aspectInfo
)

Parameters

targetEvent
Type: System.ReflectionEventInfo
Event to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IEventLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


IFieldLevelAspect Interface

IFieldLevelAspect Interface
Run-time semantics of aspects applied to fields.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IFieldLevelAspect : IAspect

The IFieldLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | RuntimeInitialize | Method invoked at runtime before any other method of the aspect is invoked.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsIFieldLevelAspectBuildSemantics
PostSharp.AspectsFieldLevelAspect


IFieldLevelAspect Methods

IFieldLevelAspect Methods

The IFieldLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | RuntimeInitialize | Method invoked at runtime before any other method of the aspect is invoked.
Top
See Also

Reference

IFieldLevelAspect Interface
PostSharp.Aspects Namespace


IFieldLevelAspect.RuntimeInitialize Method

IFieldLevelAspectRuntimeInitialize Method
Method invoked at runtime before any other method of the aspect is invoked.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void RuntimeInitialize(
    FieldInfo field
)

Parameters

field
Type: System.ReflectionFieldInfo
Field on which this instance is applied.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IFieldLevelAspect Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


IFieldLevelAspectBuildSemantics Interface

IFieldLevelAspectBuildSemantics Interface
Compile-time semantics of IFieldLevelAspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IFieldLevelAspectBuildSemantics : IAspectBuildSemantics,
    IValidableAnnotation

The IFieldLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect. (Inherited from IAspectBuildSemantics.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsIFieldLevelAspect
PostSharp.AspectsFieldLevelAspect


IFieldLevelAspectBuildSemantics Methods

IFieldLevelAspectBuildSemantics Methods

The IFieldLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect. (Inherited from IAspectBuildSemantics.)
Top
See Also

Reference

IFieldLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace


IFieldLevelAspectBuildSemantics.CompileTimeInitialize Method

IFieldLevelAspectBuildSemanticsCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void CompileTimeInitialize(
    FieldInfo field,
    AspectInfo aspectInfo
)

Parameters

field
Type: System.ReflectionFieldInfo
Field to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IFieldLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


IInstanceScopedAspect Interface

IInstanceScopedAspect Interface
Runtime semantics of aspects that have the same lifetime as instance of types to which their are applied (or instance of the declaring type of members to which they are applied).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IInstanceScopedAspect : IAspect

The IInstanceScopedAspect type exposes the following members.

Methods
 | Name | Description
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype.
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed.
Top
Remarks

When an aspect is instance-scoped, a new instance of this aspect is created whenever an instance of the type to which it has been applied is created (concretely, before the call to the base constructor and the own constructor of this type).

New aspect instances are obtained using the prototype design pattern. As any other aspect, an instance-scope aspect has a static instance initialized at build time, then serialized, deserialized at runtime, and initialized by RuntimeInitialize. This static instance then serves as a prototype. When a new instance of the target type is created, the prototype is cloned by the method CreateInstance(AdviceArgs) (typically implemented by a call to MemberwiseClone). Then some system initializations (for instance member import) are performed on the aspect instance, and finally the RuntimeInitializeInstance method is invoked.

When an aspect implementing the IInstanceScopedAspect interface is applied on a static method, field, property, or event, the aspect will be statically scoped and the interface will be ignored.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Understanding Aspect Lifetime and Scope


IInstanceScopedAspect Methods

IInstanceScopedAspect Methods

The IInstanceScopedAspect type exposes the following members.

Methods
 | Name | Description
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype.
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed.
Top
See Also

Reference

IInstanceScopedAspect Interface
PostSharp.Aspects Namespace


IInstanceScopedAspect.CreateInstance Method

IInstanceScopedAspectCreateInstance Method
Creates a new instance of the aspect based on the current instance, serving as a prototype.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object CreateInstance(
    AdviceArgs adviceArgs
)

Parameters

adviceArgs
Type: PostSharp.AspectsAdviceArgs
Aspect arguments.

Return Value

Type: Object
A new instance of the aspect, typically a clone of the current prototype instance.
Remarks
This method is typically implemented by invoking MemberwiseClone.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IInstanceScopedAspect Interface
PostSharp.Aspects Namespace


IInstanceScopedAspect.RuntimeInitializeInstance Method

IInstanceScopedAspectRuntimeInitializeInstance Method
Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void RuntimeInitializeInstance()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IInstanceScopedAspect Interface
PostSharp.Aspects Namespace
PostSharp.Aspects.AdvicesInitializeAspectInstanceAdvice


ILocationBinding Interface

ILocationBinding Interface
Interface through which a field- or property-level aspect or advice can invoke the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocationBinding

The ILocationBinding type exposes the following members.

Methods
 | Name | Description
Public method | GetValue | Invokes the Get semantic on the next node in the chain of invocation.
Public method | SetValue | Invokes the Set semantic on the next node in the chain of invocation.
Top
Properties
 | Name | Description
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration that the binding represents.
Public property | LocationInfo | Gets metadata information about the field or property represented by the current binding.
Public property | LocationType | Gets the type of the field or property.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.Aspects.AdvicesImportMemberAttribute
PostSharp.AspectsILocationBindingT

Other Resources

Conceptual Documentation: Aspect Bindings


ILocationBinding Methods

ILocationBinding Methods

The ILocationBinding type exposes the following members.

Methods
 | Name | Description
Public method | GetValue | Invokes the Get semantic on the next node in the chain of invocation.
Public method | SetValue | Invokes the Set semantic on the next node in the chain of invocation.
Top
See Also

Reference

ILocationBinding Interface
PostSharp.Aspects Namespace


ILocationBinding.GetValue Method

ILocationBindingGetValue Method
Invokes the Get semantic on the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object GetValue(
    ref Object instance,
    Arguments index
)

Parameters

instance
Type: SystemObject
Target instance from which the field or property should be retrieved (null if the field or property is static).
index
Type: PostSharp.AspectsArguments
Index arguments, if the location is an indexer property.

Return Value

Type: Object
The value stored at the location.
Remarks

The instance parameter is passed by reference so that instance methods of value types ( struct in C#) are allowed to change the value of the instance.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILocationBinding Interface
PostSharp.Aspects Namespace


ILocationBinding.SetValue Method

ILocationBindingSetValue Method
Invokes the Set semantic on the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void SetValue(
    ref Object instance,
    Arguments index,
    Object value
)

Parameters

instance
Type: SystemObject
Target instance from which the field or property should be retrieved (null if the field or property is static).
index
Type: PostSharp.AspectsArguments
Index arguments, if the location is an indexer property.
value
Type: SystemObject
New value to be stored at the location.
Remarks

The instance parameter is passed by reference so that instance methods of value types ( struct in C#) are allowed to change the value of the instance.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILocationBinding Interface
PostSharp.Aspects Namespace


ILocationBinding Properties

ILocationBinding Properties

The ILocationBinding type exposes the following members.

Properties
 | Name | Description
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration that the binding represents.
Public property | LocationInfo | Gets metadata information about the field or property represented by the current binding.
Public property | LocationType | Gets the type of the field or property.
Top
See Also

Reference

ILocationBinding Interface
PostSharp.Aspects Namespace


ILocationBinding.DeclarationIdentifier Property

ILocationBindingDeclarationIdentifier Property
Gets the DeclarationIdentifier of the declaration that the binding represents.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
DeclarationIdentifier DeclarationIdentifier { get; }

Property Value

Type: DeclarationIdentifier
Remarks

For usage information, see the remarks of the DeclarationIdentifier type documentation.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationBinding Interface
PostSharp.Aspects Namespace


ILocationBinding.LocationInfo Property

ILocationBindingLocationInfo Property
Gets metadata information about the field or property represented by the current binding.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
LocationInfo LocationInfo { get; }

Property Value

Type: LocationInfo
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationBinding Interface
PostSharp.Aspects Namespace


ILocationBinding.LocationType Property

ILocationBindingLocationType Property
Gets the type of the field or property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Type LocationType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationBinding Interface
PostSharp.Aspects Namespace


ILocationBinding(T) Interface

ILocationBindingT Interface
A strongly-typed variant for ILocationBinding.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocationBinding<T> : ILocationBinding

Type Parameters

T

The ILocationBindingT type exposes the following members.

Methods
 | Name | Description
Public method | GetValue | Invokes the Get semantic on the next node in the chain of invocation.
Public method | SetValue(Object, Arguments, Object) | Invokes the Set semantic on the next node in the chain of invocation. (Inherited from ILocationBinding.)
Public method | SetValue(Object, Arguments, T) | Invokes the Set semantic on the next node in the chain of invocation.
Top
Properties
 | Name | Description
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration that the binding represents. (Inherited from ILocationBinding.)
Public property | LocationInfo | Gets metadata information about the field or property represented by the current binding. (Inherited from ILocationBinding.)
Public property | LocationType | Gets the type of the field or property. (Inherited from ILocationBinding.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects Namespace


ILocationBinding(T) Methods

ILocationBindingT Methods

The ILocationBindingT generic type exposes the following members.

Methods
 | Name | Description
Public method | GetValue | Invokes the Get semantic on the next node in the chain of invocation.
Public method | SetValue(Object, Arguments, Object) | Invokes the Set semantic on the next node in the chain of invocation. (Inherited from ILocationBinding.)
Public method | SetValue(Object, Arguments, T) | Invokes the Set semantic on the next node in the chain of invocation.
Top
See Also

Reference

ILocationBindingT Interface
PostSharp.Aspects Namespace


ILocationBinding(T).GetValue Method

ILocationBindingTGetValue Method
Invokes the Get semantic on the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
T GetValue(
    ref Object instance,
    Arguments index
)

Parameters

instance
Type: SystemObject
Target instance from which the field or property should be retrieved (null if the field or property is static).
index
Type: PostSharp.AspectsArguments
Index arguments, if the location is an indexer property.

Return Value

Type: T
The value stored at the location.
Remarks

The instance parameter is passed by reference so that instance methods of value types ( struct in C#) are allowed to change the value of the instance.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationBindingT Interface
PostSharp.Aspects Namespace


ILocationBinding(T).SetValue Method

ILocationBindingTSetValue Method
Overload List
 | Name | Description
Public method | SetValue(Object, Arguments, Object) | Invokes the Set semantic on the next node in the chain of invocation. (Inherited from ILocationBinding.)
Public method | SetValue(Object, Arguments, T) | Invokes the Set semantic on the next node in the chain of invocation.
Top
See Also

Reference

ILocationBindingT Interface
PostSharp.Aspects Namespace


ILocationBinding(T).SetValue Method (Object, Arguments, T)

ILocationBindingTSetValue Method (Object, Arguments, T)
Invokes the Set semantic on the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void SetValue(
    ref Object instance,
    Arguments index,
    T value
)

Parameters

instance
Type: SystemObject
Target instance from which the field or property should be retrieved (null if the field or property is static).
index
Type: PostSharp.AspectsArguments
Index arguments, if the location is an indexer property.
value
Type: T
New value to be stored at the location.
Remarks

The instance parameter is passed by reference so that instance methods of value types ( struct in C#) are allowed to change the value of the instance.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationBindingT Interface
SetValue Overload
PostSharp.Aspects Namespace


ILocationBinding(T) Properties

ILocationBindingT Properties

The ILocationBindingT generic type exposes the following members.

Properties
 | Name | Description
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration that the binding represents. (Inherited from ILocationBinding.)
Public property | LocationInfo | Gets metadata information about the field or property represented by the current binding. (Inherited from ILocationBinding.)
Public property | LocationType | Gets the type of the field or property. (Inherited from ILocationBinding.)
Top
See Also

Reference

ILocationBindingT Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs Interface

ILocationInterceptionArgs Interface
An interface for LocationInterceptionArgs.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocationInterceptionArgs

The ILocationInterceptionArgs type exposes the following members.

Methods
 | Name | Description
Public method | ExecuteTPayload | Executes a delegate for the current LocationInterceptionArgs. This method allows to execute strongly-typed operations and avoid boxing required by the weakly typed ILocationInterceptionArgs interface.
Public method | GetCurrentValue | Retrieves the current value of the location without overwriting the Value property.
Public method | ProceedGetValue | Invokes the Get Location Value semantic on the next node in the chain of invocation and stores the location value in the Value property.
Public method | ProceedSetValue | Invokes the Set Location Value semantic on the next node in the chain of invocation and stores the value of the Value property into the location.
Public method | SetNewValue | Sets the value of the location without overwriting the Value property.
Top
Properties
 | Name | Description
Public property | Binding | Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.
Public property | Index | Gets the current index arguments (in case of a property with parameters).
Public property | Instance | Gets or sets the object instance on which the method is being executed.
Public property | Location | Gets the location (field, property or parameter) related to the aspect or advice being executed.
Public property | LocationFullName | Gets the full name (including the full name of the declaring type) of the location (field, property or parameter) related to the aspect or advice being executed.
Public property | LocationName | Gets the name of the location (field, property or parameter) related to the aspect or advice being executed.
Public property | Value | Gets or sets the location value.
Top
Remarks

This interface is not generally used directly, but it serves as a base for the strongly-typed ILocationInterceptionArgsT, which is used by ExecuteTPayload(ILocationInterceptionArgsActionTPayload, TPayload).

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects Namespace


ILocationInterceptionArgs Methods

ILocationInterceptionArgs Methods

The ILocationInterceptionArgs type exposes the following members.

Methods
 | Name | Description
Public method | ExecuteTPayload | Executes a delegate for the current LocationInterceptionArgs. This method allows to execute strongly-typed operations and avoid boxing required by the weakly typed ILocationInterceptionArgs interface.
Public method | GetCurrentValue | Retrieves the current value of the location without overwriting the Value property.
Public method | ProceedGetValue | Invokes the Get Location Value semantic on the next node in the chain of invocation and stores the location value in the Value property.
Public method | ProceedSetValue | Invokes the Set Location Value semantic on the next node in the chain of invocation and stores the value of the Value property into the location.
Public method | SetNewValue | Sets the value of the location without overwriting the Value property.
Top
See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.Execute(TPayload) Method

ILocationInterceptionArgsExecuteTPayload Method
Executes a delegate for the current LocationInterceptionArgs. This method allows to execute strongly-typed operations and avoid boxing required by the weakly typed ILocationInterceptionArgs interface.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void Execute<TPayload>(
    ILocationInterceptionArgsAction<TPayload> action,
    ref TPayload payload
)

Parameters

action
Type: PostSharp.AspectsILocationInterceptionArgsAction TPayload
Class (typically a singleton) that contains the generic method ExecuteTValue(ILocationInterceptionArgsTValue, TPayload) that will be executed with the right method generic argument.
payload
Type: TPayload
An argument being passed to the ExecuteTValue(ILocationInterceptionArgsTValue, TPayload) method of the action parameter.

Type Parameters

TPayload
Type of the payload.
Remarks
Note Note

This method is ignored by the advice optimizer. As a result, the optimizer will not know that the action implementation uses any feature of the LocationInterceptionArgs object, and the code supporting these features won't be generated. If these features are required by action, they must be referenced inside the OnGetValue(LocationInterceptionArgs) or OnSetValue(LocationInterceptionArgs) method.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.GetCurrentValue Method

ILocationInterceptionArgsGetCurrentValue Method
Retrieves the current value of the location without overwriting the Value property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object GetCurrentValue()

Return Value

Type: Object
The current value of the location, as returned by the next node in the chain of invocation (see Binding).
Remarks
Note Note
This method is designed to be invoked during the execution of the advice. If you need to retrieve or store the value of the location at a different time, it is recommended to use the Binding . Indeed, a binding is stateless, while LocationInterceptionArgs instances may be shared among different aspects.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.ProceedGetValue Method

ILocationInterceptionArgsProceedGetValue Method
Invokes the Get Location Value semantic on the next node in the chain of invocation and stores the location value in the Value property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void ProceedGetValue()
Remarks

Note that this method overwrites the content of the Value property. Therefore, you should not call this invoke from a OnSetValue(LocationInterceptionArgs) advice unless you store the value before. If you need to retrieve the current value of the location from a OnSetValue(LocationInterceptionArgs) advice, it is recommended you use the GetCurrentValue method.

Note Note
This method is designed to be invoked during the execution of the advice. If you need to retrieve or store the value of the location at a different time, it is recommended to use the Binding . Indeed, a binding is stateless, while LocationInterceptionArgs instances may be shared among different aspects.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.ProceedSetValue Method

ILocationInterceptionArgsProceedSetValue Method
Invokes the Set Location Value semantic on the next node in the chain of invocation and stores the value of the Value property into the location.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void ProceedSetValue()
Remarks

Note that this method requires the value to be stored in the Value property. If you need to retrieve the current value of the location from a OnSetValue(LocationInterceptionArgs) advice, it is recommended you use the GetCurrentValue method.

Note Note
This method is designed to be invoked during the execution of the advice. If you need to retrieve or store the value of the location at a different time, it is recommended to use the Binding . Indeed, a binding is stateless, while LocationInterceptionArgs instances may be shared among different aspects.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.SetNewValue Method

ILocationInterceptionArgsSetNewValue Method
Sets the value of the location without overwriting the Value property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void SetNewValue(
    Object value
)

Parameters

value
Type: SystemObject
The value to be passed to the next node in the chain of invocation (see Binding).
Remarks

Note Note
This method is designed to be invoked during the execution of the advice. If you need to retrieve or store the value of the location at a different time, it is recommended to use the Binding . Indeed, a binding is stateless, while LocationInterceptionArgs instances may be shared among different aspects.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs Properties

ILocationInterceptionArgs Properties

The ILocationInterceptionArgs type exposes the following members.

Properties
 | Name | Description
Public property | Binding | Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.
Public property | Index | Gets the current index arguments (in case of a property with parameters).
Public property | Instance | Gets or sets the object instance on which the method is being executed.
Public property | Location | Gets the location (field, property or parameter) related to the aspect or advice being executed.
Public property | LocationFullName | Gets the full name (including the full name of the declaring type) of the location (field, property or parameter) related to the aspect or advice being executed.
Public property | LocationName | Gets the name of the location (field, property or parameter) related to the aspect or advice being executed.
Public property | Value | Gets or sets the location value.
Top
See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.Binding Property

ILocationInterceptionArgsBinding Property
Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ILocationBinding Binding { get; }

Property Value

Type: ILocationBinding
Remarks

Bindings are thread-safe and context-free singleton instances exposing the next node in the chain of invocation.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Aspect Bindings


ILocationInterceptionArgs.Index Property

ILocationInterceptionArgsIndex Property
Gets the current index arguments (in case of a property with parameters).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Arguments Index { get; }

Property Value

Type: Arguments
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.Instance Property

ILocationInterceptionArgsInstance Property
Gets or sets the object instance on which the method is being executed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object Instance { get; set; }

Property Value

Type: Object
Remarks
This set may be set by user code only when the instance is a value type. As usually, user code is responsible for setting an object of the right type.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.Location Property

ILocationInterceptionArgsLocation Property
Gets the location (field, property or parameter) related to the aspect or advice being executed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
LocationInfo Location { get; set; }

Property Value

Type: LocationInfo
Remarks
Note Note
Using this property causes the aspect weaver to generate code that has non-trivial runtime overhead. Avoid using this property whenever possible. One of the possible solution is to use compile-time initialization of aspect instances and to make use of reflection only at build time.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.LocationFullName Property

ILocationInterceptionArgsLocationFullName Property
Gets the full name (including the full name of the declaring type) of the location (field, property or parameter) related to the aspect or advice being executed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string LocationFullName { get; set; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.LocationName Property

ILocationInterceptionArgsLocationName Property
Gets the name of the location (field, property or parameter) related to the aspect or advice being executed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string LocationName { get; set; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs.Value Property

ILocationInterceptionArgsValue Property
Gets or sets the location value.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object Value { get; set; }

Property Value

Type: Object
Remarks

Inside an OnGetValue(LocationInterceptionArgs) advice, this property is available after the next advice in chain has been invoked using ProceedGetValue. However, inside an OnSetValue(LocationInterceptionArgs) advice, the value is available immediately, and is used as input by ProceedSetValue.

See GetCurrentValue and SetNewValue(Object) to get or set the value of the location without affecting the value of this property.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgs Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs(T) Interface

ILocationInterceptionArgsT Interface
A strongly-typed specialization of the ILocationInterceptionArgs interface.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocationInterceptionArgs<T> : ILocationInterceptionArgs

Type Parameters

T
Type of the location value.

The ILocationInterceptionArgsT type exposes the following members.

Methods
 | Name | Description
Public method | ExecuteTPayload | Executes a delegate for the current LocationInterceptionArgs. This method allows to execute strongly-typed operations and avoid boxing required by the weakly typed ILocationInterceptionArgs interface. (Inherited from ILocationInterceptionArgs.)
Public method | GetCurrentValue | Retrieves the current value of the location without overwriting the Value property.
Public method | ProceedGetValue | Invokes the Get Location Value semantic on the next node in the chain of invocation and stores the location value in the Value property. (Inherited from ILocationInterceptionArgs.)
Public method | ProceedSetValue | Invokes the Set Location Value semantic on the next node in the chain of invocation and stores the value of the Value property into the location. (Inherited from ILocationInterceptionArgs.)
Public method | SetNewValue(Object) | Sets the value of the location without overwriting the Value property. (Inherited from ILocationInterceptionArgs.)
Public method | SetNewValue(T) | Sets the value of the location without overwriting the Value property.
Top
Properties
 | Name | Description
Public property | Binding | Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.
Public property | Index | Gets the current index arguments (in case of a property with parameters). (Inherited from ILocationInterceptionArgs.)
Public property | Instance | Gets or sets the object instance on which the method is being executed. (Inherited from ILocationInterceptionArgs.)
Public property | Location | Gets the location (field, property or parameter) related to the aspect or advice being executed. (Inherited from ILocationInterceptionArgs.)
Public property | LocationFullName | Gets the full name (including the full name of the declaring type) of the location (field, property or parameter) related to the aspect or advice being executed. (Inherited from ILocationInterceptionArgs.)
Public property | LocationName | Gets the name of the location (field, property or parameter) related to the aspect or advice being executed. (Inherited from ILocationInterceptionArgs.)
Public property | Value | Gets or sets the location value.
Top
Remarks
Use the ExecuteTPayload(ILocationInterceptionArgsActionTPayload, TPayload) method to consume this interface.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects Namespace


ILocationInterceptionArgs(T) Methods

ILocationInterceptionArgsT Methods

The ILocationInterceptionArgsT generic type exposes the following members.

Methods
 | Name | Description
Public method | ExecuteTPayload | Executes a delegate for the current LocationInterceptionArgs. This method allows to execute strongly-typed operations and avoid boxing required by the weakly typed ILocationInterceptionArgs interface. (Inherited from ILocationInterceptionArgs.)
Public method | GetCurrentValue | Retrieves the current value of the location without overwriting the Value property.
Public method | ProceedGetValue | Invokes the Get Location Value semantic on the next node in the chain of invocation and stores the location value in the Value property. (Inherited from ILocationInterceptionArgs.)
Public method | ProceedSetValue | Invokes the Set Location Value semantic on the next node in the chain of invocation and stores the value of the Value property into the location. (Inherited from ILocationInterceptionArgs.)
Public method | SetNewValue(Object) | Sets the value of the location without overwriting the Value property. (Inherited from ILocationInterceptionArgs.)
Public method | SetNewValue(T) | Sets the value of the location without overwriting the Value property.
Top
See Also

Reference

ILocationInterceptionArgsT Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs(T).GetCurrentValue Method

ILocationInterceptionArgsTGetCurrentValue Method
Retrieves the current value of the location without overwriting the Value property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
T GetCurrentValue()

Return Value

Type: T
The current value of the location, as returned by the next node in the chain of invocation (see Binding).
Remarks
Note Note
This method is designed to be invoked during the execution of the advice. If you need to retrieve or store the value of the location at a different time, it is recommended to use the Binding . Indeed, a binding is stateless, while LocationInterceptionArgs instances may be shared among different aspects.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgsT Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs(T).SetNewValue Method

ILocationInterceptionArgsTSetNewValue Method
Overload List
 | Name | Description
Public method | SetNewValue(Object) | Sets the value of the location without overwriting the Value property. (Inherited from ILocationInterceptionArgs.)
Public method | SetNewValue(T) | Sets the value of the location without overwriting the Value property.
Top
See Also

Reference

ILocationInterceptionArgsT Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs(T).SetNewValue Method (T)

ILocationInterceptionArgsTSetNewValue Method (T)
Sets the value of the location without overwriting the Value property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void SetNewValue(
    T value
)

Parameters

value
Type: T
The value to be passed to the next node in the chain of invocation (see Binding).
Remarks

Note Note
This method is designed to be invoked during the execution of the advice. If you need to retrieve or store the value of the location at a different time, it is recommended to use the Binding . Indeed, a binding is stateless, while LocationInterceptionArgs instances may be shared among different aspects.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgsT Interface
SetNewValue Overload
PostSharp.Aspects Namespace


ILocationInterceptionArgs(T) Properties

ILocationInterceptionArgsT Properties

The ILocationInterceptionArgsT generic type exposes the following members.

Properties
 | Name | Description
Public property | Binding | Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.
Public property | Index | Gets the current index arguments (in case of a property with parameters). (Inherited from ILocationInterceptionArgs.)
Public property | Instance | Gets or sets the object instance on which the method is being executed. (Inherited from ILocationInterceptionArgs.)
Public property | Location | Gets the location (field, property or parameter) related to the aspect or advice being executed. (Inherited from ILocationInterceptionArgs.)
Public property | LocationFullName | Gets the full name (including the full name of the declaring type) of the location (field, property or parameter) related to the aspect or advice being executed. (Inherited from ILocationInterceptionArgs.)
Public property | LocationName | Gets the name of the location (field, property or parameter) related to the aspect or advice being executed. (Inherited from ILocationInterceptionArgs.)
Public property | Value | Gets or sets the location value.
Top
See Also

Reference

ILocationInterceptionArgsT Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgs(T).Binding Property

ILocationInterceptionArgsTBinding Property
Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ILocationBinding<T> Binding { get; }

Property Value

Type: ILocationBinding T
Remarks

Bindings are thread-safe and context-free singleton instances exposing the next node in the chain of invocation.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgsT Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Aspect Bindings


ILocationInterceptionArgs(T).Value Property

ILocationInterceptionArgsTValue Property
Gets or sets the location value.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
T Value { get; set; }

Property Value

Type: T
Remarks

Inside an OnGetValue(LocationInterceptionArgs) advice, this property is available after the next advice in chain has been invoked using ProceedGetValue. However, inside an OnSetValue(LocationInterceptionArgs) advice, the value is available immediately, and is used as input by ProceedSetValue.

See GetCurrentValue and SetNewValue(T) to get or set the value of the location without affecting the value of this property.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgsT Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgsAction(TPayload) Interface

ILocationInterceptionArgsActionTPayload Interface
Exposes an ExecuteTValue(ILocationInterceptionArgsTValue, TPayload) method invoked by the ExecuteTPayload(ILocationInterceptionArgsActionTPayload, TPayload) method, which allows to execute strongly-typed operations and avoid boxing required by the weakly typed ILocationInterceptionArgs interface.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocationInterceptionArgsAction<TPayload>

Type Parameters

TPayload
Type of the payload of the ExecuteTValue(ILocationInterceptionArgsTValue, TPayload) method.

The ILocationInterceptionArgsActionTPayload type exposes the following members.

Methods
 | Name | Description
Public method | ExecuteTValue | Method invoked by the ExecuteTPayload(ILocationInterceptionArgsActionTPayload, TPayload) method.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects Namespace


ILocationInterceptionArgsAction(TPayload) Methods

ILocationInterceptionArgsActionTPayload Methods

The ILocationInterceptionArgsActionTPayload generic type exposes the following members.

Methods
 | Name | Description
Public method | ExecuteTValue | Method invoked by the ExecuteTPayload(ILocationInterceptionArgsActionTPayload, TPayload) method.
Top
See Also

Reference

ILocationInterceptionArgsActionTPayload Interface
PostSharp.Aspects Namespace


ILocationInterceptionArgsAction(TPayload).Execute(TValue) Method

ILocationInterceptionArgsActionTPayloadExecuteTValue Method
Method invoked by the ExecuteTPayload(ILocationInterceptionArgsActionTPayload, TPayload) method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void Execute<TValue>(
    ILocationInterceptionArgs<TValue> args,
    ref TPayload payload
)

Parameters

args
Type: PostSharp.AspectsILocationInterceptionArgs TValue
The typed LocationInterceptionArgs.
payload
Type: TPayload
Payload passed to the ExecuteTPayload(ILocationInterceptionArgsActionTPayload, TPayload) method.

Type Parameters

TValue
Type of the value of the LocationInterceptionArgs object.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ILocationInterceptionArgsActionTPayload Interface
PostSharp.Aspects Namespace


ILocationInterceptionAspect Interface

ILocationInterceptionAspect Interface
Runtime semantics of an aspect that, when applied on a location (field or property), intercepts invocations of the Get (OnGetValue(LocationInterceptionArgs)) and Set (OnSetValue(LocationInterceptionArgs)) semantics.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocationInterceptionAspect : ILocationLevelAspect,
    IAspect

The ILocationInterceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnGetValue | Method invoked instead of the Get semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is retrieved.
Public method | OnSetValue | Method invoked instead of the Set semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is changed.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from ILocationLevelAspect.)
Top
Remarks
See LocationInterceptionAspect for details.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


ILocationInterceptionAspect Methods

ILocationInterceptionAspect Methods

The ILocationInterceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnGetValue | Method invoked instead of the Get semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is retrieved.
Public method | OnSetValue | Method invoked instead of the Set semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is changed.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from ILocationLevelAspect.)
Top
See Also

Reference

ILocationInterceptionAspect Interface
PostSharp.Aspects Namespace


ILocationInterceptionAspect.OnGetValue Method

ILocationInterceptionAspectOnGetValue Method
Method invoked instead of the Get semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is retrieved.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnGetValue(
    LocationInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsLocationInterceptionArgs
Advice arguments.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILocationInterceptionAspect Interface
PostSharp.Aspects Namespace
PostSharp.AspectsLocationInterceptionArgs


ILocationInterceptionAspect.OnSetValue Method

ILocationInterceptionAspectOnSetValue Method
Method invoked instead of the Set semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is changed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnSetValue(
    LocationInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsLocationInterceptionArgs
Advice arguments.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILocationInterceptionAspect Interface
PostSharp.Aspects Namespace
PostSharp.AspectsLocationInterceptionArgs


ILocationLevelAspect Interface

ILocationLevelAspect Interface
Runtime semantics of aspects defined on a field, property, or parameter.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocationLevelAspect : IAspect

The ILocationLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | RuntimeInitialize | Initializes the current aspect.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


ILocationLevelAspect Methods

ILocationLevelAspect Methods

The ILocationLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | RuntimeInitialize | Initializes the current aspect.
Top
See Also

Reference

ILocationLevelAspect Interface
PostSharp.Aspects Namespace


ILocationLevelAspect.RuntimeInitialize Method

ILocationLevelAspectRuntimeInitialize Method
Initializes the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void RuntimeInitialize(
    LocationInfo locationInfo
)

Parameters

locationInfo
Type: PostSharp.ReflectionLocationInfo
Location to which the current aspect is applied.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILocationLevelAspect Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


ILocationLevelAspectBuildSemantics Interface

ILocationLevelAspectBuildSemantics Interface
Compile-time semantics of ILocationLevelAspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocationLevelAspectBuildSemantics : IAspectBuildSemantics,
    IValidableAnnotation

The ILocationLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect. (Inherited from IAspectBuildSemantics.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


ILocationLevelAspectBuildSemantics Methods

ILocationLevelAspectBuildSemantics Methods

The ILocationLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect. (Inherited from IAspectBuildSemantics.)
Top
See Also

Reference

ILocationLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace


ILocationLevelAspectBuildSemantics.CompileTimeInitialize Method

ILocationLevelAspectBuildSemanticsCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void CompileTimeInitialize(
    LocationInfo targetLocation,
    AspectInfo aspectInfo
)

Parameters

targetLocation
Type: PostSharp.ReflectionLocationInfo
Location to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILocationLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


ILocationValidationAspect Interface

ILocationValidationAspect Interface
Ancestor of ILocationValidationAspectT.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocationValidationAspect : IAspect
Remarks

This interface exists only because PostSharp SDK requires a common non-generic interface for ILocationValidationAspectT. It should not be used in user code.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


ILocationValidationAspect(T) Interface

ILocationValidationAspectT Interface
Runtime semantics of an aspect that, when applied on a location (field, property, or parameter), validates the value assigned to this location using method ValidateValue(T, String, LocationKind), and throws the exception returned by this method if any.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocationValidationAspect<T> : ILocationValidationAspect,
    IAspect

Type Parameters

T
Type of values validated by the current aspect.

The ILocationValidationAspectT type exposes the following members.

Methods
 | Name | Description
Public method | ValidateValue | Validates the value being assigned to the location to which the current aspect has been applied.
Top
Remarks

An aspect will typically implement several generic instances of the current interface, with different values of T. The aspect can be applied only to locations for which there is an exact type match. PostSharp does not implement any type conversion, even when this conversion is implicitly supported by the compiler, for instance int to long. Therefore, if your aspect must be able to validate all integers, you may need to implement the interface instances for T ranging in long, int, short, sbyte and possibly their unsigned variant. However, values of a derived type can be validated if T is the base type.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.Aspects.AdvicesLocationValidationAdvice


ILocationValidationAspect(T) Methods

ILocationValidationAspectT Methods

The ILocationValidationAspectT generic type exposes the following members.

Methods
 | Name | Description
Public method | ValidateValue | Validates the value being assigned to the location to which the current aspect has been applied.
Top
See Also

Reference

ILocationValidationAspectT Interface
PostSharp.Aspects Namespace


ILocationValidationAspect(T).ValidateValue Method

ILocationValidationAspectTValidateValue Method
Validates the value being assigned to the location to which the current aspect has been applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Exception ValidateValue(
    T value,
    string locationName,
    LocationKind locationKind
)

Parameters

value
Type: T
Value being applied to the location.
locationName
Type: SystemString
Name of the location.
locationKind
Type: PostSharp.ReflectionLocationKind
Location kind (Field, Property, or Parameter).

Return Value

Type: Exception
The Exception to be thrown, or null if no exception needs to be thrown.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILocationValidationAspectT Interface
PostSharp.Aspects Namespace


IManagedResourceIntroductionAspect Interface

IManagedResourceIntroductionAspect Interface
Semantics of an aspect that, when applied to an assembly, adds a managed resource to this assembly.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IManagedResourceIntroductionAspect : IAspect
Remarks
See ManagedResourceIntroductionAspect for details.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsManagedResourceIntroductionAspect
PostSharp.Aspects.ConfigurationManagedResourceIntroductionAspectConfiguration


IMethodBinding Interface

IMethodBinding Interface
Interface through which a method-level aspect or advice can invoke the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMethodBinding

The IMethodBinding type exposes the following members.

Methods
 | Name | Description
Public method | Invoke | Invokes the next node in the chain of invocation.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.Aspects.AdvicesImportMemberAttribute

Other Resources

Conceptual Documentation: Aspect Bindings


IMethodBinding Methods

IMethodBinding Methods

The IMethodBinding type exposes the following members.

Methods
 | Name | Description
Public method | Invoke | Invokes the next node in the chain of invocation.
Top
See Also

Reference

IMethodBinding Interface
PostSharp.Aspects Namespace


IMethodBinding.Invoke Method

IMethodBindingInvoke Method
Invokes the next node in the chain of invocation.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object Invoke(
    ref Object instance,
    Arguments arguments
)

Parameters

instance
Type: SystemObject
Target instance on which the method should be invoked (null if the method is static).
arguments
Type: PostSharp.AspectsArguments
Method arguments.

Return Value

Type: Object
Return value of the method.
Remarks

The instance parameter is passed by reference so that instance methods of value types ( struct in C#) are allowed to change the value of the instance.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodBinding Interface
PostSharp.Aspects Namespace


IMethodInterceptionAspect Interface

IMethodInterceptionAspect Interface
Runtime semantics of an aspect that, when applied on a method, intercepts invocations of this method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMethodInterceptionAspect : IMethodLevelAspect,
    IAspect

The IMethodInterceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnInvoke | Method invoked instead of the method to which the aspect has been applied.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from IMethodLevelAspect.)
Top
Remarks
See MethodInterceptionAspect for details.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


IMethodInterceptionAspect Methods

IMethodInterceptionAspect Methods

The IMethodInterceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnInvoke | Method invoked instead of the method to which the aspect has been applied.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from IMethodLevelAspect.)
Top
See Also

Reference

IMethodInterceptionAspect Interface
PostSharp.Aspects Namespace


IMethodInterceptionAspect.OnInvoke Method

IMethodInterceptionAspectOnInvoke Method
Method invoked instead of the method to which the aspect has been applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnInvoke(
    MethodInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodInterceptionArgs
Advice arguments.
Remarks

The implementation of OnInvoke(MethodInterceptionArgs) may invoke Proceed, may schedule it for invocation from another thread, or may completely skip its invocation. Alternatively, it may use Binding. Before returning to the caller, the OnInvoke(MethodInterceptionArgs) method must set the return value (property ReturnValue) and all output arguments (property Arguments), otherwise the target method may fail with a NullReferenceException. These are normally set by calling Proceed.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodInterceptionAspect Interface
PostSharp.Aspects Namespace
PostSharp.AspectsMethodInterceptionArgs


IMethodLevelAspect Interface

IMethodLevelAspect Interface
Runtime semantics of aspects applied to methods.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMethodLevelAspect : IAspect

The IMethodLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | RuntimeInitialize | Initializes the current aspect.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsIMethodLevelAspectBuildSemantics
PostSharp.AspectsMethodLevelAspect


IMethodLevelAspect Methods

IMethodLevelAspect Methods

The IMethodLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | RuntimeInitialize | Initializes the current aspect.
Top
See Also

Reference

IMethodLevelAspect Interface
PostSharp.Aspects Namespace


IMethodLevelAspect.RuntimeInitialize Method

IMethodLevelAspectRuntimeInitialize Method
Initializes the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void RuntimeInitialize(
    MethodBase method
)

Parameters

method
Type: System.ReflectionMethodBase
Method to which the current aspect is applied.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodLevelAspect Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


IMethodLevelAspectBuildSemantics Interface

IMethodLevelAspectBuildSemantics Interface
Compile-time semantics of IMethodLevelAspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMethodLevelAspectBuildSemantics : IAspectBuildSemantics,
    IValidableAnnotation

The IMethodLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect. (Inherited from IAspectBuildSemantics.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


IMethodLevelAspectBuildSemantics Methods

IMethodLevelAspectBuildSemantics Methods

The IMethodLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect. (Inherited from IAspectBuildSemantics.)
Top
See Also

Reference

IMethodLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace


IMethodLevelAspectBuildSemantics.CompileTimeInitialize Method

IMethodLevelAspectBuildSemanticsCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void CompileTimeInitialize(
    MethodBase method,
    AspectInfo aspectInfo
)

Parameters

method
Type: System.ReflectionMethodBase
Method to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


InstanceLevelAspect Class

InstanceLevelAspect Class
Base class for aspects applied on types, but having the same lifetime as instances of the type to which they are applied.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableAttribute
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ModelNotifyPropertyChangedAttribute
PostSharp.Patterns.RecordingEditableObjectAttribute
PostSharp.Patterns.RecordingRecordableAttribute

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class InstanceLevelAspect : TypeLevelAspect,
    ICloneAwareAspect, IInstanceScopedAspect, IAspect

The InstanceLevelAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | InstanceLevelAspect | Initializes a new instance of the InstanceLevelAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype.
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied.
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

This class is provided for convenience. You get the same functionality by deriving your aspect class directly from TypeLevelAspect and implementing the interface IInstanceScopedAspect

See IInstanceScopedAspect for a discussion of instance-scoped aspects.

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsIInstanceScopedAspect

Other Resources

Conceptual Documentation: Aspect Serialization
Conceptual Documentation: Understanding Aspect Lifetime and Scope


InstanceLevelAspect Constructor

InstanceLevelAspect Constructor
Initializes a new instance of the InstanceLevelAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected InstanceLevelAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceLevelAspect Class
PostSharp.Aspects Namespace


InstanceLevelAspect Methods

InstanceLevelAspect Methods

The InstanceLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype.
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

InstanceLevelAspect Class
PostSharp.Aspects Namespace


InstanceLevelAspect.CreateAspectConfiguration Method

InstanceLevelAspectCreateAspectConfiguration Method
Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the Aspect.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration, Object) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


InstanceLevelAspect.CreateInstance Method

InstanceLevelAspectCreateInstance Method
Creates a new instance of the aspect based on the current instance, serving as a prototype.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object CreateInstance(
    AdviceArgs adviceArgs
)

Parameters

adviceArgs
Type: PostSharp.AspectsAdviceArgs
Aspect arguments.

Return Value

Type: Object
A new instance of the aspect, typically a clone of the current prototype instance.

Implements

IInstanceScopedAspectCreateInstance(AdviceArgs)
Remarks
This method is typically implemented by invoking MemberwiseClone.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceLevelAspect Class
PostSharp.Aspects Namespace


InstanceLevelAspect.OnCloned Method

InstanceLevelAspectOnCloned Method
Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnCloned(
    ICloneAwareAspect source
)

Parameters

source
Type: PostSharp.AspectsICloneAwareAspect
Aspect instance corresponding to the current aspect instance in the cloned target object.

Implements

ICloneAwareAspectOnCloned(ICloneAwareAspect)
Remarks

Prior to calling the current method, the aspect framework initializes the source object using CreateInstance(AdviceArgs) and RuntimeInitializeInstance. That is, the aspect instance in the cloned object is not cloned from the source aspect instance, but from the prototype aspect instance.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceLevelAspect Class
PostSharp.Aspects Namespace


InstanceLevelAspect.RuntimeInitializeInstance Method

InstanceLevelAspectRuntimeInitializeInstance Method
Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void RuntimeInitializeInstance()

Implements

IInstanceScopedAspectRuntimeInitializeInstance
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceLevelAspect Class
PostSharp.Aspects Namespace
PostSharp.Aspects.AdvicesInitializeAspectInstanceAdvice


InstanceLevelAspect Properties

InstanceLevelAspect Properties

The InstanceLevelAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied.
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

InstanceLevelAspect Class
PostSharp.Aspects Namespace


InstanceLevelAspect.Instance Property

InstanceLevelAspectInstance Property
Gets the object to which the current aspect has been applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Instance { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceLevelAspect Class
PostSharp.Aspects Namespace


IOnExceptionAspect Interface

IOnExceptionAspect Interface
Runtime semantics of an aspect that, when applied on a method, defines an exception handler around the whole method body and let the implementation of this interface handle the exception.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IOnExceptionAspect : IMethodLevelAspect,
    IAspect

The IOnExceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnException | Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception (i.e., in a catch block).
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from IMethodLevelAspect.)
Top
Remarks

See OnExceptionAspect for details.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsOnExceptionAspect
PostSharp.Aspects.ConfigurationOnExceptionAspectConfiguration
PostSharp.Aspects.ConfigurationOnExceptionAspectConfigurationAttribute


IOnExceptionAspect Methods

IOnExceptionAspect Methods

The IOnExceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnException | Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception (i.e., in a catch block).
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from IMethodLevelAspect.)
Top
See Also

Reference

IOnExceptionAspect Interface
PostSharp.Aspects Namespace


IOnExceptionAspect.OnException Method

IOnExceptionAspectOnException Method
Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception (i.e., in a catch block).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnException(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Advice arguments.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IOnExceptionAspect Interface
PostSharp.Aspects Namespace


IOnMethodBoundaryAspect Interface

IOnMethodBoundaryAspect Interface
Runtime semantics of OnMethodBoundaryAspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IOnMethodBoundaryAspect : IMethodLevelAspect,
    IAspect

The IOnMethodBoundaryAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnEntry | Method executed before the body of methods to which this aspect is applied.
Public method | OnException | Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception.
Public method | OnExit | Method executed after the body of methods to which this aspect is applied, even when the method exists with an exception (this method is invoked from the finally block).
Public method | OnSuccess | Method executed after the body of methods to which this aspect is applied, but only when the method successfully returns (i.e. when no exception flies out the method.).
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from IMethodLevelAspect.)
Top
Remarks

See OnMethodBoundaryAspect for details.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsOnMethodBoundaryAspect
PostSharp.Aspects.ConfigurationOnMethodBoundaryAspectConfiguration
PostSharp.Aspects.ConfigurationOnMethodBoundaryAspectConfigurationAttribute


IOnMethodBoundaryAspect Methods

IOnMethodBoundaryAspect Methods

The IOnMethodBoundaryAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnEntry | Method executed before the body of methods to which this aspect is applied.
Public method | OnException | Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception.
Public method | OnExit | Method executed after the body of methods to which this aspect is applied, even when the method exists with an exception (this method is invoked from the finally block).
Public method | OnSuccess | Method executed after the body of methods to which this aspect is applied, but only when the method successfully returns (i.e. when no exception flies out the method.).
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from IMethodLevelAspect.)
Top
See Also

Reference

IOnMethodBoundaryAspect Interface
PostSharp.Aspects Namespace


IOnMethodBoundaryAspect.OnEntry Method

IOnMethodBoundaryAspectOnEntry Method
Method executed before the body of methods to which this aspect is applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnEntry(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed, which are its arguments, and how should the execution continue after the execution of OnEntry(MethodExecutionArgs).
Remarks
If the aspect is applied to a constructor, the current method is invoked after the this pointer has been initialized, that is, after the base constructor has been called.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IOnMethodBoundaryAspect Interface
PostSharp.Aspects Namespace


IOnMethodBoundaryAspect.OnException Method

IOnMethodBoundaryAspectOnException Method
Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnException(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed and which are its arguments.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IOnMethodBoundaryAspect Interface
PostSharp.Aspects Namespace


IOnMethodBoundaryAspect.OnExit Method

IOnMethodBoundaryAspectOnExit Method
Method executed after the body of methods to which this aspect is applied, even when the method exists with an exception (this method is invoked from the finally block).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnExit(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed and which are its arguments.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IOnMethodBoundaryAspect Interface
PostSharp.Aspects Namespace


IOnMethodBoundaryAspect.OnSuccess Method

IOnMethodBoundaryAspectOnSuccess Method
Method executed after the body of methods to which this aspect is applied, but only when the method successfully returns (i.e. when no exception flies out the method.).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnSuccess(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed and which are its arguments.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IOnMethodBoundaryAspect Interface
PostSharp.Aspects Namespace


IOnStateMachineBoundaryAspect Interface

IOnStateMachineBoundaryAspect Interface
Extends the IOnMethodBoundaryAspect interface with two advises to be applied on state machines.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IOnStateMachineBoundaryAspect : IOnMethodBoundaryAspect,
    IMethodLevelAspect, IAspect

The IOnStateMachineBoundaryAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnEntry | Method executed before the body of methods to which this aspect is applied. (Inherited from IOnMethodBoundaryAspect.)
Public method | OnException | Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception. (Inherited from IOnMethodBoundaryAspect.)
Public method | OnExit | Method executed after the body of methods to which this aspect is applied, even when the method exists with an exception (this method is invoked from the finally block). (Inherited from IOnMethodBoundaryAspect.)
Public method | OnResume | Method executed when a state machine resumes execution after an yield return or await statement.
Public method | OnSuccess | Method executed after the body of methods to which this aspect is applied, but only when the method successfully returns (i.e. when no exception flies out the method.). (Inherited from IOnMethodBoundaryAspect.)
Public method | OnYield | Method executed when a state machine yields, as the result of an yield return or await statement.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from IMethodLevelAspect.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


IOnStateMachineBoundaryAspect Methods

IOnStateMachineBoundaryAspect Methods

The IOnStateMachineBoundaryAspect type exposes the following members.

Methods
 | Name | Description
Public method | OnEntry | Method executed before the body of methods to which this aspect is applied. (Inherited from IOnMethodBoundaryAspect.)
Public method | OnException | Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception. (Inherited from IOnMethodBoundaryAspect.)
Public method | OnExit | Method executed after the body of methods to which this aspect is applied, even when the method exists with an exception (this method is invoked from the finally block). (Inherited from IOnMethodBoundaryAspect.)
Public method | OnResume | Method executed when a state machine resumes execution after an yield return or await statement.
Public method | OnSuccess | Method executed after the body of methods to which this aspect is applied, but only when the method successfully returns (i.e. when no exception flies out the method.). (Inherited from IOnMethodBoundaryAspect.)
Public method | OnYield | Method executed when a state machine yields, as the result of an yield return or await statement.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from IMethodLevelAspect.)
Top
See Also

Reference

IOnStateMachineBoundaryAspect Interface
PostSharp.Aspects Namespace


IOnStateMachineBoundaryAspect.OnResume Method

IOnStateMachineBoundaryAspectOnResume Method
Method executed when a state machine resumes execution after an yield return or await statement.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnResume(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed and which are its arguments.
Remarks

For iterator methods, this advice is executed before the MoveNext method. However, the very first call of MoveNext maps to OnEntry(MethodExecutionArgs).

In async methods, the advice is executed just after the state machine restarts execution after having waited as a result of the await statement.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IOnStateMachineBoundaryAspect Interface
PostSharp.Aspects Namespace


IOnStateMachineBoundaryAspect.OnYield Method

IOnStateMachineBoundaryAspectOnYield Method
Method executed when a state machine yields, as the result of an yield return or await statement.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnYield(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed and which are its arguments. In iterator methods, the YieldValue property gives access to the operand of the yield return statement.
Remarks

In iterator methods, this advise is exactly executed at the yield return statement.

In async methods, the advice is executed just after the state machine starts waiting as a result of the await statement. In case the operand of the await statement is an operation that completed synchronously, the state machine does not yield, and the OnYield(MethodExecutionArgs) advise won't be invoked.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IOnStateMachineBoundaryAspect Interface
PostSharp.Aspects Namespace


ITypeLevelAspect Interface

ITypeLevelAspect Interface
Run-time semantics of aspects applied to types.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ITypeLevelAspect : IAspect

The ITypeLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | RuntimeInitialize | Initializes the current aspect.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsITypeLevelAspectBuildSemantics


ITypeLevelAspect Methods

ITypeLevelAspect Methods

The ITypeLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | RuntimeInitialize | Initializes the current aspect.
Top
See Also

Reference

ITypeLevelAspect Interface
PostSharp.Aspects Namespace


ITypeLevelAspect.RuntimeInitialize Method

ITypeLevelAspectRuntimeInitialize Method
Initializes the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void RuntimeInitialize(
    Type type
)

Parameters

type
Type: SystemType
Type to which the current aspect is applied.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ITypeLevelAspect Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


ITypeLevelAspectBuildSemantics Interface

ITypeLevelAspectBuildSemantics Interface
Compile-time semantics of ITypeLevelAspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ITypeLevelAspectBuildSemantics : IAspectBuildSemantics,
    IValidableAnnotation

The ITypeLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect. (Inherited from IAspectBuildSemantics.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


ITypeLevelAspectBuildSemantics Methods

ITypeLevelAspectBuildSemantics Methods

The ITypeLevelAspectBuildSemantics type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from IValidableAnnotation.)
Public method | GetAspectConfiguration | Method invoked at build time to get the imperative configuration of the current Aspect. (Inherited from IAspectBuildSemantics.)
Top
See Also

Reference

ITypeLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace


ITypeLevelAspectBuildSemantics.CompileTimeInitialize Method

ITypeLevelAspectBuildSemanticsCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void CompileTimeInitialize(
    Type type,
    AspectInfo aspectInfo
)

Parameters

type
Type: SystemType
Type to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ITypeLevelAspectBuildSemantics Interface
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


LocationBindingExtensions Class

LocationBindingExtensions Class
Extension methods for the ILocationBinding interface.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsLocationBindingExtensions

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class LocationBindingExtensions
Methods
Name | Description
GetValue(ILocationBinding, Object) | Gets the value of a field or property.
GetValue(ILocationBinding, Object, Arguments) | Gets the value of an indexer (property with arguments).
SetValue(ILocationBinding, Object, Object) | Sets the value of a field or property.
SetValue(ILocationBinding, Object, Arguments, Object) | Sets the value of an indexer (property with arguments).
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects Namespace


LocationBindingExtensions Methods

LocationBindingExtensions Methods
Methods
Name | Description
GetValue(ILocationBinding, Object) | Gets the value of a field or property.
GetValue(ILocationBinding, Object, Arguments) | Gets the value of an indexer (property with arguments).
SetValue(ILocationBinding, Object, Object) | Sets the value of a field or property.
SetValue(ILocationBinding, Object, Arguments, Object) | Sets the value of an indexer (property with arguments).
Top
See Also

Reference

LocationBindingExtensions Class
PostSharp.Aspects Namespace


LocationBindingExtensions.GetValue Method

LocationBindingExtensionsGetValue Method
Overload List
Name | Description
GetValue(ILocationBinding, Object) | Gets the value of a field or property.
GetValue(ILocationBinding, Object, Arguments) | Gets the value of an indexer (property with arguments).
Top
See Also

Reference

LocationBindingExtensions Class
PostSharp.Aspects Namespace


LocationBindingExtensions.GetValue Method (ILocationBinding, Object)

LocationBindingExtensionsGetValue Method (ILocationBinding, Object)
Gets the value of a field or property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Object GetValue(
    ILocationBinding locationBinding,
    Object instance
)

Parameters

locationBinding
Type: PostSharp.AspectsILocationBinding
The binding for the field or property.
instance
Type: SystemObject
The instance for which the field or property is evaluated, or null if the location is static.

Return Value

Type: Object
The field or property value.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

LocationBindingExtensions Class
GetValue Overload
PostSharp.Aspects Namespace
ILocationBindingGetValue(Object, Arguments)


LocationBindingExtensions.GetValue Method (ILocationBinding, Object, Arguments)

LocationBindingExtensionsGetValue Method (ILocationBinding, Object, Arguments)
Gets the value of an indexer (property with arguments).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Object GetValue(
    ILocationBinding locationBinding,
    Object instance,
    Arguments index
)

Parameters

locationBinding
Type: PostSharp.AspectsILocationBinding
The binding for the indexer.
instance
Type: SystemObject
The instance for which the indexer is evaluated, or null if the indexer is static.
index
Type: PostSharp.AspectsArguments
The arguments of the indexer.

Return Value

Type: Object
The indexer value.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

LocationBindingExtensions Class
GetValue Overload
PostSharp.Aspects Namespace
ILocationBindingGetValue(Object, Arguments)


LocationBindingExtensions.SetValue Method

LocationBindingExtensionsSetValue Method
Overload List
Name | Description
SetValue(ILocationBinding, Object, Object) | Sets the value of a field or property.
SetValue(ILocationBinding, Object, Arguments, Object) | Sets the value of an indexer (property with arguments).
Top
See Also

Reference

LocationBindingExtensions Class
PostSharp.Aspects Namespace


LocationBindingExtensions.SetValue Method (ILocationBinding, Object, Object)

LocationBindingExtensionsSetValue Method (ILocationBinding, Object, Object)
Sets the value of a field or property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void SetValue(
    ILocationBinding locationBinding,
    Object instance,
    Object value
)

Parameters

locationBinding
Type: PostSharp.AspectsILocationBinding
The binding for the field or property.
instance
Type: SystemObject
The instance for which the field or property is set, or null if the location is static.
value
Type: SystemObject
The new value assigned to the field or property.

Return Value

Type:
The field or property value.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

LocationBindingExtensions Class
SetValue Overload
PostSharp.Aspects Namespace
ILocationBindingGetValue(Object, Arguments)


LocationBindingExtensions.SetValue Method (ILocationBinding, Object, Arguments, Object)

LocationBindingExtensionsSetValue Method (ILocationBinding, Object, Arguments, Object)
Sets the value of an indexer (property with arguments).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void SetValue(
    ILocationBinding locationBinding,
    Object instance,
    Arguments index,
    Object value
)

Parameters

locationBinding
Type: PostSharp.AspectsILocationBinding
The binding for the indexer.
instance
Type: SystemObject
The instance for which the indexer is set, or null if the indexer is static.
index
Type: PostSharp.AspectsArguments
The arguments of the indexer.
value
Type: SystemObject
The new value.

Return Value

Type:
The indexer value.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

LocationBindingExtensions Class
SetValue Overload
PostSharp.Aspects Namespace
ILocationBindingGetValue(Object, Arguments)


LocationInterceptionArgs Class

LocationInterceptionArgs Class
Arguments of advices of aspect type LocationInterceptionAspect.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsAdviceArgs
PostSharp.AspectsLocationInterceptionArgs

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class LocationInterceptionArgs : AdviceArgs,
    ILocationInterceptionArgs

The LocationInterceptionArgs type exposes the following members.

Methods
 | Name | Description
Public method | ExecuteTPayload | Executes a delegate for the current LocationInterceptionArgs. This method allows to
Public method | GetCurrentValue | Retrieves the current value of the location without overwriting the Value property.
Public method | ProceedGetValue | Invokes the Get Location Value semantic on the next node in the chain of invocation and stores the location value in the Value property.
Public method | ProceedSetValue | Invokes the Set Location Value semantic on the next node in the chain of invocation and stores the value of the Value property into the location.
Public method | SetNewValue | Sets the value of the location without overwriting the Value property.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Binding | Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration to which the advice has been applied. (Inherited from AdviceArgs.)
Public property | Index | Gets the current index arguments (in case of a property with parameters).
Public property | Instance | Gets or sets the object instance on which the method is being executed. (Inherited from AdviceArgs.)
Public property | Location | Gets the location (field, property or parameter) related to the aspect or advice being executed.
Public property | LocationFullName | Gets the full name (including the full name of the declaring type) of the location (field, property or parameter) related to the aspect or advice being executed.
Public property | LocationName | Gets the name of the location (field, property or parameter) related to the aspect or advice being executed.
Public property | Value | Gets or sets the location value.
Top
Remarks
Note Note
As a result of weaving optimizations, instances of classes derived from AdviceArgs may be shared among different aspects. Therefore, aspect code should not attempt to access this object once the control has been given over to the next node in the chain of invocation. Consider working with aspect bindings if you need such deferred execution.
Note Note
Aspect weaving optimizations may also cause an advice parameter of this type to be seen

Field Value

Type:
null when inspecting it in a debugger. If you need to inspect the instance in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsLocationInterceptionAspect

Other Resources

Conceptual Documentation: Aspect Bindings


LocationInterceptionArgs Methods

LocationInterceptionArgs Methods

The LocationInterceptionArgs type exposes the following members.

Methods
 | Name | Description
Public method | ExecuteTPayload | Executes a delegate for the current LocationInterceptionArgs. This method allows to
Public method | GetCurrentValue | Retrieves the current value of the location without overwriting the Value property.
Public method | ProceedGetValue | Invokes the Get Location Value semantic on the next node in the chain of invocation and stores the location value in the Value property.
Public method | ProceedSetValue | Invokes the Set Location Value semantic on the next node in the chain of invocation and stores the value of the Value property into the location.
Public method | SetNewValue | Sets the value of the location without overwriting the Value property.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs.Execute(TPayload) Method

LocationInterceptionArgsExecuteTPayload Method
Executes a delegate for the current LocationInterceptionArgs. This method allows to

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void Execute<TPayload>(
    ILocationInterceptionArgsAction<TPayload> action,
    ref TPayload payload
)

Parameters

action
Type: PostSharp.AspectsILocationInterceptionArgsAction TPayload
payload
Type: TPayload

Type Parameters

TPayload

Implements

ILocationInterceptionArgsExecuteTPayload(ILocationInterceptionArgsActionTPayload, TPayload)
Version Information

Supported in: 4.1, 4.0

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs.GetCurrentValue Method

LocationInterceptionArgsGetCurrentValue Method
Retrieves the current value of the location without overwriting the Value property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract Object GetCurrentValue()

Return Value

Type: Object
The current value of the location, as returned by the next node in the chain of invocation (see Binding).

Implements

ILocationInterceptionArgsGetCurrentValue
Remarks
Note Note
This method is designed to be invoked during the execution of the advice. If you need to retrieve or store the value of the location at a different time, it is recommended to use the Binding . Indeed, a binding is stateless, while LocationInterceptionArgs instances may be shared among different aspects.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs.ProceedGetValue Method

LocationInterceptionArgsProceedGetValue Method
Invokes the Get Location Value semantic on the next node in the chain of invocation and stores the location value in the Value property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void ProceedGetValue()

Implements

ILocationInterceptionArgsProceedGetValue
Remarks

Note that this method overwrites the content of the Value property. Therefore, you should not call this invoke from a OnSetValue(LocationInterceptionArgs) advice unless you store the value before. If you need to retrieve the current value of the location from a OnSetValue(LocationInterceptionArgs) advice, it is recommended you use the GetCurrentValue method.

Note Note
This method is designed to be invoked during the execution of the advice. If you need to retrieve or store the value of the location at a different time, it is recommended to use the Binding . Indeed, a binding is stateless, while LocationInterceptionArgs instances may be shared among different aspects.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs.ProceedSetValue Method

LocationInterceptionArgsProceedSetValue Method
Invokes the Set Location Value semantic on the next node in the chain of invocation and stores the value of the Value property into the location.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void ProceedSetValue()

Implements

ILocationInterceptionArgsProceedSetValue
Remarks

Note that this method requires the value to be stored in the Value property. If you need to retrieve the current value of the location from a OnSetValue(LocationInterceptionArgs) advice, it is recommended you use the GetCurrentValue method.

Note Note
This method is designed to be invoked during the execution of the advice. If you need to retrieve or store the value of the location at a different time, it is recommended to use the Binding . Indeed, a binding is stateless, while LocationInterceptionArgs instances may be shared among different aspects.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs.SetNewValue Method

LocationInterceptionArgsSetNewValue Method
Sets the value of the location without overwriting the Value property.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void SetNewValue(
    Object value
)

Parameters

value
Type: SystemObject
The value to be passed to the next node in the chain of invocation (see Binding).

Implements

ILocationInterceptionArgsSetNewValue(Object)
Remarks

Note Note
This method is designed to be invoked during the execution of the advice. If you need to retrieve or store the value of the location at a different time, it is recommended to use the Binding . Indeed, a binding is stateless, while LocationInterceptionArgs instances may be shared among different aspects.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs Properties

LocationInterceptionArgs Properties

The LocationInterceptionArgs type exposes the following members.

Properties
 | Name | Description
Public property | Binding | Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration to which the advice has been applied. (Inherited from AdviceArgs.)
Public property | Index | Gets the current index arguments (in case of a property with parameters).
Public property | Instance | Gets or sets the object instance on which the method is being executed. (Inherited from AdviceArgs.)
Public property | Location | Gets the location (field, property or parameter) related to the aspect or advice being executed.
Public property | LocationFullName | Gets the full name (including the full name of the declaring type) of the location (field, property or parameter) related to the aspect or advice being executed.
Public property | LocationName | Gets the name of the location (field, property or parameter) related to the aspect or advice being executed.
Public property | Value | Gets or sets the location value.
Top
See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs.Binding Property

LocationInterceptionArgsBinding Property
Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract ILocationBinding Binding { get; }

Property Value

Type: ILocationBinding

Implements

ILocationInterceptionArgsBinding
Remarks

Bindings are thread-safe and context-free singleton instances exposing the next node in the chain of invocation.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Aspect Bindings


LocationInterceptionArgs.Index Property

LocationInterceptionArgsIndex Property
Gets the current index arguments (in case of a property with parameters).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Arguments Index { get; }

Property Value

Type: Arguments

Implements

ILocationInterceptionArgsIndex
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs.Location Property

LocationInterceptionArgsLocation Property
Gets the location (field, property or parameter) related to the aspect or advice being executed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LocationInfo Location { get; set; }

Property Value

Type: LocationInfo

Implements

ILocationInterceptionArgsLocation
Remarks
Note Note
Using this property causes the aspect weaver to generate code that has non-trivial runtime overhead. Avoid using this property whenever possible. One of the possible solution is to use compile-time initialization of aspect instances and to make use of reflection only at build time.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs.LocationFullName Property

LocationInterceptionArgsLocationFullName Property
Gets the full name (including the full name of the declaring type) of the location (field, property or parameter) related to the aspect or advice being executed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string LocationFullName { get; set; }

Property Value

Type: String

Implements

ILocationInterceptionArgsLocationFullName
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs.LocationName Property

LocationInterceptionArgsLocationName Property
Gets the name of the location (field, property or parameter) related to the aspect or advice being executed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string LocationName { get; set; }

Property Value

Type: String

Implements

ILocationInterceptionArgsLocationName
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionArgs.Value Property

LocationInterceptionArgsValue Property
Gets or sets the location value.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract Object Value { get; set; }

Property Value

Type: Object

Implements

ILocationInterceptionArgsValue
Remarks

Inside an OnGetValue(LocationInterceptionArgs) advice, this property is available after the next advice in chain has been invoked using ProceedGetValue. However, inside an OnSetValue(LocationInterceptionArgs) advice, the value is available immediately, and is used as input by ProceedSetValue.

See GetCurrentValue and SetNewValue(Object) to get or set the value of the location without affecting the value of this property.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionArgs Class
PostSharp.Aspects Namespace


LocationInterceptionAspect Class

LocationInterceptionAspect Class
Aspect that, when applied on a location (field or property), intercepts invocations of the Get (OnGetValue(LocationInterceptionArgs)) and Set (OnSetValue(LocationInterceptionArgs)) semantics.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsLocationLevelAspect
PostSharp.AspectsLocationInterceptionAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class LocationInterceptionAspect : LocationLevelAspect,
    ILocationInterceptionAspect, ILocationLevelAspect, IAspect

The LocationInterceptionAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | LocationInterceptionAspect | Initializes a new instance of the LocationInterceptionAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from LocationLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from LocationLevelAspect.)
Public method | CompileTimeValidate(LocationInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from LocationLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnGetValue | Method invoked instead of the Get semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is retrieved.
Public method | OnSetValue | Method invoked instead of the Set semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is changed.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from LocationLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, LocationInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from LocationLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from LocationLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

This aspect can be applied indifferently to fields and properties, called locations because they both have the semantics of a slot where a value can be stored and retrieved.

Applying the Aspect on Properties

Applying an aspect of type LocationInterceptionAspect to a property results in the accessors of this property to be replaced by a call to the method OnGetValue(LocationInterceptionArgs) or OnSetValue(LocationInterceptionArgs) of the current class. The original body of the accessor is moved into a new method, which can be called by the aspect by invoking one of the methods ProceedGetValue, ProceedSetValue, GetCurrentValue or SetNewValue(Object), or by using the Binding object.

For details about the implementation of this aspect, see Interception Aspects.

Applying the Aspect on Fields

Applying this aspect on a field transforms the field into a property of the same name, scope and visibility as the original field. The original field is removed. Aspect code can get or set the value of the field by calling the methods ProceedGetValue, ProceedSetValue, GetCurrentValue or SetNewValue(Object), or by using the Binding object.

For details about the implementation of this aspect, see Interception Aspects.

Note Note
Remember to use PropertyInfo instead of FieldInfo at runtime to reflect the original field. For this reason, you cannot store a FieldInfo in the aspect. Store a LocationInfo instead; even if a LocationInfo represents a field at build time, it will represent the corresponding PropertyInfo at runtime.

Note Note
When you apply an aspect derived from LocationInterceptionAspect to a value-type field, you should not pass the value of this field by reference (as an argument to out and ref parameters in C#). Indeed, PostSharp is unable to detect read and write accesses through references.

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Examples

Example: Backing a Property with a Registry Value

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.Aspects.ConfigurationLocationInterceptionAspectConfigurationAttribute

Other Resources

Conceptual Documentation: Aspect Serialization
Conceptual Documentation: Interception Aspects


LocationInterceptionAspect Constructor

LocationInterceptionAspect Constructor
Initializes a new instance of the LocationInterceptionAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected LocationInterceptionAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionAspect Class
PostSharp.Aspects Namespace


LocationInterceptionAspect Methods

LocationInterceptionAspect Methods

The LocationInterceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from LocationLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from LocationLevelAspect.)
Public method | CompileTimeValidate(LocationInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from LocationLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnGetValue | Method invoked instead of the Get semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is retrieved.
Public method | OnSetValue | Method invoked instead of the Set semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is changed.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from LocationLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, LocationInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from LocationLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from LocationLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LocationInterceptionAspect Class
PostSharp.Aspects Namespace


LocationInterceptionAspect.CreateAspectConfiguration Method

LocationInterceptionAspectCreateAspectConfiguration Method
Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the Aspect.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration, Object) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


LocationInterceptionAspect.OnGetValue Method

LocationInterceptionAspectOnGetValue Method
Method invoked instead of the Get semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is retrieved.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnGetValue(
    LocationInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsLocationInterceptionArgs
Advice arguments.

Implements

ILocationInterceptionAspectOnGetValue(LocationInterceptionArgs)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionAspect Class
PostSharp.Aspects Namespace
PostSharp.AspectsLocationInterceptionArgs


LocationInterceptionAspect.OnSetValue Method

LocationInterceptionAspectOnSetValue Method
Method invoked instead of the Set semantic of the field or property to which the current aspect is applied, i.e. when the value of this field or property is changed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnSetValue(
    LocationInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsLocationInterceptionArgs
Advice arguments.

Implements

ILocationInterceptionAspectOnSetValue(LocationInterceptionArgs)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionAspect Class
PostSharp.Aspects Namespace
PostSharp.AspectsLocationInterceptionArgs


LocationInterceptionAspect Properties

LocationInterceptionAspect Properties

The LocationInterceptionAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

LocationInterceptionAspect Class
PostSharp.Aspects Namespace


LocationLevelAspect Class

LocationLevelAspect Class
Base class for aspects defined in fields, properties, or parameters.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsLocationLevelAspect
PostSharp.AspectsLocationInterceptionAspect
PostSharp.Patterns.ThreadingRequiresThreadSafeAttribute

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class LocationLevelAspect : Aspect,
    ILocationLevelAspect, IAspect, ILocationLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation

The LocationLevelAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | LocationLevelAspect | Initializes a new instance of the LocationLevelAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(LocationInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, LocationInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks
Note Note
This class does not provide any advice. You may derive your aspect class from a class providing predefined advice , or build a composite aspect .

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsILocationLevelAspect

Other Resources

Conceptual Documentation: Aspect Classes
Conceptual Documentation: Developing Complex Aspects
Conceptual Documentation: Aspect Serialization


LocationLevelAspect Constructor

LocationLevelAspect Constructor
Initializes a new instance of the LocationLevelAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected LocationLevelAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationLevelAspect Class
PostSharp.Aspects Namespace


LocationLevelAspect Methods

LocationLevelAspect Methods

The LocationLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(LocationInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, LocationInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LocationLevelAspect Class
PostSharp.Aspects Namespace


LocationLevelAspect.CompileTimeInitialize Method

LocationLevelAspectCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void CompileTimeInitialize(
    LocationInfo targetLocation,
    AspectInfo aspectInfo
)

Parameters

targetLocation
Type: PostSharp.ReflectionLocationInfo
Location to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.

Implements

ILocationLevelAspectBuildSemanticsCompileTimeInitialize(LocationInfo, AspectInfo)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


LocationLevelAspect.CompileTimeValidate Method

LocationLevelAspectCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(LocationInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
See Also

Reference

LocationLevelAspect Class
PostSharp.Aspects Namespace


LocationLevelAspect.CompileTimeValidate Method (Object)

LocationLevelAspectCompileTimeValidate Method (Object)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override sealed bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the aspect has been applied.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.

Implements

IValidableAnnotationCompileTimeValidate(Object)
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


LocationLevelAspect.CompileTimeValidate Method (LocationInfo)

LocationLevelAspectCompileTimeValidate Method (LocationInfo)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual bool CompileTimeValidate(
    LocationInfo locationInfo
)

Parameters

locationInfo
Type: PostSharp.ReflectionLocationInfo
Location to which the aspect has been applied

Return Value

Type: Boolean
true if the aspect was applied to an acceptable field, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


LocationLevelAspect.RuntimeInitialize Method

LocationLevelAspectRuntimeInitialize Method
Initializes the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void RuntimeInitialize(
    LocationInfo locationInfo
)

Parameters

locationInfo
Type: PostSharp.ReflectionLocationInfo
Location to which the current aspect is applied.

Implements

ILocationLevelAspectRuntimeInitialize(LocationInfo)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


LocationLevelAspect.SetAspectConfiguration Method

LocationLevelAspectSetAspectConfiguration Method
Overload List
 | Name | Description
Protected method | SetAspectConfiguration(AspectConfiguration, LocationInfo) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Top
See Also

Reference

LocationLevelAspect Class
PostSharp.Aspects Namespace


LocationLevelAspect.SetAspectConfiguration Method (AspectConfiguration, LocationInfo)

LocationLevelAspectSetAspectConfiguration Method (AspectConfiguration, LocationInfo)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    LocationInfo targetLocation
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetLocation
Type: PostSharp.ReflectionLocationInfo
Location to which the current aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


LocationLevelAspect.SetAspectConfiguration Method (AspectConfiguration, Object)

LocationLevelAspectSetAspectConfiguration Method (AspectConfiguration, Object)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    Object targetElement
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current Aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


LocationLevelAspect Properties

LocationLevelAspect Properties

The LocationLevelAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

LocationLevelAspect Class
PostSharp.Aspects Namespace


ManagedResourceIntroductionAspect Class

ManagedResourceIntroductionAspect Class
Aspect that, when applied to an assembly, adds a custom attribute to this assembly.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsManagedResourceIntroductionAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ManagedResourceIntroductionAspect : IManagedResourceIntroductionAspect,
    IAspect, IAspectBuildSemantics, IValidableAnnotation

The ManagedResourceIntroductionAspect type exposes the following members.

Constructors
 | Name | Description
Public method | ManagedResourceIntroductionAspect | Initializes a new ManagedResourceIntroductionAspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Data | Gets the content of the managed resource.
Public property | Name | Gets the name of the managed resource.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Adding Aspects Dynamically


ManagedResourceIntroductionAspect Constructor

ManagedResourceIntroductionAspect Constructor
Initializes a new ManagedResourceIntroductionAspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ManagedResourceIntroductionAspect(
    string name,
    byte[] data
)

Parameters

name
Type: SystemString
Name of the managed resource.
data
Type: SystemByte
Content of the managed resource.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ManagedResourceIntroductionAspect Class
PostSharp.Aspects Namespace


ManagedResourceIntroductionAspect Methods

ManagedResourceIntroductionAspect Methods

The ManagedResourceIntroductionAspect type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ManagedResourceIntroductionAspect Class
PostSharp.Aspects Namespace


ManagedResourceIntroductionAspect Properties

ManagedResourceIntroductionAspect Properties

The ManagedResourceIntroductionAspect type exposes the following members.

Properties
 | Name | Description
Public property | Data | Gets the content of the managed resource.
Public property | Name | Gets the name of the managed resource.
Top
See Also

Reference

ManagedResourceIntroductionAspect Class
PostSharp.Aspects Namespace


ManagedResourceIntroductionAspect.Data Property

ManagedResourceIntroductionAspectData Property
Gets the content of the managed resource.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public byte[] Data { get; }

Property Value

Type: Byte
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ManagedResourceIntroductionAspect Class
PostSharp.Aspects Namespace


ManagedResourceIntroductionAspect.Name Property

ManagedResourceIntroductionAspectName Property
Gets the name of the managed resource.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Name { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ManagedResourceIntroductionAspect Class
PostSharp.Aspects Namespace


MethodExecutionArgs Class

MethodExecutionArgs Class
Arguments of advices of aspects of type OnMethodBoundaryAspect and OnExceptionAspect
Inheritance Hierarchy
SystemObject
PostSharp.AspectsAdviceArgs
PostSharp.AspectsMethodExecutionArgs

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class MethodExecutionArgs : AdviceArgs

The MethodExecutionArgs type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Arguments | Gets the arguments with which the method has been invoked.
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration to which the advice has been applied. (Inherited from AdviceArgs.)
Public property | Exception | Gets the exception currently flying.
Public property | FlowBehavior | Determines the control flow of the target method once the advice is exited.
Public property | Instance | Gets or sets the object instance on which the method is being executed. (Inherited from AdviceArgs.)
Public property | Method | Gets the method being executed.
Public property | MethodExecutionTag | User-defined state information whose lifetime is linked to the current method execution. Aspects derived from IOnMethodBoundaryAspect should use this property to save state information between different events (OnEntry(MethodExecutionArgs), OnExit(MethodExecutionArgs) and OnException(MethodExecutionArgs)).
Public property | ReturnValue | Gets or sets the method return value.
Public property | YieldValue | Gets or sets the value yielded by the iterator method.
Top
Remarks
Note Note
As a result of weaving optimizations, instances of classes derived from AdviceArgs may be shared among different aspects. Therefore, aspect code should not attempt to access this object once the control has been given over to the next node in the chain of invocation. Consider working with aspect bindings if you need such deferred execution.
Note Note
Aspect weaving optimizations may also cause an advice parameter of this type to be seen

Field Value

Type:
null when inspecting it in a debugger. If you need to inspect the instance in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Aspect Bindings


MethodExecutionArgs Methods

MethodExecutionArgs Methods

The MethodExecutionArgs type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MethodExecutionArgs Class
PostSharp.Aspects Namespace


MethodExecutionArgs Properties

MethodExecutionArgs Properties

The MethodExecutionArgs type exposes the following members.

Properties
 | Name | Description
Public property | Arguments | Gets the arguments with which the method has been invoked.
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration to which the advice has been applied. (Inherited from AdviceArgs.)
Public property | Exception | Gets the exception currently flying.
Public property | FlowBehavior | Determines the control flow of the target method once the advice is exited.
Public property | Instance | Gets or sets the object instance on which the method is being executed. (Inherited from AdviceArgs.)
Public property | Method | Gets the method being executed.
Public property | MethodExecutionTag | User-defined state information whose lifetime is linked to the current method execution. Aspects derived from IOnMethodBoundaryAspect should use this property to save state information between different events (OnEntry(MethodExecutionArgs), OnExit(MethodExecutionArgs) and OnException(MethodExecutionArgs)).
Public property | ReturnValue | Gets or sets the method return value.
Public property | YieldValue | Gets or sets the value yielded by the iterator method.
Top
See Also

Reference

MethodExecutionArgs Class
PostSharp.Aspects Namespace


MethodExecutionArgs.Arguments Property

MethodExecutionArgsArguments Property
Gets the arguments with which the method has been invoked.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Arguments Arguments { get; set; }

Property Value

Type: Arguments
Remarks
Note Note
The property setter should never be used in user code.
Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: Arguments
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodExecutionArgs Class
PostSharp.Aspects Namespace


MethodExecutionArgs.Exception Property

MethodExecutionArgsException Property
Gets the exception currently flying.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Exception Exception { get; set; }

Property Value

Type: Exception
An Exception, or null if the method is exiting normally.
Remarks

You cannot replace the exception by setting this property. Throw a new exception from the aspect if you need to replace the current exception.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodExecutionArgs Class
PostSharp.Aspects Namespace


MethodExecutionArgs.FlowBehavior Property

MethodExecutionArgsFlowBehavior Property
Determines the control flow of the target method once the advice is exited.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public FlowBehavior FlowBehavior { get; set; }

Property Value

Type: FlowBehavior
Remarks
Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: FlowBehavior
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodExecutionArgs Class
PostSharp.Aspects Namespace


MethodExecutionArgs.Method Property

MethodExecutionArgsMethod Property
Gets the method being executed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MethodBase Method { get; set; }

Property Value

Type: MethodBase
Remarks

If the executed method is generic or if its declaring type is generic, the current property contains the generic instance being executed.

Note Note
Using this property causes the aspect weaver to generate code that has non-trivial runtime overhead. Avoid using this property whenever possible. One of the possible solution is to use compile-time initialization of aspect instances and to make use of reflection only at build time. See CompileTimeInitialize(MethodBase, AspectInfo) for details.
Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: MethodBase
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodExecutionArgs Class
PostSharp.Aspects Namespace
MethodLevelAspectCompileTimeInitialize(MethodBase, AspectInfo)


MethodExecutionArgs.MethodExecutionTag Property

MethodExecutionArgsMethodExecutionTag Property
User-defined state information whose lifetime is linked to the current method execution. Aspects derived from IOnMethodBoundaryAspect should use this property to save state information between different events (OnEntry(MethodExecutionArgs), OnExit(MethodExecutionArgs) and OnException(MethodExecutionArgs)).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object MethodExecutionTag { get; set; }

Property Value

Type: Object
Remarks
Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: Object
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodExecutionArgs Class
PostSharp.Aspects Namespace


MethodExecutionArgs.ReturnValue Property

MethodExecutionArgsReturnValue Property
Gets or sets the method return value.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object ReturnValue { get; set; }

Property Value

Type: Object
Remarks

You can modify the return value only when the join point is located after a method execution (OnSuccess(MethodExecutionArgs), OnException(MethodExecutionArgs) or OnExit(MethodExecutionArgs), or in case you force the method to exit using the FlowBehavior property.

Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: Object
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodExecutionArgs Class
PostSharp.Aspects Namespace


MethodExecutionArgs.YieldValue Property

MethodExecutionArgsYieldValue Property
Gets or sets the value yielded by the iterator method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object YieldValue { get; set; }

Property Value

Type: Object
Remarks

This property is only available inside the OnYield(MethodExecutionArgs) advice when the current method is an iterator method.

Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: Object
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodExecutionArgs Class
PostSharp.Aspects Namespace
PostSharp.AspectsIOnStateMachineBoundaryAspect


MethodImplementationAspect Class

MethodImplementationAspect Class
Aspect that, when applied on an abstract or extern method, creates an implementation for this method.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.AspectsMethodImplementationAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class MethodImplementationAspect : MethodLevelAspect,
    IMethodInterceptionAspect, IMethodLevelAspect, IAspect

The MethodImplementationAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | MethodImplementationAspect | Initializes a new instance of the MethodImplementationAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnInvoke | Method invoked instead of the method to which the aspect has been applied.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

This aspect is exactly identical to MethodInterceptionAspect, with the difference that it applies to abstract methods.

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.Aspects.ConfigurationMethodInterceptionAspectConfigurationAttribute

Other Resources

Conceptual Documentation: Aspect Serialization


MethodImplementationAspect Constructor

MethodImplementationAspect Constructor
Initializes a new instance of the MethodImplementationAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected MethodImplementationAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodImplementationAspect Class
PostSharp.Aspects Namespace


MethodImplementationAspect Methods

MethodImplementationAspect Methods

The MethodImplementationAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnInvoke | Method invoked instead of the method to which the aspect has been applied.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MethodImplementationAspect Class
PostSharp.Aspects Namespace


MethodImplementationAspect.CreateAspectConfiguration Method

MethodImplementationAspectCreateAspectConfiguration Method
Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the Aspect.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration, Object) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodImplementationAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


MethodImplementationAspect.OnInvoke Method

MethodImplementationAspectOnInvoke Method
Method invoked instead of the method to which the aspect has been applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void OnInvoke(
    MethodInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodInterceptionArgs
Advice arguments.

Implements

IMethodInterceptionAspectOnInvoke(MethodInterceptionArgs)
Remarks

The implementation of OnInvoke(MethodInterceptionArgs) may invoke Proceed, may schedule it for invocation from another thread, or may completely skip its invocation. Alternatively, it may use Binding. Before returning to the caller, the OnInvoke(MethodInterceptionArgs) method must set the return value (property ReturnValue) and all output arguments (property Arguments), otherwise the target method may fail with a NullReferenceException. These are normally set by calling Proceed.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodImplementationAspect Class
PostSharp.Aspects Namespace
PostSharp.AspectsMethodInterceptionArgs


MethodImplementationAspect Properties

MethodImplementationAspect Properties

The MethodImplementationAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

MethodImplementationAspect Class
PostSharp.Aspects Namespace


MethodInterceptionArgs Class

MethodInterceptionArgs Class
Arguments of advices of aspect type MethodInterceptionAspect.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsAdviceArgs
PostSharp.AspectsMethodInterceptionArgs

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class MethodInterceptionArgs : AdviceArgs

The MethodInterceptionArgs type exposes the following members.

Methods
 | Name | Description
Public method | Invoke | Invokes the method that has been intercepted by calling the next node in the chain of invocation with given arguments, without affecting the property ReturnValue.
Public method | Proceed | Proceeds with invocation of the method that has been intercepted by calling the next node in the chain of invocation, passing the current Arguments to that method and storing its return value into the property ReturnValue.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Arguments | Gets the list of arguments with which the method has been invoked.
Public property | Binding | Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration to which the advice has been applied. (Inherited from AdviceArgs.)
Public property | Instance | Gets or sets the object instance on which the method is being executed. (Inherited from AdviceArgs.)
Public property | Method | Gets the method being executed.
Public property | ReturnValue | Gets or sets the return value of the method.
Top
Remarks
Note Note
As a result of weaving optimizations, instances of classes derived from AdviceArgs may be shared among different aspects. Therefore, aspect code should not attempt to access this object once the control has been given over to the next node in the chain of invocation. Consider working with aspect bindings if you need such deferred execution.
Note Note
Aspect weaving optimizations may also cause an advice parameter of this type to be seen

Field Value

Type:
null when inspecting it in a debugger. If you need to inspect the instance in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsMethodInterceptionAspect

Other Resources

Conceptual Documentation: Aspect Bindings


MethodInterceptionArgs Methods

MethodInterceptionArgs Methods

The MethodInterceptionArgs type exposes the following members.

Methods
 | Name | Description
Public method | Invoke | Invokes the method that has been intercepted by calling the next node in the chain of invocation with given arguments, without affecting the property ReturnValue.
Public method | Proceed | Proceeds with invocation of the method that has been intercepted by calling the next node in the chain of invocation, passing the current Arguments to that method and storing its return value into the property ReturnValue.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MethodInterceptionArgs Class
PostSharp.Aspects Namespace


MethodInterceptionArgs.Invoke Method

MethodInterceptionArgsInvoke Method
Invokes the method that has been intercepted by calling the next node in the chain of invocation with given arguments, without affecting the property ReturnValue.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract Object Invoke(
    Arguments arguments
)

Parameters

arguments
Type: PostSharp.AspectsArguments
Arguments passed to the intercepted method.

Return Value

Type: Object
Value returned by the intercepted method.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionArgs Class
PostSharp.Aspects Namespace


MethodInterceptionArgs.Proceed Method

MethodInterceptionArgsProceed Method
Proceeds with invocation of the method that has been intercepted by calling the next node in the chain of invocation, passing the current Arguments to that method and storing its return value into the property ReturnValue.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void Proceed()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionArgs Class
PostSharp.Aspects Namespace


MethodInterceptionArgs Properties

MethodInterceptionArgs Properties

The MethodInterceptionArgs type exposes the following members.

Properties
 | Name | Description
Public property | Arguments | Gets the list of arguments with which the method has been invoked.
Public property | Binding | Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the declaration to which the advice has been applied. (Inherited from AdviceArgs.)
Public property | Instance | Gets or sets the object instance on which the method is being executed. (Inherited from AdviceArgs.)
Public property | Method | Gets the method being executed.
Public property | ReturnValue | Gets or sets the return value of the method.
Top
See Also

Reference

MethodInterceptionArgs Class
PostSharp.Aspects Namespace


MethodInterceptionArgs.Arguments Property

MethodInterceptionArgsArguments Property
Gets the list of arguments with which the method has been invoked.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Arguments Arguments { get; protected set; }

Property Value

Type: Arguments
Remarks
Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: Arguments
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionArgs Class
PostSharp.Aspects Namespace


MethodInterceptionArgs.Binding Property

MethodInterceptionArgsBinding Property
Gets an interface that allows to invoke the next node in the chain of invocation of the intercepted method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract IMethodBinding Binding { get; }

Property Value

Type: IMethodBinding
Remarks

Bindings are thread-safe and context-free singleton instances exposing the next node in the chain of invocation.

Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: IMethodBinding
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionArgs Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Aspect Bindings


MethodInterceptionArgs.Method Property

MethodInterceptionArgsMethod Property
Gets the method being executed.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MethodBase Method { get; set; }

Property Value

Type: MethodBase
Remarks

If the executed method is generic or if its declaring type is generic, the current property contains the generic instance being executed.

Note Note
Using this property causes the aspect weaver to generate code that has non-trivial runtime overhead. Avoid using this property whenever possible. One of the possible solution is to use compile-time initialization of aspect instances and to make use of reflection only at build time. See CompileTimeInitialize(MethodBase, AspectInfo) for details.
Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: MethodBase
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionArgs Class
PostSharp.Aspects Namespace
MethodLevelAspectCompileTimeInitialize(MethodBase, AspectInfo)


MethodInterceptionArgs.ReturnValue Property

MethodInterceptionArgsReturnValue Property
Gets or sets the return value of the method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract Object ReturnValue { get; set; }

Property Value

Type: Object
Remarks
Note Note
As a result of weaving optimizations, value of this property may be seen

Property Value

Type: Object
null in a debugger. If you need to inspect the value in runtime, consider disabling aspect optimizations in the debug build configuration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionArgs Class
PostSharp.Aspects Namespace


MethodInterceptionAspect Class

MethodInterceptionAspect Class
Aspect that, when applied on a method, intercepts invocations of this method.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.AspectsMethodInterceptionAspect
PostSharp.Patterns.ThreadingBackgroundAttribute

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class MethodInterceptionAspect : MethodLevelAspect,
    IMethodInterceptionAspect, IMethodLevelAspect, IAspect

The MethodInterceptionAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | MethodInterceptionAspect | Initializes a new instance of the MethodInterceptionAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnInvoke | Method invoked instead of the method to which the aspect has been applied.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

Applying a MethodInterceptionAspect to a method results in the body of this method to be replaced by a call to the aspect OnInvoke(MethodInterceptionArgs) method of the current class. The original method body is moved into a new method, which can be called by the aspect by invoking the Proceed method, or by using the object Binding.

For details about the implementation of this aspect, see Interception Aspects.

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Examples

Example: Dispatching a Method Execution to the GUI Thread

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.Aspects.ConfigurationMethodInterceptionAspectConfigurationAttribute

Other Resources

Conceptual Documentation: Aspect Serialization
Conceptual Documentation: Interception Aspects


MethodInterceptionAspect Constructor

MethodInterceptionAspect Constructor
Initializes a new instance of the MethodInterceptionAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected MethodInterceptionAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionAspect Class
PostSharp.Aspects Namespace


MethodInterceptionAspect Methods

MethodInterceptionAspect Methods

The MethodInterceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnInvoke | Method invoked instead of the method to which the aspect has been applied.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MethodInterceptionAspect Class
PostSharp.Aspects Namespace


MethodInterceptionAspect.CreateAspectConfiguration Method

MethodInterceptionAspectCreateAspectConfiguration Method
Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the Aspect.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration, Object) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


MethodInterceptionAspect.OnInvoke Method

MethodInterceptionAspectOnInvoke Method
Method invoked instead of the method to which the aspect has been applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnInvoke(
    MethodInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodInterceptionArgs
Advice arguments.

Implements

IMethodInterceptionAspectOnInvoke(MethodInterceptionArgs)
Remarks

The implementation of OnInvoke(MethodInterceptionArgs) may invoke Proceed, may schedule it for invocation from another thread, or may completely skip its invocation. Alternatively, it may use Binding. Before returning to the caller, the OnInvoke(MethodInterceptionArgs) method must set the return value (property ReturnValue) and all output arguments (property Arguments), otherwise the target method may fail with a NullReferenceException. These are normally set by calling Proceed.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionAspect Class
PostSharp.Aspects Namespace
PostSharp.AspectsMethodInterceptionArgs


MethodInterceptionAspect Properties

MethodInterceptionAspect Properties

The MethodInterceptionAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

MethodInterceptionAspect Class
PostSharp.Aspects Namespace


MethodLevelAspect Class

MethodLevelAspect Class
Base class for all aspects applied on methods.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
More...

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class MethodLevelAspect : Aspect,
    IMethodLevelAspect, IAspect, IMethodLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation

The MethodLevelAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | MethodLevelAspect | Initializes a new instance of the MethodLevelAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks
Note Note
This class does not provide any advice. You may derive your aspect class from a class providing predefined advice , or build a composite aspect .

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsIMethodLevelAspect

Other Resources

Conceptual Documentation: Aspect Classes
Conceptual Documentation: Developing Complex Aspects
Conceptual Documentation: Aspect Serialization
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.AspectsMethodImplementationAspect
PostSharp.AspectsMethodInterceptionAspect
PostSharp.AspectsOnExceptionAspect
PostSharp.AspectsOnMethodBoundaryAspect
PostSharp.Patterns.DiagnosticsLogAttributeBase
PostSharp.Patterns.ThreadingDispatchedAttribute


MethodLevelAspect Constructor

MethodLevelAspect Constructor
Initializes a new instance of the MethodLevelAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected MethodLevelAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodLevelAspect Class
PostSharp.Aspects Namespace


MethodLevelAspect Methods

MethodLevelAspect Methods

The MethodLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MethodLevelAspect Class
PostSharp.Aspects Namespace


MethodLevelAspect.CompileTimeInitialize Method

MethodLevelAspectCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void CompileTimeInitialize(
    MethodBase method,
    AspectInfo aspectInfo
)

Parameters

method
Type: System.ReflectionMethodBase
Method to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.

Implements

IMethodLevelAspectBuildSemanticsCompileTimeInitialize(MethodBase, AspectInfo)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


MethodLevelAspect.CompileTimeValidate Method

MethodLevelAspectCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
See Also

Reference

MethodLevelAspect Class
PostSharp.Aspects Namespace


MethodLevelAspect.CompileTimeValidate Method (Object)

MethodLevelAspectCompileTimeValidate Method (Object)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override sealed bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the aspect has been applied.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.

Implements

IValidableAnnotationCompileTimeValidate(Object)
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


MethodLevelAspect.CompileTimeValidate Method (MethodBase)

MethodLevelAspectCompileTimeValidate Method (MethodBase)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual bool CompileTimeValidate(
    MethodBase method
)

Parameters

method
Type: System.ReflectionMethodBase
Method to which the aspect has been applied

Return Value

Type: Boolean
true if the aspect was applied to an acceptable field, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


MethodLevelAspect.RuntimeInitialize Method

MethodLevelAspectRuntimeInitialize Method
Initializes the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void RuntimeInitialize(
    MethodBase method
)

Parameters

method
Type: System.ReflectionMethodBase
Method to which the current aspect is applied.

Implements

IMethodLevelAspectRuntimeInitialize(MethodBase)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


MethodLevelAspect.SetAspectConfiguration Method

MethodLevelAspectSetAspectConfiguration Method
Overload List
 | Name | Description
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
See Also

Reference

MethodLevelAspect Class
PostSharp.Aspects Namespace


MethodLevelAspect.SetAspectConfiguration Method (AspectConfiguration, Object)

MethodLevelAspectSetAspectConfiguration Method (AspectConfiguration, Object)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    Object targetElement
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current Aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


MethodLevelAspect.SetAspectConfiguration Method (AspectConfiguration, MethodBase)

MethodLevelAspectSetAspectConfiguration Method (AspectConfiguration, MethodBase)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    MethodBase targetMethod
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetMethod
Type: System.ReflectionMethodBase
Method to which the current aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


MethodLevelAspect Properties

MethodLevelAspect Properties

The MethodLevelAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

MethodLevelAspect Class
PostSharp.Aspects Namespace


OnExceptionAspect Class

OnExceptionAspect Class
Aspect that, when applied to a method, defines an exception handler around the whole method and calls a custom method in this exception handler.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.AspectsOnExceptionAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class OnExceptionAspect : MethodLevelAspect,
    IOnExceptionAspect, IMethodLevelAspect, IAspect

The OnExceptionAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | OnExceptionAspect | Initializes a new instance of the OnExceptionAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | GetExceptionType | Gets the type of exception handled by this aspect.
Public method | OnException | Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception (i.e., in a catch block).
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides MethodLevelAspectSetAspectConfiguration(AspectConfiguration, MethodBase).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

The OnExceptionAspect aspect adds an exception handler to the method to which it is applied. It allows you to easily encapsulate exception handling policies as a custom attribute.

The most important method is OnException(MethodExecutionArgs). It is the exception handler in itself.

The current exception is available from the Exception property of the MethodExecutionArgs> object. This property is read-only. If you need to replace the current exception by another one, you should throw a new exception from the handler. If you need to ignore the exception, set the FlowBehavior property to Continue.

An object of type MethodExecutionArgs is passed to every advice of this aspect. This object allows you to:

  • Get or set arguments . Input and output arguments are available on the property Arguments . You can change output ( out ) and by-reference ( ref ) arguments, but not input arguments. If you need to modify arguments passed by value, consider using a MethodInterceptionAspect . (see property );
  • Get the current exception . The current exception is available on property Exception , but from the OnException(MethodExecutionArgs) advice. You cannot replace the exception by setting this property. Throw a new exception from the aspect if you need to replace the current exception.
  • Get or set the return value . The return value is available on the ReturnValue property.
  • Change the method control flow . You can change the value of the FlowBehavior property to specify whether the target method should execute after the execution of the current advice. This may be useful to implement a caching aspect or an exception handler.
  • Share state between advices . You can use the MethodExecutionTag property to store state between the execution of different advices related to the same execution of a method. For instance, you can store a cache key in OnEntry(MethodExecutionArgs) and find it back on OnSuccess(MethodExecutionArgs) . Using MethodExecutionTag is the only way to share state that is both thread-safe and reentrant. All other implementations are buggy.

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Examples

Example: Handling Exceptions

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.Aspects.ConfigurationOnExceptionAspectConfigurationAttribute

Other Resources

Conceptual Documentation: Aspect Serialization


OnExceptionAspect Constructor

OnExceptionAspect Constructor
Initializes a new instance of the OnExceptionAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected OnExceptionAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnExceptionAspect Class
PostSharp.Aspects Namespace


OnExceptionAspect Methods

OnExceptionAspect Methods

The OnExceptionAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | GetExceptionType | Gets the type of exception handled by this aspect.
Public method | OnException | Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception (i.e., in a catch block).
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides MethodLevelAspectSetAspectConfiguration(AspectConfiguration, MethodBase).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnExceptionAspect Class
PostSharp.Aspects Namespace


OnExceptionAspect.CreateAspectConfiguration Method

OnExceptionAspectCreateAspectConfiguration Method
Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the Aspect.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration, Object) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnExceptionAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


OnExceptionAspect.GetExceptionType Method

OnExceptionAspectGetExceptionType Method
Gets the type of exception handled by this aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Type GetExceptionType(
    MethodBase targetMethod
)

Parameters

targetMethod
Type: System.ReflectionMethodBase
Method to which the current aspect is applied.

Return Value

Type: Type
The type (derived from Exception) of exceptions handled by this aspect.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnExceptionAspect Class
PostSharp.Aspects Namespace


OnExceptionAspect.OnException Method

OnExceptionAspectOnException Method
Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception (i.e., in a catch block).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnException(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Advice arguments.

Implements

IOnExceptionAspectOnException(MethodExecutionArgs)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnExceptionAspect Class
PostSharp.Aspects Namespace


OnExceptionAspect.SetAspectConfiguration Method

OnExceptionAspectSetAspectConfiguration Method
Overload List
 | Name | Description
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides MethodLevelAspectSetAspectConfiguration(AspectConfiguration, MethodBase).)
Top
See Also

Reference

OnExceptionAspect Class
PostSharp.Aspects Namespace


OnExceptionAspect.SetAspectConfiguration Method (AspectConfiguration, MethodBase)

OnExceptionAspectSetAspectConfiguration Method (AspectConfiguration, MethodBase)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    MethodBase targetMethod
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetMethod
Type: System.ReflectionMethodBase
Method to which the current aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnExceptionAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


OnExceptionAspect Properties

OnExceptionAspect Properties

The OnExceptionAspect type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

OnExceptionAspect Class
PostSharp.Aspects Namespace


OnExceptionAspect.ApplyToStateMachine Property

OnExceptionAspectApplyToStateMachine Property
Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool ApplyToStateMachine { get; set; }

Property Value

Type: Boolean
true if the aspect should be applied to the state machine, or false if it should be applied to the method instantiating the state machine.
Remarks

Assigning this property to true results in an aspect that is consistent with the level of abstraction of the programming language. The false value is consistent with the level of abstraction of MSIL and is backward-compatible with versions of PostSharp prior to 3.1.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

OnExceptionAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect Class

OnMethodBoundaryAspect Class
Aspect that, when applied to a method defined in the current assembly, inserts a piece of code before and after the body of these methods.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.AspectsOnMethodBoundaryAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class OnMethodBoundaryAspect : MethodLevelAspect,
    IOnStateMachineBoundaryAspect, IOnMethodBoundaryAspect, IMethodLevelAspect, IAspect

The OnMethodBoundaryAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | OnMethodBoundaryAspect | Initializes a new instance of the OnMethodBoundaryAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnEntry | Method executed before the body of methods to which this aspect is applied.
Public method | OnException | Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception.
Public method | OnExit | Method executed after the body of methods to which this aspect is applied, even when the method exists with an exception (this method is invoked from the finally block).
Public method | OnResume | Method executed when a state machine resumes execution after an yield return or await statement.
Public method | OnSuccess | Method executed after the body of methods to which this aspect is applied, but only when the method successfully returns (i.e. when no exception flies out the method.).
Public method | OnYield | Method executed when a state machine yields, as the result of an yield return or await statement.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides MethodLevelAspectSetAspectConfiguration(AspectConfiguration, MethodBase).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

The OnMethodBoundaryAspect aspect results in the target method to be wrapped into a try ... catch ... finally block. You can implement four advices: OnEntry(MethodExecutionArgs), executed at the beginning of the block; OnSuccess(MethodExecutionArgs), executed only when the method is successful (i.e. does not result in an exception); OnException(MethodExecutionArgs), invoked when the method results in an exception; and OnExit(MethodExecutionArgs), always executed after method execution (whether the method resulted in an exception or not).

Schematically, the aspect transforms the original method as follows:

C#
Copy
int MyMethod(object arg0, int arg1)
{
   OnEntry();
   try
   {
    // Original method body.
    OnSuccess();
    return returnValue;
  }
  catch ( Exception e )
  {
    OnException();
  }
  finally
  {
    OnExit();
  }
}

Note that this code is only schematic; actually generated instructions are more complex because they have to cope with parameter boxing and control flow modification, among others.

An object of type MethodExecutionArgs is passed to every advice of this aspect. This object allows you to:

  • Get or set arguments . Input and output arguments are available on the property Arguments . You can change output ( out ) and by-reference ( ref ) arguments, but not input arguments. If you need to modify arguments passed by value, consider using a MethodInterceptionAspect . (see property );
  • Get the current exception . The current exception is available on property Exception , but from the OnException(MethodExecutionArgs) advice. You cannot replace the exception by setting this property. Throw a new exception from the aspect if you need to replace the current exception.
  • Get or set the return value . The return value is available on the ReturnValue property.
  • Change the method control flow . You can change the value of the FlowBehavior property to specify whether the target method should execute after the execution of the current advice. This may be useful to implement a caching aspect or an exception handler.
  • Share state between advices . You can use the MethodExecutionTag property to store state between the execution of different advices related to the same execution of a method. For instance, you can store a cache key in OnEntry(MethodExecutionArgs) and find it back on OnSuccess(MethodExecutionArgs) . Using MethodExecutionTag is the only way to share state that is both thread-safe and reentrant. All other implementations are buggy.

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Examples

Example: Tracing Method Execution

Example: Caching the Result of a Method

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Aspect Serialization


OnMethodBoundaryAspect Constructor

OnMethodBoundaryAspect Constructor
Initializes a new instance of the OnMethodBoundaryAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected OnMethodBoundaryAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect Methods

OnMethodBoundaryAspect Methods

The OnMethodBoundaryAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnEntry | Method executed before the body of methods to which this aspect is applied.
Public method | OnException | Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception.
Public method | OnExit | Method executed after the body of methods to which this aspect is applied, even when the method exists with an exception (this method is invoked from the finally block).
Public method | OnResume | Method executed when a state machine resumes execution after an yield return or await statement.
Public method | OnSuccess | Method executed after the body of methods to which this aspect is applied, but only when the method successfully returns (i.e. when no exception flies out the method.).
Public method | OnYield | Method executed when a state machine yields, as the result of an yield return or await statement.
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides MethodLevelAspectSetAspectConfiguration(AspectConfiguration, MethodBase).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect.CreateAspectConfiguration Method

OnMethodBoundaryAspectCreateAspectConfiguration Method
Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the Aspect.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration, Object) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


OnMethodBoundaryAspect.OnEntry Method

OnMethodBoundaryAspectOnEntry Method
Method executed before the body of methods to which this aspect is applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnEntry(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed, which are its arguments, and how should the execution continue after the execution of OnEntry(MethodExecutionArgs).

Implements

IOnMethodBoundaryAspectOnEntry(MethodExecutionArgs)
Remarks
If the aspect is applied to a constructor, the current method is invoked after the this pointer has been initialized, that is, after the base constructor has been called.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect.OnException Method

OnMethodBoundaryAspectOnException Method
Method executed after the body of methods to which this aspect is applied, in case that the method resulted with an exception.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnException(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed and which are its arguments.

Implements

IOnMethodBoundaryAspectOnException(MethodExecutionArgs)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect.OnExit Method

OnMethodBoundaryAspectOnExit Method
Method executed after the body of methods to which this aspect is applied, even when the method exists with an exception (this method is invoked from the finally block).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnExit(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed and which are its arguments.

Implements

IOnMethodBoundaryAspectOnExit(MethodExecutionArgs)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect.OnResume Method

OnMethodBoundaryAspectOnResume Method
Method executed when a state machine resumes execution after an yield return or await statement.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnResume(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed and which are its arguments.

Implements

IOnStateMachineBoundaryAspectOnResume(MethodExecutionArgs)
Remarks

For iterator methods, this advice is executed before the MoveNext method. However, the very first call of MoveNext maps to OnEntry(MethodExecutionArgs).

In async methods, the advice is executed just after the state machine restarts execution after having waited as a result of the await statement.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect.OnSuccess Method

OnMethodBoundaryAspectOnSuccess Method
Method executed after the body of methods to which this aspect is applied, but only when the method successfully returns (i.e. when no exception flies out the method.).

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnSuccess(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed and which are its arguments.

Implements

IOnMethodBoundaryAspectOnSuccess(MethodExecutionArgs)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect.OnYield Method

OnMethodBoundaryAspectOnYield Method
Method executed when a state machine yields, as the result of an yield return or await statement.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnYield(
    MethodExecutionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodExecutionArgs
Event arguments specifying which method is being executed and which are its arguments. In iterator methods, the YieldValue property gives access to the operand of the yield return statement.

Implements

IOnStateMachineBoundaryAspectOnYield(MethodExecutionArgs)
Remarks

In iterator methods, this advise is exactly executed at the yield return statement.

In async methods, the advice is executed just after the state machine starts waiting as a result of the await statement. In case the operand of the await statement is an operation that completed synchronously, the state machine does not yield, and the OnYield(MethodExecutionArgs) advise won't be invoked.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect.SetAspectConfiguration Method

OnMethodBoundaryAspectSetAspectConfiguration Method
Overload List
 | Name | Description
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides MethodLevelAspectSetAspectConfiguration(AspectConfiguration, MethodBase).)
Top
See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect.SetAspectConfiguration Method (AspectConfiguration, MethodBase)

OnMethodBoundaryAspectSetAspectConfiguration Method (AspectConfiguration, MethodBase)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    MethodBase targetMethod
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetMethod
Type: System.ReflectionMethodBase
Method to which the current aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


OnMethodBoundaryAspect Properties

OnMethodBoundaryAspect Properties

The OnMethodBoundaryAspect type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


OnMethodBoundaryAspect.ApplyToStateMachine Property

OnMethodBoundaryAspectApplyToStateMachine Property
Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool ApplyToStateMachine { get; set; }

Property Value

Type: Boolean
true if the aspect should be applied to the state machine, or false if it should be applied to the method instantiating the state machine.
Remarks

The default value is false unless the aspect class implements the OnYield(MethodExecutionArgs) or OnResume(MethodExecutionArgs) advices. In the latter case the default value is true.

Assigning this property to true results in an aspect that is consistent with the level of abstraction of the programming language. The false value is consistent with the level of abstraction of MSIL and is backward-compatible with versions of PostSharp prior to 3.1.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspect Class
PostSharp.Aspects Namespace


TypeIdentity Class

TypeIdentity Class
Wraps a Type or a type name.
Inheritance Hierarchy
SystemObject
PostSharp.AspectsTypeIdentity

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class TypeIdentity

The TypeIdentity type exposes the following members.

Methods
 | Name | Description
 | FromType | Wraps a Type into a TypeIdentity.
 | FromTypeName | Wraps a type name into a TypeIdentity.
 | FromTypeNames | Wraps an array of type names into an array of TypeIdentity.
 | FromTypes | Wraps an array of Type into an array of TypeIdentity.
Public method | ToType | Converts a TypeIdentity into a Type.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Type | Gets the wrapped Type, or null it the TypeName property is set.
Public property | TypeName | Gets the wrapped type name, or null it the Type property is set.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace


TypeIdentity Methods

TypeIdentity Methods

The TypeIdentity type exposes the following members.

Methods
 | Name | Description
 | FromType | Wraps a Type into a TypeIdentity.
 | FromTypeName | Wraps a type name into a TypeIdentity.
 | FromTypeNames | Wraps an array of type names into an array of TypeIdentity.
 | FromTypes | Wraps an array of Type into an array of TypeIdentity.
Public method | ToType | Converts a TypeIdentity into a Type.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

TypeIdentity Class
PostSharp.Aspects Namespace


TypeIdentity.FromType Method

TypeIdentityFromType Method
Wraps a Type into a TypeIdentity.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static TypeIdentity FromType(
    Type type
)

Parameters

type
Type: SystemType
A Type.

Return Value

Type: TypeIdentity
A TypeIdentity wrapping .
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeIdentity Class
PostSharp.Aspects Namespace


TypeIdentity.FromTypeName Method

TypeIdentityFromTypeName Method
Wraps a type name into a TypeIdentity.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static TypeIdentity FromTypeName(
    string typeName
)

Parameters

typeName
Type: SystemString
The type name.

Return Value

Type: TypeIdentity
A TypeIdentity wrapping the type name.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeIdentity Class
PostSharp.Aspects Namespace


TypeIdentity.FromTypeNames Method

TypeIdentityFromTypeNames Method
Wraps an array of type names into an array of TypeIdentity.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static TypeIdentity[] FromTypeNames(
    string[] typeNames
)

Parameters

typeNames
Type: SystemString
An array of type names.

Return Value

Type: TypeIdentity
An array of TypeIdentity wrapping typeNames.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeIdentity Class
PostSharp.Aspects Namespace


TypeIdentity.FromTypes Method

TypeIdentityFromTypes Method
Wraps an array of Type into an array of TypeIdentity.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static TypeIdentity[] FromTypes(
    Type[] types
)

Parameters

types
Type: SystemType
An array of Type.

Return Value

Type: TypeIdentity
An array of TypeIdentity wrapping types.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeIdentity Class
PostSharp.Aspects Namespace


TypeIdentity.ToType Method

TypeIdentityToType Method
Converts a TypeIdentity into a Type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type ToType()

Return Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeIdentity Class
PostSharp.Aspects Namespace


TypeIdentity Properties

TypeIdentity Properties

The TypeIdentity type exposes the following members.

Properties
 | Name | Description
Public property | Type | Gets the wrapped Type, or null it the TypeName property is set.
Public property | TypeName | Gets the wrapped type name, or null it the Type property is set.
Top
See Also

Reference

TypeIdentity Class
PostSharp.Aspects Namespace


TypeIdentity.Type Property

TypeIdentityType Property
Gets the wrapped Type, or null it the TypeName property is set.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type Type { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeIdentity Class
PostSharp.Aspects Namespace


TypeIdentity.TypeName Property

TypeIdentityTypeName Property
Gets the wrapped type name, or null it the Type property is set.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string TypeName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeIdentity Class
PostSharp.Aspects Namespace


TypeLevelAspect Class

TypeLevelAspect Class
Base class for all aspects applied on types.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsCompositionAspect
PostSharp.AspectsInstanceLevelAspect

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class TypeLevelAspect : Aspect,
    ITypeLevelAspect, IAspect, ITypeLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation

The TypeLevelAspect type exposes the following members.

Constructors
 | Name | Description
Protected method | TypeLevelAspect | Initializes a new instance of the TypeLevelAspect class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks
Note Note
This class does not provide any advice. You may derive your aspect class from a class providing predefined advice , or build a composite aspect .

Note Note
All classes implementing IAspect should typically be marked as serializable using the custom attribute SerializableAttribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the custom attribute NonSerializedAttribute . When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Aspect Serialization .

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects Namespace
PostSharp.AspectsITypeLevelAspect

Other Resources

Conceptual Documentation: Aspect Classes
Conceptual Documentation: Developing Complex Aspects
Conceptual Documentation: Aspect Serialization


TypeLevelAspect Constructor

TypeLevelAspect Constructor
Initializes a new instance of the TypeLevelAspect class

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected TypeLevelAspect()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeLevelAspect Class
PostSharp.Aspects Namespace


TypeLevelAspect Methods

TypeLevelAspect Methods

The TypeLevelAspect type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from Aspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect.
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

TypeLevelAspect Class
PostSharp.Aspects Namespace


TypeLevelAspect.CompileTimeInitialize Method

TypeLevelAspectCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void CompileTimeInitialize(
    Type type,
    AspectInfo aspectInfo
)

Parameters

type
Type: SystemType
Type to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.

Implements

ITypeLevelAspectBuildSemanticsCompileTimeInitialize(Type, AspectInfo)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


TypeLevelAspect.CompileTimeValidate Method

TypeLevelAspectCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AspectCompileTimeValidate(Object).)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
See Also

Reference

TypeLevelAspect Class
PostSharp.Aspects Namespace


TypeLevelAspect.CompileTimeValidate Method (Object)

TypeLevelAspectCompileTimeValidate Method (Object)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override sealed bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the aspect has been applied.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.

Implements

IValidableAnnotationCompileTimeValidate(Object)
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


TypeLevelAspect.CompileTimeValidate Method (Type)

TypeLevelAspectCompileTimeValidate Method (Type)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual bool CompileTimeValidate(
    Type type
)

Parameters

type
Type: SystemType
Type to which the aspect has been applied

Return Value

Type: Boolean
true if the aspect was applied to an acceptable field, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeLevelAspect Class
CompileTimeValidate Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Validating Aspects


TypeLevelAspect.RuntimeInitialize Method

TypeLevelAspectRuntimeInitialize Method
Initializes the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void RuntimeInitialize(
    Type type
)

Parameters

type
Type: SystemType
Type to which the current aspect is applied.

Implements

ITypeLevelAspectRuntimeInitialize(Type)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeLevelAspect Class
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


TypeLevelAspect.SetAspectConfiguration Method

TypeLevelAspectSetAspectConfiguration Method
Overload List
 | Name | Description
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Overrides AspectSetAspectConfiguration(AspectConfiguration, Object).)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.
Top
See Also

Reference

TypeLevelAspect Class
PostSharp.Aspects Namespace


TypeLevelAspect.SetAspectConfiguration Method (AspectConfiguration, Object)

TypeLevelAspectSetAspectConfiguration Method (AspectConfiguration, Object)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    Object targetElement
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetElement
Type: SystemObject
Code element (Assembly, Type, FieldInfo, MethodBase, PropertyInfo, EventInfo, ParameterInfo, or LocationInfo) to which the current Aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


TypeLevelAspect.SetAspectConfiguration Method (AspectConfiguration, Type)

TypeLevelAspectSetAspectConfiguration Method (AspectConfiguration, Type)
Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration,
    Type targetType
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
targetType
Type: SystemType
Type to which the current aspect has been applied.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeLevelAspect Class
SetAspectConfiguration Overload
PostSharp.Aspects Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


TypeLevelAspect Properties

TypeLevelAspect Properties

The TypeLevelAspect type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

TypeLevelAspect Class
PostSharp.Aspects Namespace


PostSharp.Aspects.Advices Namespace

PostSharp.Aspects.Advices Namespace
The PostSharp.Aspects.Advices provides custom attributes that allow developing composite aspects with advices and pointcuts.
Classes
 | Class | Description
Public class | Advice | Base class for all custom attributes representing an advice.
Public class | AdviceInstance | Base class for advice instances, which can be provided dynamically by the aspect thanks to the IAdviceProvider interface.
Public class | CopyCustomAttributesAttribute | Custom attribute that, when applied on an aspect class, requires custom attributes present on the aspect class to be copied to the target of this class. When applied on an introduced member (see IntroduceMemberAttribute), this custom attribute requires custom attributes present on the aspect member to be copied to the introduced member.
Public class | EventTDelegate | Exposes the semantics of an event for use with the ImportMemberAttribute aspect extension.
Public class | GroupingAdvice | Base class for all advices that are possibly composed of multiple advices that can be grouped together using the Master property.
Public class | ImportLocationAdviceInstance | Represents an advice that imports a field or property (represented by a LocationInfo) of the target class into a field of the aspect class. This class is the imperative equivalent of the ImportMemberAttribute declarative advise.
Public class | ImportMemberAdviceInstance | Base class for ImportLocationAdviceInstance and ImportMethodAdviceInstance.
Public class | ImportMemberAttribute | Custom attribute that, when applied to an instance field of an aspect class, determines that this field should be bound to a method, event or property, of the target class of this aspect. Valid types for fields are a concrete Delegate (to bind to a method), PropertyTValue or PropertyTValue, TIndex (to bind to a property), or EventTDelegate (to bind to an event).
Public class | ImportMethodAdviceInstance | Represents an advises that import a method of the target class into the aspect class.
Public class | InitializeAspectInstanceAdvice | Custom attribute that, when applied to a method of an aspect class, specifies that this method should be invoked whenever the aspect instance needs to be initialized. The target method must have a void return value and have a single parameter of type AspectInitializationReason. This method is equivalent to RuntimeInitializeInstance
Public class | IntroduceInterfaceAdviceInstance | Represents an advise that introduces an interface into the target class. The interface must be implemented by the aspect class.
Public class | IntroduceInterfaceAttribute | Custom attribute that, when applied to an aspect class, specifies that the aspect should introduce a given interface into the type to which the aspect is applied.
Public class | IntroduceMemberAdviceInstance | Base class for IntroduceMethodAdviceInstance.
Public class | IntroduceMemberAttribute | Custom attribute that, when applied on a method, event or property of an aspect class, specifies that this method, event or property should be introduced into the types to which the aspect is applied.
Public class | IntroduceMethodAdviceInstance | Represents an advice that introduces a method of the aspect class into the target class.
Public class | LocationValidationAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method has the same semantic as the ValidateValue(T, String, LocationKind) method of the ILocationValidationAspectT interface.
Public class | MethodPointcut | Custom attribute that, when applied on an advice method, specifies the name of the method that will be invoked at build-time to return the set of elements of code to which the advice applies.
Public class | MulticastPointcut | Custom attribute that, when applied on an advice method, specifies to which elements of code this advice applies, based on the kind, name and attributes of code elements. Works similarly as MulticastAttribute.
Public class | OnEventAddHandlerAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnAddHandler(EventInterceptionArgs).
Public class | OnEventInvokeHandlerAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnInvokeHandler(EventInterceptionArgs).
Public class | OnEventRemoveHandlerAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnRemoveHandler(EventInterceptionArgs).
Public class | OnInstanceConstructedAdvice | Custom attribute that, when applied to a method of an aspect implementing , specifies that this method should be executed after the last instance constructor of the target class of the aspect has completed execution. That is, this method will be invoked when the target object will be fully constructed. This custom attribute can be applied only on methods that have void return type and accepts no parameter.
Public class | OnLocationGetValueAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnGetValue(LocationInterceptionArgs).
Public class | OnLocationSetValueAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnSetValue(LocationInterceptionArgs).
Public class | OnMethodBoundaryAdvice | Base class for OnMethodEntryAdvice, OnMethodExceptionAdvice, OnMethodSuccessAdvice or OnMethodExitAdvice.
Public class | OnMethodEntryAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnEntry(MethodExecutionArgs).
Public class | OnMethodExceptionAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnException(MethodExecutionArgs).
Public class | OnMethodExitAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnExit(MethodExecutionArgs).
Public class | OnMethodInvokeAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnInvoke(MethodInterceptionArgs).
Public class | OnMethodResumeAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnResume(MethodExecutionArgs).
Public class | OnMethodSuccessAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnSuccess(MethodExecutionArgs).
Public class | OnMethodYieldAdvice | Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnYield(MethodExecutionArgs).
Public class | Pointcut | Custom attribute, typically accompanying an advice, specifying to which code elements the advice applies.
Public class | PropertyTValue | Exposes the semantics of a parameterless property for use with the ImportMemberAttribute aspect extension.
Public class | PropertyTValue, TIndex | Mimics the semantics of a property accepting a single index parameter, for use with the ImportMemberAttribute aspect extension.
Public class | SelfPointcut | Pointcut that selects exactly the aspect target.
Interfaces
 | Interface | Description
Public interface | IAdviceProvider | Interface that allows an aspect to provide aspects dynamically, instead of declaratively using custom attributes.
Public interface | IProperty | A weakly-typed interface for the class.
Delegates
 | Delegate | Description
Public delegate | EventAccessorTDelegate | Defines the signature of methods implementing the Add and Remove semantics of an event.
Public delegate | PropertyGetterTValue | Defines the signature of methods implementing the Get semantic of a parameterless property.
Public delegate | PropertyGetterTValue, TIndex | Defines the signature of methods implementing the Get semantic of a property with a single index parameter.
Public delegate | PropertySetterTValue | Defines the signature of methods implementing the Set semantic of a parameterless property.
Public delegate | PropertySetterTValue, TIndex | Defines the signature of methods implementing the Set semantic of a property with a single index parameter.
Enumerations
 | Enumeration | Description
Public enumeration | AspectInitializationReason | Enumerates the reasons why the target method of the InitializeAspectInstanceAdvice has been invoked.
Public enumeration | CustomAttributeOverrideAction | Behavior of CopyCustomAttributesAttribute when a custom attribute of the same type already exists on the target declaration.
Public enumeration | ImportMemberOrder | Enumeration of moments when members should be imported into an aspect.
Public enumeration | InterfaceOverrideAction | Enumeration of actions to be overtaken when an interface that should be introduced into a type is already implemented by that type.
Public enumeration | MemberOverrideAction | Enumeration of actions to be overtaken by the IntroduceMemberAttribute aspect extension when the member to be introduced already exists in the aspect target type or its base type.


Advice Class

Advice Class
Base class for all custom attributes representing an advice.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
More...

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class Advice : Attribute

The Advice type exposes the following members.

Constructors
 | Name | Description
Protected method | Advice | Initializes a new instance of the Advice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks

Advices are behaviors added to aspects by the way of custom attributes. Other ways to add behaviors is to implement interface methods.

Advice custom attributes are typically used on aspect classes, or on members of aspect classes.

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace

Other Resources

Conceptual Documentation: Developing Complex Aspects
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesCopyCustomAttributesAttribute
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesImportMemberAttribute
PostSharp.Aspects.AdvicesInitializeAspectInstanceAdvice
PostSharp.Aspects.AdvicesIntroduceInterfaceAttribute
PostSharp.Aspects.AdvicesIntroduceMemberAttribute
PostSharp.Aspects.AdvicesOnInstanceConstructedAdvice
PostSharp.Aspects.AdvicesOnMethodInvokeAdvice


Advice Constructor

Advice Constructor
Initializes a new instance of the Advice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected Advice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Advice Class
PostSharp.Aspects.Advices Namespace


Advice Methods

Advice Methods

The Advice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

Advice Class
PostSharp.Aspects.Advices Namespace


AdviceInstance Class

AdviceInstance Class
Base class for advice instances, which can be provided dynamically by the aspect thanks to the IAdviceProvider interface.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.AdvicesAdviceInstance
PostSharp.Aspects.AdvicesImportMemberAdviceInstance
PostSharp.Aspects.AdvicesIntroduceInterfaceAdviceInstance
PostSharp.Aspects.AdvicesIntroduceMemberAdviceInstance

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class AdviceInstance

The AdviceInstance type exposes the following members.

Constructors
 | Name | Description
Protected method | AdviceInstance | Initializes a new instance of the AdviceInstance class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to.
Top
Remarks

The only supported dynamic advice currently is ImportLocationAdviceInstance.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace


AdviceInstance Constructor

AdviceInstance Constructor
Initializes a new instance of the AdviceInstance class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AdviceInstance()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AdviceInstance Class
PostSharp.Aspects.Advices Namespace


AdviceInstance Methods

AdviceInstance Methods

The AdviceInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdviceInstance Class
PostSharp.Aspects.Advices Namespace


AdviceInstance Properties

AdviceInstance Properties

The AdviceInstance type exposes the following members.

Properties
 | Name | Description
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to.
Top
See Also

Reference

AdviceInstance Class
PostSharp.Aspects.Advices Namespace


AdviceInstance.MasterAspectMember Property

AdviceInstanceMasterAspectMember Property
Gets the main field or method of the aspect class that the current AdviceInstance relates to.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract Object MasterAspectMember { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AdviceInstance Class
PostSharp.Aspects.Advices Namespace


AspectInitializationReason Enumeration

AspectInitializationReason Enumeration
Enumerates the reasons why the target method of the InitializeAspectInstanceAdvice has been invoked.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum AspectInitializationReason
Members
Member name | Value | Description
None | 0 | None.
Manual | 1 | Manual call of the InitializeAspects method.
Constructor | 2 | Call from the instance constructor.
Clone | 3 | Call from MemberwiseClone.
Deserialize | 4 | Call during deserialization.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace


CopyCustomAttributesAttribute Class

CopyCustomAttributesAttribute Class
Custom attribute that, when applied on an aspect class, requires custom attributes present on the aspect class to be copied to the target of this class. When applied on an introduced member (see IntroduceMemberAttribute), this custom attribute requires custom attributes present on the aspect member to be copied to the introduced member.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesCopyCustomAttributesAttribute

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class CopyCustomAttributesAttribute : Advice

The CopyCustomAttributesAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | CopyCustomAttributesAttribute(Type) | Requires custom attributes present on the aspect class or aspect class member to be copied to the aspect target or to the introduced member, respectively.
Public method | CopyCustomAttributesAttribute(Type) | Requires custom attributes present on the aspect class or aspect class member to be copied to the aspect target or to the introduced member, respectively.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | OverrideAction | Determines what should happen when a custom attribute of the same type is already present on the target declaration.
Public property | Types | Gets the list of custom attribute types to be copied.
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesIntroduceMemberAttribute

Other Resources

Conceptual Documentation: Introducing, Overriding and Importing Members


CopyCustomAttributesAttribute Constructor

CopyCustomAttributesAttribute Constructor
Overload List
 | Name | Description
Public method | CopyCustomAttributesAttribute(Type) | Requires custom attributes present on the aspect class or aspect class member to be copied to the aspect target or to the introduced member, respectively.
Public method | CopyCustomAttributesAttribute(Type) | Requires custom attributes present on the aspect class or aspect class member to be copied to the aspect target or to the introduced member, respectively.
Top
See Also

Reference

CopyCustomAttributesAttribute Class
PostSharp.Aspects.Advices Namespace


CopyCustomAttributesAttribute Constructor (Type)

CopyCustomAttributesAttribute Constructor (Type)
Requires custom attributes present on the aspect class or aspect class member to be copied to the aspect target or to the introduced member, respectively.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public CopyCustomAttributesAttribute(
    Type type
)

Parameters

type
Type: SystemType
Base type of custom attributes to be copied.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CopyCustomAttributesAttribute Class
CopyCustomAttributesAttribute Overload
PostSharp.Aspects.Advices Namespace


CopyCustomAttributesAttribute Constructor (Type[])

CopyCustomAttributesAttribute Constructor (Type)
Requires custom attributes present on the aspect class or aspect class member to be copied to the aspect target or to the introduced member, respectively.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public CopyCustomAttributesAttribute(
    params Type[] types
)

Parameters

types
Type: SystemType
Base types of custom attributes to be copied.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CopyCustomAttributesAttribute Class
CopyCustomAttributesAttribute Overload
PostSharp.Aspects.Advices Namespace


CopyCustomAttributesAttribute Methods

CopyCustomAttributesAttribute Methods

The CopyCustomAttributesAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CopyCustomAttributesAttribute Class
PostSharp.Aspects.Advices Namespace


CopyCustomAttributesAttribute Properties

CopyCustomAttributesAttribute Properties

The CopyCustomAttributesAttribute type exposes the following members.

Properties
 | Name | Description
Public property | OverrideAction | Determines what should happen when a custom attribute of the same type is already present on the target declaration.
Public property | Types | Gets the list of custom attribute types to be copied.
Top
See Also

Reference

CopyCustomAttributesAttribute Class
PostSharp.Aspects.Advices Namespace


CopyCustomAttributesAttribute.OverrideAction Property

CopyCustomAttributesAttributeOverrideAction Property
Determines what should happen when a custom attribute of the same type is already present on the target declaration.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public CustomAttributeOverrideAction OverrideAction { get; set; }

Property Value

Type: CustomAttributeOverrideAction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CopyCustomAttributesAttribute Class
PostSharp.Aspects.Advices Namespace


CopyCustomAttributesAttribute.Types Property

CopyCustomAttributesAttributeTypes Property
Gets the list of custom attribute types to be copied.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type[] Types { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CopyCustomAttributesAttribute Class
PostSharp.Aspects.Advices Namespace


CustomAttributeOverrideAction Enumeration

CustomAttributeOverrideAction Enumeration
Behavior of CopyCustomAttributesAttribute when a custom attribute of the same type already exists on the target declaration.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum CustomAttributeOverrideAction
Members
Member name | Value | Description
Default | 0 | Default (Fail).
Fail | 0 | Emits an error message.
Ignore | 1 | Silently ignore this custom attribute (does not copy it, without error message).
Add | 2 | Adds a new copy (possibly duplicate) of the custom attribute.
MergeAddProperty | 3 | Merges the existing custom attribute with the template custom attribute by adding properties and fields. If the existing custom attribute defines the same properties and fields as the template custom attribute, they are not overridden.
MergeReplaceProperty | 4 | Merges the existing custom attribute with the template custom attribute by adding and replacing properties and fields. If the existing custom attribute defines the same properties and fields as the template custom attribute, they are replaced by the values defined in the template custom attribute.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesCopyCustomAttributesAttribute


Event(TDelegate) Class

EventTDelegate Class
Exposes the semantics of an event for use with the ImportMemberAttribute aspect extension.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.AdvicesEventTDelegate

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class Event<TDelegate>

Type Parameters

TDelegate
Handler type (derived from Delegate).

The EventTDelegate type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Add | Gets a delegate enabling to invoke the add accessor of the imported event.
Public property | Remove | Gets a delegate enabling to invoke the remove accessor of the imported event.
Top
Remarks
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesImportMemberAttribute

Other Resources

Conceptual Documentation: Introducing, Overriding and Importing Members


Event(TDelegate) Methods

EventTDelegate Methods

The EventTDelegate generic type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EventTDelegate Class
PostSharp.Aspects.Advices Namespace


Event(TDelegate) Properties

EventTDelegate Properties

The EventTDelegate generic type exposes the following members.

Properties
 | Name | Description
Public property | Add | Gets a delegate enabling to invoke the add accessor of the imported event.
Public property | Remove | Gets a delegate enabling to invoke the remove accessor of the imported event.
Top
See Also

Reference

EventTDelegate Class
PostSharp.Aspects.Advices Namespace


Event(TDelegate).Add Property

EventTDelegateAdd Property
Gets a delegate enabling to invoke the add accessor of the imported event.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EventAccessor<TDelegate> Add { get; }

Property Value

Type: EventAccessor TDelegate
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventTDelegate Class
PostSharp.Aspects.Advices Namespace


Event(TDelegate).Remove Property

EventTDelegateRemove Property
Gets a delegate enabling to invoke the remove accessor of the imported event.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EventAccessor<TDelegate> Remove { get; }

Property Value

Type: EventAccessor TDelegate
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventTDelegate Class
PostSharp.Aspects.Advices Namespace


EventAccessor(TDelegate) Delegate

EventAccessorTDelegate Delegate
Defines the signature of methods implementing the Add and Remove semantics of an event.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public delegate void EventAccessor<TDelegate>(
    TDelegate delegate
)

Parameters

delegate
Type: TDelegate
Handler.

Type Parameters

TDelegate
Handler type (derived from Delegate).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesEventTDelegate


GroupingAdvice Class

GroupingAdvice Class
Base class for all advices that are possibly composed of multiple advices that can be grouped together using the Master property.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
More...

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class GroupingAdvice : Advice

The GroupingAdvice type exposes the following members.

Constructors
 | Name | Description
Protected method | GroupingAdvice | Initializes a new instance of the GroupingAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute).
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesLocationValidationAdvice
PostSharp.Aspects.AdvicesOnEventAddHandlerAdvice
PostSharp.Aspects.AdvicesOnEventInvokeHandlerAdvice
PostSharp.Aspects.AdvicesOnEventRemoveHandlerAdvice
PostSharp.Aspects.AdvicesOnLocationGetValueAdvice
PostSharp.Aspects.AdvicesOnLocationSetValueAdvice
PostSharp.Aspects.AdvicesOnMethodBoundaryAdvice


GroupingAdvice Constructor

GroupingAdvice Constructor
Initializes a new instance of the GroupingAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected GroupingAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

GroupingAdvice Class
PostSharp.Aspects.Advices Namespace


GroupingAdvice Methods

GroupingAdvice Methods

The GroupingAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

GroupingAdvice Class
PostSharp.Aspects.Advices Namespace


GroupingAdvice Properties

GroupingAdvice Properties

The GroupingAdvice type exposes the following members.

Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute).
Top
See Also

Reference

GroupingAdvice Class
PostSharp.Aspects.Advices Namespace


GroupingAdvice.Master Property

GroupingAdviceMaster Property
Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute).

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Master { get; set; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

GroupingAdvice Class
PostSharp.Aspects.Advices Namespace


IAdviceProvider Interface

IAdviceProvider Interface
Interface that allows an aspect to provide aspects dynamically, instead of declaratively using custom attributes.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAdviceProvider : IAspect

The IAdviceProvider type exposes the following members.

Methods
 | Name | Description
Public method | ProvideAdvices | Provides an enumeration of advices, represented as instances of the AdviceInstance class, for the current aspect instance.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace


IAdviceProvider Methods

IAdviceProvider Methods

The IAdviceProvider type exposes the following members.

Methods
 | Name | Description
Public method | ProvideAdvices | Provides an enumeration of advices, represented as instances of the AdviceInstance class, for the current aspect instance.
Top
See Also

Reference

IAdviceProvider Interface
PostSharp.Aspects.Advices Namespace


IAdviceProvider.ProvideAdvices Method

IAdviceProviderProvideAdvices Method
Provides an enumeration of advices, represented as instances of the AdviceInstance class, for the current aspect instance.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IEnumerable<AdviceInstance> ProvideAdvices(
    Object targetElement
)

Parameters

targetElement
Type: SystemObject
Element of code to which the current aspect has been applied.

Return Value

Type: IEnumerable AdviceInstance
A collection of advices to be added to the current aspect instance.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IAdviceProvider Interface
PostSharp.Aspects.Advices Namespace


ImportLocationAdviceInstance Class

ImportLocationAdviceInstance Class
Represents an advice that imports a field or property (represented by a LocationInfo) of the target class into a field of the aspect class. This class is the imperative equivalent of the ImportMemberAttribute declarative advise.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.AdvicesAdviceInstance
PostSharp.Aspects.AdvicesImportMemberAdviceInstance
PostSharp.Aspects.AdvicesImportLocationAdviceInstance

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ImportLocationAdviceInstance : ImportMemberAdviceInstance

The ImportLocationAdviceInstance type exposes the following members.

Constructors
 | Name | Description
Public method | ImportLocationAdviceInstance(FieldInfo, LocationInfo) | Initializes a new instance of the ImportLocationAdviceInstance class and specifies which field or property should be imported by giving its reflection representation.
Public method | ImportLocationAdviceInstance(FieldInfo, String, Boolean, ImportMemberOrder) | Initializes a new instance of the ImportLocationAdviceInstance class and specifies the name of the property to be imported; the type of this property will be matched according to the type of the aspect field.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectField | Gets the field of the aspect class to which the field or property needs to be bound. (Inherited from ImportMemberAdviceInstance.)
Public property | IsRequired | Determines whether a build-time error should be emitted if the member cannot be found. If false, the binding field will be null in case the imported member is absent. (Inherited from ImportMemberAdviceInstance.)
Public property | Location | Gets the field or property of the target class that needs to be imported into the aspect.
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to. (Inherited from ImportMemberAdviceInstance.)
Public property | Member | Gets the reflection object (LocationInfo or MethodInfo) that needs to be imported, or null if the exact member is unknown and must be matched by name and signature. (Overrides ImportMemberAdviceInstanceMember.)
Public property | MemberName | Gets the name of the member to be imported. (Overrides ImportMemberAdviceInstanceMemberName.)
Public property | Order | Determines whether the AspectField should be bound to the member as resolved before or after introduction of new members into the target class by the current advise. (Inherited from ImportMemberAdviceInstance.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesIAdviceProvider
PostSharp.Aspects.AdvicesImportMemberAttribute


ImportLocationAdviceInstance Constructor

ImportLocationAdviceInstance Constructor
Overload List
 | Name | Description
Public method | ImportLocationAdviceInstance(FieldInfo, LocationInfo) | Initializes a new instance of the ImportLocationAdviceInstance class and specifies which field or property should be imported by giving its reflection representation.
Public method | ImportLocationAdviceInstance(FieldInfo, String, Boolean, ImportMemberOrder) | Initializes a new instance of the ImportLocationAdviceInstance class and specifies the name of the property to be imported; the type of this property will be matched according to the type of the aspect field.
Top
See Also

Reference

ImportLocationAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportLocationAdviceInstance Constructor (FieldInfo, LocationInfo)

ImportLocationAdviceInstance Constructor (FieldInfo, LocationInfo)
Initializes a new instance of the ImportLocationAdviceInstance class and specifies which field or property should be imported by giving its reflection representation.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ImportLocationAdviceInstance(
    FieldInfo aspectField,
    LocationInfo location
)

Parameters

aspectField
Type: System.ReflectionFieldInfo
A field of the aspect class to which location should be bound at runtime. This field can be of type ILocationBinding, PropertyTValue, or a type that is both (a) derived from ICollection<ILocationBinding> and (b) has a parameterless constructor.
location
Type: PostSharp.ReflectionLocationInfo
The field or property to import.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportLocationAdviceInstance Class
ImportLocationAdviceInstance Overload
PostSharp.Aspects.Advices Namespace


ImportLocationAdviceInstance Constructor (FieldInfo, String, Boolean, ImportMemberOrder)

ImportLocationAdviceInstance Constructor (FieldInfo, String, Boolean, ImportMemberOrder)
Initializes a new instance of the ImportLocationAdviceInstance class and specifies the name of the property to be imported; the type of this property will be matched according to the type of the aspect field.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ImportLocationAdviceInstance(
    FieldInfo aspectField,
    string propertyName,
    bool isRequired = false,
    ImportMemberOrder order = ImportMemberOrder.Default
)

Parameters

aspectField
Type: System.ReflectionFieldInfo
A field of the aspect class to which the field or property should be bound at build time. This field must be of type PropertyTValue.
propertyName
Type: SystemString
The name of the property to import.
isRequired (Optional)
Type: SystemBoolean
Determines whether a build-time error should be emitted if the member cannot be found. If false, the binding field will be null in case the imported member is absent.
order (Optional)
Type: PostSharp.Aspects.AdvicesImportMemberOrder
Determines whether the aspectField should be bound to the member as resolved before or after introduction of new members into the target class by the current advise.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportLocationAdviceInstance Class
ImportLocationAdviceInstance Overload
PostSharp.Aspects.Advices Namespace


ImportLocationAdviceInstance Methods

ImportLocationAdviceInstance Methods

The ImportLocationAdviceInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ImportLocationAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportLocationAdviceInstance Properties

ImportLocationAdviceInstance Properties

The ImportLocationAdviceInstance type exposes the following members.

Properties
 | Name | Description
Public property | AspectField | Gets the field of the aspect class to which the field or property needs to be bound. (Inherited from ImportMemberAdviceInstance.)
Public property | IsRequired | Determines whether a build-time error should be emitted if the member cannot be found. If false, the binding field will be null in case the imported member is absent. (Inherited from ImportMemberAdviceInstance.)
Public property | Location | Gets the field or property of the target class that needs to be imported into the aspect.
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to. (Inherited from ImportMemberAdviceInstance.)
Public property | Member | Gets the reflection object (LocationInfo or MethodInfo) that needs to be imported, or null if the exact member is unknown and must be matched by name and signature. (Overrides ImportMemberAdviceInstanceMember.)
Public property | MemberName | Gets the name of the member to be imported. (Overrides ImportMemberAdviceInstanceMemberName.)
Public property | Order | Determines whether the AspectField should be bound to the member as resolved before or after introduction of new members into the target class by the current advise. (Inherited from ImportMemberAdviceInstance.)
Top
See Also

Reference

ImportLocationAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportLocationAdviceInstance.Location Property

ImportLocationAdviceInstanceLocation Property
Gets the field or property of the target class that needs to be imported into the aspect.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LocationInfo Location { get; }

Property Value

Type: LocationInfo
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportLocationAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportLocationAdviceInstance.Member Property

ImportLocationAdviceInstanceMember Property
Gets the reflection object (LocationInfo or MethodInfo) that needs to be imported, or null if the exact member is unknown and must be matched by name and signature.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object Member { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportLocationAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportLocationAdviceInstance.MemberName Property

ImportLocationAdviceInstanceMemberName Property
Gets the name of the member to be imported.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override string MemberName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportLocationAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMemberAdviceInstance Class

ImportMemberAdviceInstance Class
Base class for ImportLocationAdviceInstance and ImportMethodAdviceInstance.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.AdvicesAdviceInstance
PostSharp.Aspects.AdvicesImportMemberAdviceInstance
PostSharp.Aspects.AdvicesImportLocationAdviceInstance
PostSharp.Aspects.AdvicesImportMethodAdviceInstance

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class ImportMemberAdviceInstance : AdviceInstance,
    IImportMemberAdviseProperties

The ImportMemberAdviceInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectField | Gets the field of the aspect class to which the field or property needs to be bound.
Public property | IsRequired | Determines whether a build-time error should be emitted if the member cannot be found. If false, the binding field will be null in case the imported member is absent.
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to. (Overrides AdviceInstanceMasterAspectMember.)
Public property | Member | Gets the reflection object (LocationInfo or MethodInfo) that needs to be imported, or null if the exact member is unknown and must be matched by name and signature.
Public property | MemberName | Gets the name of the member to be imported.
Public property | Order | Determines whether the AspectField should be bound to the member as resolved before or after introduction of new members into the target class by the current advise.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesIAdviceProvider
PostSharp.Aspects.AdvicesImportMemberAttribute


ImportMemberAdviceInstance Methods

ImportMemberAdviceInstance Methods

The ImportMemberAdviceInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ImportMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMemberAdviceInstance Properties

ImportMemberAdviceInstance Properties

The ImportMemberAdviceInstance type exposes the following members.

Properties
 | Name | Description
Public property | AspectField | Gets the field of the aspect class to which the field or property needs to be bound.
Public property | IsRequired | Determines whether a build-time error should be emitted if the member cannot be found. If false, the binding field will be null in case the imported member is absent.
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to. (Overrides AdviceInstanceMasterAspectMember.)
Public property | Member | Gets the reflection object (LocationInfo or MethodInfo) that needs to be imported, or null if the exact member is unknown and must be matched by name and signature.
Public property | MemberName | Gets the name of the member to be imported.
Public property | Order | Determines whether the AspectField should be bound to the member as resolved before or after introduction of new members into the target class by the current advise.
Top
See Also

Reference

ImportMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMemberAdviceInstance.AspectField Property

ImportMemberAdviceInstanceAspectField Property
Gets the field of the aspect class to which the field or property needs to be bound.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public FieldInfo AspectField { get; }

Property Value

Type: FieldInfo
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMemberAdviceInstance.IsRequired Property

ImportMemberAdviceInstanceIsRequired Property
Determines whether a build-time error should be emitted if the member cannot be found. If false, the binding field will be null in case the imported member is absent.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsRequired { get; }

Property Value

Type: Boolean
Remarks

This property is always true when the Member property is set.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMemberAdviceInstance.MasterAspectMember Property

ImportMemberAdviceInstanceMasterAspectMember Property
Gets the main field or method of the aspect class that the current AdviceInstance relates to.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object MasterAspectMember { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMemberAdviceInstance.Member Property

ImportMemberAdviceInstanceMember Property
Gets the reflection object (LocationInfo or MethodInfo) that needs to be imported, or null if the exact member is unknown and must be matched by name and signature.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract Object Member { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMemberAdviceInstance.MemberName Property

ImportMemberAdviceInstanceMemberName Property
Gets the name of the member to be imported.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract string MemberName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMemberAdviceInstance.Order Property

ImportMemberAdviceInstanceOrder Property
Determines whether the AspectField should be bound to the member as resolved before or after introduction of new members into the target class by the current advise.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ImportMemberOrder Order { get; }

Property Value

Type: ImportMemberOrder
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMemberAttribute Class

ImportMemberAttribute Class
Custom attribute that, when applied to an instance field of an aspect class, determines that this field should be bound to a method, event or property, of the target class of this aspect. Valid types for fields are a concrete Delegate (to bind to a method), PropertyTValue or PropertyTValue, TIndex (to bind to a property), or EventTDelegate (to bind to an event).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesImportMemberAttribute

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ImportMemberAttribute : Advice,
    IImportMemberAdviseProperties

The ImportMemberAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ImportMemberAttribute | Initializes a new ImportMemberAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsRequired | Determines whether a build time error must be issued if the member to be imported is absent. If false, the binding field will be null in case the imported member is absent.
Public property | MemberName | Name of the imported member.
Public property | Order | Determines when the member should be imported: either before (BeforeIntroductions) or after (AfterIntroductions) members have been introduced by the current aspect. Default is BeforeIntroductions.
Top
Remarks

Fields annotated with the ImportMemberAttribute custom attribute must be public and must not be read only.

At runtime, these fields are assigned to a delegate (in case of method binding) or a pair of delegates (in case of event or property binding) allowing to invoke the imported member.

When the target type does not contain a member of the required name and signature

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace

Other Resources

Conceptual Documentation: Introducing, Overriding and Importing Members


ImportMemberAttribute Constructor

ImportMemberAttribute Constructor
Initializes a new ImportMemberAttribute.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ImportMemberAttribute(
    string memberName
)

Parameters

memberName
Type: SystemString
Name of the member to import.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ImportMemberAttribute Class
PostSharp.Aspects.Advices Namespace


ImportMemberAttribute Methods

ImportMemberAttribute Methods

The ImportMemberAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ImportMemberAttribute Class
PostSharp.Aspects.Advices Namespace


ImportMemberAttribute Properties

ImportMemberAttribute Properties

The ImportMemberAttribute type exposes the following members.

Properties
 | Name | Description
Public property | IsRequired | Determines whether a build time error must be issued if the member to be imported is absent. If false, the binding field will be null in case the imported member is absent.
Public property | MemberName | Name of the imported member.
Public property | Order | Determines when the member should be imported: either before (BeforeIntroductions) or after (AfterIntroductions) members have been introduced by the current aspect. Default is BeforeIntroductions.
Top
See Also

Reference

ImportMemberAttribute Class
PostSharp.Aspects.Advices Namespace


ImportMemberAttribute.IsRequired Property

ImportMemberAttributeIsRequired Property
Determines whether a build time error must be issued if the member to be imported is absent. If false, the binding field will be null in case the imported member is absent.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsRequired { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ImportMemberAttribute Class
PostSharp.Aspects.Advices Namespace


ImportMemberAttribute.MemberName Property

ImportMemberAttributeMemberName Property
Name of the imported member.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string MemberName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ImportMemberAttribute Class
PostSharp.Aspects.Advices Namespace


ImportMemberAttribute.Order Property

ImportMemberAttributeOrder Property
Determines when the member should be imported: either before (BeforeIntroductions) or after (AfterIntroductions) members have been introduced by the current aspect. Default is BeforeIntroductions.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ImportMemberOrder Order { get; set; }

Property Value

Type: ImportMemberOrder
Remarks
Sometimes it makes sense for an aspect to import a member after the same aspect has introduced member. This allows the aspect to invoke a member that could be overridden by later aspects.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ImportMemberAttribute Class
PostSharp.Aspects.Advices Namespace


ImportMemberOrder Enumeration

ImportMemberOrder Enumeration
Enumeration of moments when members should be imported into an aspect.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum ImportMemberOrder
Members
Member name | Value | Description
Default | 0 | AfterIntroductions
BeforeIntroductions | 1 | Before the aspect introduces its own members. This is similar to calling the overridden method using the base keyword in C#. The overridden method implementation is always selected, even if the method is virtual.
AfterIntroductions | 0 | After the aspect introduces its own members. Note that importing a member introduced by the current aspect makes sense only if the member has been introduced as virtual; in this case, the the imported member is dynamically resolved using the virtual table of the target object.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesImportMemberAttribute


ImportMethodAdviceInstance Class

ImportMethodAdviceInstance Class
Represents an advises that import a method of the target class into the aspect class.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.AdvicesAdviceInstance
PostSharp.Aspects.AdvicesImportMemberAdviceInstance
PostSharp.Aspects.AdvicesImportMethodAdviceInstance

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ImportMethodAdviceInstance : ImportMemberAdviceInstance

The ImportMethodAdviceInstance type exposes the following members.

Constructors
 | Name | Description
Public method | ImportMethodAdviceInstance | Initializes a new instance of the ImportMethodAdviceInstance.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectField | Gets the field of the aspect class to which the field or property needs to be bound. (Inherited from ImportMemberAdviceInstance.)
Public property | IsRequired | Determines whether a build-time error should be emitted if the member cannot be found. If false, the binding field will be null in case the imported member is absent. (Inherited from ImportMemberAdviceInstance.)
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to. (Inherited from ImportMemberAdviceInstance.)
Public property | Member | Gets the reflection object (LocationInfo or MethodInfo) that needs to be imported, or null if the exact member is unknown and must be matched by name and signature. (Overrides ImportMemberAdviceInstanceMember.)
Public property | MemberName | Gets the name of the member to be imported. (Overrides ImportMemberAdviceInstanceMemberName.)
Public property | Order | Determines whether the AspectField should be bound to the member as resolved before or after introduction of new members into the target class by the current advise. (Inherited from ImportMemberAdviceInstance.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace


ImportMethodAdviceInstance Constructor

ImportMethodAdviceInstance Constructor
Initializes a new instance of the ImportMethodAdviceInstance.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ImportMethodAdviceInstance(
    FieldInfo aspectField,
    string methodName,
    bool isRequired = false,
    ImportMemberOrder order = ImportMemberOrder.Default
)

Parameters

aspectField
Type: System.ReflectionFieldInfo
A field of the aspect class into that will be assigned to a delegate of the imported method at runtime. The field type should be a delegate of the same signature than the method to import.
methodName
Type: SystemString
Name of the method to import.
isRequired (Optional)
Type: SystemBoolean
true if the build should fail if there no matching method in the target class, false to set aspectField to null in this case.
order (Optional)
Type: PostSharp.Aspects.AdvicesImportMemberOrder
Determines whether the aspectField should be bound to the member as resolved before or after introduction of new members into the target class by the current advise.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportMethodAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMethodAdviceInstance Methods

ImportMethodAdviceInstance Methods

The ImportMethodAdviceInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ImportMethodAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMethodAdviceInstance Properties

ImportMethodAdviceInstance Properties

The ImportMethodAdviceInstance type exposes the following members.

Properties
 | Name | Description
Public property | AspectField | Gets the field of the aspect class to which the field or property needs to be bound. (Inherited from ImportMemberAdviceInstance.)
Public property | IsRequired | Determines whether a build-time error should be emitted if the member cannot be found. If false, the binding field will be null in case the imported member is absent. (Inherited from ImportMemberAdviceInstance.)
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to. (Inherited from ImportMemberAdviceInstance.)
Public property | Member | Gets the reflection object (LocationInfo or MethodInfo) that needs to be imported, or null if the exact member is unknown and must be matched by name and signature. (Overrides ImportMemberAdviceInstanceMember.)
Public property | MemberName | Gets the name of the member to be imported. (Overrides ImportMemberAdviceInstanceMemberName.)
Public property | Order | Determines whether the AspectField should be bound to the member as resolved before or after introduction of new members into the target class by the current advise. (Inherited from ImportMemberAdviceInstance.)
Top
See Also

Reference

ImportMethodAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMethodAdviceInstance.Member Property

ImportMethodAdviceInstanceMember Property
Gets the reflection object (LocationInfo or MethodInfo) that needs to be imported, or null if the exact member is unknown and must be matched by name and signature.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object Member { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportMethodAdviceInstance Class
PostSharp.Aspects.Advices Namespace


ImportMethodAdviceInstance.MemberName Property

ImportMethodAdviceInstanceMemberName Property
Gets the name of the member to be imported.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override string MemberName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImportMethodAdviceInstance Class
PostSharp.Aspects.Advices Namespace


InitializeAspectInstanceAdvice Class

InitializeAspectInstanceAdvice Class
Custom attribute that, when applied to a method of an aspect class, specifies that this method should be invoked whenever the aspect instance needs to be initialized. The target method must have a void return value and have a single parameter of type AspectInitializationReason. This method is equivalent to RuntimeInitializeInstance
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesInitializeAspectInstanceAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class InitializeAspectInstanceAdvice : Advice

The InitializeAspectInstanceAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | InitializeAspectInstanceAdvice | Initializes a new instance of the InitializeAspectInstanceAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace


InitializeAspectInstanceAdvice Constructor

InitializeAspectInstanceAdvice Constructor
Initializes a new instance of the InitializeAspectInstanceAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InitializeAspectInstanceAdvice()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

InitializeAspectInstanceAdvice Class
PostSharp.Aspects.Advices Namespace


InitializeAspectInstanceAdvice Methods

InitializeAspectInstanceAdvice Methods

The InitializeAspectInstanceAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

InitializeAspectInstanceAdvice Class
PostSharp.Aspects.Advices Namespace


InterfaceOverrideAction Enumeration

InterfaceOverrideAction Enumeration
Enumeration of actions to be overtaken when an interface that should be introduced into a type is already implemented by that type.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum InterfaceOverrideAction
Members
Member name | Value | Description
Default | 0 | Fail.
Fail | 0 | Fails and emits an error message.
Ignore | 1 | Silently ignore this interface (does not introduce it).
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesIntroduceInterfaceAttribute


IntroduceInterfaceAdviceInstance Class

IntroduceInterfaceAdviceInstance Class
Represents an advise that introduces an interface into the target class. The interface must be implemented by the aspect class.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.AdvicesAdviceInstance
PostSharp.Aspects.AdvicesIntroduceInterfaceAdviceInstance

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class IntroduceInterfaceAdviceInstance : AdviceInstance,
    IIntroduceInterfaceAdviceProperties

The IntroduceInterfaceAdviceInstance type exposes the following members.

Constructors
 | Name | Description
Public method | IntroduceInterfaceAdviceInstance | Initializes a new instance of the IntroduceInterfaceAdviceInstance class.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AncestorOverrideAction | Specifies the action (Fail or Ignore) to be overtaken when an ancestor of the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.
Public property | InterfaceType | Gets the interface to be introduced into the target class.
Public property | MasterAspectMember | (Overrides AdviceInstanceMasterAspectMember.)
Public property | OverrideAction | Specifies the action (Fail or Ignore) to be overtaken when the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesIAdviceProvider
PostSharp.Aspects.AdvicesIntroduceInterfaceAttribute


IntroduceInterfaceAdviceInstance Constructor

IntroduceInterfaceAdviceInstance Constructor
Initializes a new instance of the IntroduceInterfaceAdviceInstance class.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IntroduceInterfaceAdviceInstance(
    Type interfaceType,
    InterfaceOverrideAction overrideAction = InterfaceOverrideAction.Default,
    InterfaceOverrideAction ancestorOverrideAction = InterfaceOverrideAction.Default
)

Parameters

interfaceType
Type: SystemType
Interface to introduce to the target class. Must be implemented by the aspect class itself.
overrideAction (Optional)
Type: PostSharp.Aspects.AdvicesInterfaceOverrideAction
Specifies the action (Fail or Ignore) to be overtaken when the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.
ancestorOverrideAction (Optional)
Type: PostSharp.Aspects.AdvicesInterfaceOverrideAction
Specifies the action (Fail or Ignore) to be overtaken when an ancestor of the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IntroduceInterfaceAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceInterfaceAdviceInstance Methods

IntroduceInterfaceAdviceInstance Methods

The IntroduceInterfaceAdviceInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

IntroduceInterfaceAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceInterfaceAdviceInstance Properties

IntroduceInterfaceAdviceInstance Properties

The IntroduceInterfaceAdviceInstance type exposes the following members.

Properties
 | Name | Description
Public property | AncestorOverrideAction | Specifies the action (Fail or Ignore) to be overtaken when an ancestor of the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.
Public property | InterfaceType | Gets the interface to be introduced into the target class.
Public property | MasterAspectMember | (Overrides AdviceInstanceMasterAspectMember.)
Public property | OverrideAction | Specifies the action (Fail or Ignore) to be overtaken when the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.
Top
See Also

Reference

IntroduceInterfaceAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceInterfaceAdviceInstance.AncestorOverrideAction Property

IntroduceInterfaceAdviceInstanceAncestorOverrideAction Property
Specifies the action (Fail or Ignore) to be overtaken when an ancestor of the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InterfaceOverrideAction AncestorOverrideAction { get; }

Property Value

Type: InterfaceOverrideAction
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IntroduceInterfaceAdviceInstance Class
PostSharp.Aspects.Advices Namespace
IntroduceInterfaceAdviceInstanceOverrideAction


IntroduceInterfaceAdviceInstance.InterfaceType Property

IntroduceInterfaceAdviceInstanceInterfaceType Property
Gets the interface to be introduced into the target class.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type InterfaceType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IntroduceInterfaceAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceInterfaceAdviceInstance.MasterAspectMember Property

IntroduceInterfaceAdviceInstanceMasterAspectMember Property

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object MasterAspectMember { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IntroduceInterfaceAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceInterfaceAdviceInstance.OverrideAction Property

IntroduceInterfaceAdviceInstanceOverrideAction Property
Specifies the action (Fail or Ignore) to be overtaken when the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InterfaceOverrideAction OverrideAction { get; }

Property Value

Type: InterfaceOverrideAction
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IntroduceInterfaceAdviceInstance Class
PostSharp.Aspects.Advices Namespace
IntroduceInterfaceAdviceInstanceAncestorOverrideAction


IntroduceInterfaceAttribute Class

IntroduceInterfaceAttribute Class
Custom attribute that, when applied to an aspect class, specifies that the aspect should introduce a given interface into the type to which the aspect is applied.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesIntroduceInterfaceAttribute

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class IntroduceInterfaceAttribute : Advice,
    IIntroduceInterfaceAdviceProperties

The IntroduceInterfaceAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | IntroduceInterfaceAttribute | Initializes a new IntroduceInterfaceAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AncestorOverrideAction | Specifies the action (Fail or Ignore) to be overtaken when an ancestor of the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.
Public property | IsProtected | Obsolete. Determines whether the interface should be exposed indirectly through the IProtectedInterfaceT interface. If false, the interface will be implemented directly by the type.
Public property | OverrideAction | Specifies the action (Fail or Ignore) to be overtaken when the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.
Top
Remarks

The introduced interface will be implemented explicitly by the type to which the aspect is applied.

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace

Other Resources

Conceptual Documentation: Introducing Interfaces


IntroduceInterfaceAttribute Constructor

IntroduceInterfaceAttribute Constructor
Initializes a new IntroduceInterfaceAttribute.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IntroduceInterfaceAttribute(
    Type interfaceType
)

Parameters

interfaceType
Type: SystemType
Interface that should be introduced into the types to which the aspect is applied.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IntroduceInterfaceAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceInterfaceAttribute Methods

IntroduceInterfaceAttribute Methods

The IntroduceInterfaceAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

IntroduceInterfaceAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceInterfaceAttribute Properties

IntroduceInterfaceAttribute Properties

The IntroduceInterfaceAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AncestorOverrideAction | Specifies the action (Fail or Ignore) to be overtaken when an ancestor of the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.
Public property | IsProtected | Obsolete. Determines whether the interface should be exposed indirectly through the IProtectedInterfaceT interface. If false, the interface will be implemented directly by the type.
Public property | OverrideAction | Specifies the action (Fail or Ignore) to be overtaken when the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.
Top
See Also

Reference

IntroduceInterfaceAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceInterfaceAttribute.AncestorOverrideAction Property

IntroduceInterfaceAttributeAncestorOverrideAction Property
Specifies the action (Fail or Ignore) to be overtaken when an ancestor of the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InterfaceOverrideAction AncestorOverrideAction { get; set; }

Property Value

Type: InterfaceOverrideAction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IntroduceInterfaceAttribute Class
PostSharp.Aspects.Advices Namespace
IntroduceInterfaceAttributeOverrideAction


IntroduceInterfaceAttribute.IsProtected Property

IntroduceInterfaceAttributeIsProtected Property

Note: This API is now obsolete.

Determines whether the interface should be exposed indirectly through the IProtectedInterfaceT interface. If false, the interface will be implemented directly by the type.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("The IProtectedInterface mechanism is considered obsolete. Introduce and consume protected members instead.")]
public bool IsProtected { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 3.1
Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0

See Also

Reference

IntroduceInterfaceAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceInterfaceAttribute.OverrideAction Property

IntroduceInterfaceAttributeOverrideAction Property
Specifies the action (Fail or Ignore) to be overtaken when the interface specified in the constructor of this custom attribute is already implemented by the type to which the current aspect is applied.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InterfaceOverrideAction OverrideAction { get; set; }

Property Value

Type: InterfaceOverrideAction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IntroduceInterfaceAttribute Class
PostSharp.Aspects.Advices Namespace
IntroduceInterfaceAttributeAncestorOverrideAction


IntroduceMemberAdviceInstance Class

IntroduceMemberAdviceInstance Class
Base class for IntroduceMethodAdviceInstance.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.AdvicesAdviceInstance
PostSharp.Aspects.AdvicesIntroduceMemberAdviceInstance
PostSharp.Aspects.AdvicesIntroduceMethodAdviceInstance

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class IntroduceMemberAdviceInstance : AdviceInstance,
    IIntroduceMemberAdviceProperties

The IntroduceMemberAdviceInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsVirtual | Determines whether the introduced member should be virtual.
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to. (Inherited from AdviceInstance.)
Public property | OverrideAction | Determines the action to be overtaken when the member to be introduced already exists in the type to which the aspect is applied, or to a base type.
Public property | Visibility | Gets the visibility of the introduced member.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace


IntroduceMemberAdviceInstance Methods

IntroduceMemberAdviceInstance Methods

The IntroduceMemberAdviceInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

IntroduceMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAdviceInstance Properties

IntroduceMemberAdviceInstance Properties

The IntroduceMemberAdviceInstance type exposes the following members.

Properties
 | Name | Description
Public property | IsVirtual | Determines whether the introduced member should be virtual.
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to. (Inherited from AdviceInstance.)
Public property | OverrideAction | Determines the action to be overtaken when the member to be introduced already exists in the type to which the aspect is applied, or to a base type.
Public property | Visibility | Gets the visibility of the introduced member.
Top
See Also

Reference

IntroduceMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAdviceInstance.IsVirtual Property

IntroduceMemberAdviceInstanceIsVirtual Property
Determines whether the introduced member should be virtual.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<bool> IsVirtual { get; }

Property Value

Type: Nullable Boolean
Remarks

When this property is false and the member already exists in a base type and is virtual, the member is overridden and marked as sealed.

When this property is set to null, the introduced member is virtual if it exists in a base type as a virtual member, otherwise non-virtual.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

IntroduceMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAdviceInstance.OverrideAction Property

IntroduceMemberAdviceInstanceOverrideAction Property
Determines the action to be overtaken when the member to be introduced already exists in the type to which the aspect is applied, or to a base type.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MemberOverrideAction OverrideAction { get; }

Property Value

Type: MemberOverrideAction
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IntroduceMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAdviceInstance.Visibility Property

IntroduceMemberAdviceInstanceVisibility Property
Gets the visibility of the introduced member.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Visibility Visibility { get; }

Property Value

Type: Visibility
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IntroduceMemberAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAttribute Class

IntroduceMemberAttribute Class
Custom attribute that, when applied on a method, event or property of an aspect class, specifies that this method, event or property should be introduced into the types to which the aspect is applied.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesIntroduceMemberAttribute

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class IntroduceMemberAttribute : Advice,
    IIntroduceMemberAdviceProperties

The IntroduceMemberAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | IntroduceMemberAttribute | Initializes a new instance of the IntroduceMemberAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsIsVirtualSpecified | Determines whether the IsVirtual property has been specified.
Public property | IsVirtual | Determines whether the introduced member should be virtual.
Public property | OverrideAction | Determines the action to be overtaken when the member to be introduced already exists in the type to which the aspect is applied, or to a base type.
Public property | Visibility | Determines the visibility (Public, (Family, ...) of the introduced member.
Top
Remarks

Methods, properties and events annotated with IntroduceMemberAttribute must be public.

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesCopyCustomAttributesAttribute

Other Resources

Conceptual Documentation: Introducing, Overriding and Importing Members


IntroduceMemberAttribute Constructor

IntroduceMemberAttribute Constructor
Initializes a new instance of the IntroduceMemberAttribute class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IntroduceMemberAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IntroduceMemberAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAttribute Methods

IntroduceMemberAttribute Methods

The IntroduceMemberAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

IntroduceMemberAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAttribute Properties

IntroduceMemberAttribute Properties

The IntroduceMemberAttribute type exposes the following members.

Properties
 | Name | Description
Public property | IsIsVirtualSpecified | Determines whether the IsVirtual property has been specified.
Public property | IsVirtual | Determines whether the introduced member should be virtual.
Public property | OverrideAction | Determines the action to be overtaken when the member to be introduced already exists in the type to which the aspect is applied, or to a base type.
Public property | Visibility | Determines the visibility (Public, (Family, ...) of the introduced member.
Top
See Also

Reference

IntroduceMemberAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAttribute.IsIsVirtualSpecified Property

IntroduceMemberAttributeIsIsVirtualSpecified Property
Determines whether the IsVirtual property has been specified.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsIsVirtualSpecified { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IntroduceMemberAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAttribute.IsVirtual Property

IntroduceMemberAttributeIsVirtual Property
Determines whether the introduced member should be virtual.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsVirtual { get; set; }

Property Value

Type: Boolean
Remarks

When this property is false and the member already exists in a base type and is virtual, the member is overridden and marked as sealed.

When this property is not set, the introduced member is virtual if it exists in a base type as a virtual member, otherwise non-virtual.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IntroduceMemberAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAttribute.OverrideAction Property

IntroduceMemberAttributeOverrideAction Property
Determines the action to be overtaken when the member to be introduced already exists in the type to which the aspect is applied, or to a base type.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MemberOverrideAction OverrideAction { get; set; }

Property Value

Type: MemberOverrideAction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IntroduceMemberAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceMemberAttribute.Visibility Property

IntroduceMemberAttributeVisibility Property
Determines the visibility (Public, (Family, ...) of the introduced member.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Visibility Visibility { get; set; }

Property Value

Type: Visibility
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IntroduceMemberAttribute Class
PostSharp.Aspects.Advices Namespace


IntroduceMethodAdviceInstance Class

IntroduceMethodAdviceInstance Class
Represents an advice that introduces a method of the aspect class into the target class.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.AdvicesAdviceInstance
PostSharp.Aspects.AdvicesIntroduceMemberAdviceInstance
PostSharp.Aspects.AdvicesIntroduceMethodAdviceInstance

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class IntroduceMethodAdviceInstance : IntroduceMemberAdviceInstance

The IntroduceMethodAdviceInstance type exposes the following members.

Constructors
 | Name | Description
Public method | IntroduceMethodAdviceInstance | Initializes a new instance of the IntroduceMethodAdviceInstance class.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsVirtual | Determines whether the introduced member should be virtual. (Inherited from IntroduceMemberAdviceInstance.)
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to. (Overrides AdviceInstanceMasterAspectMember.)
Public property | OverrideAction | Determines the action to be overtaken when the member to be introduced already exists in the type to which the aspect is applied, or to a base type. (Inherited from IntroduceMemberAdviceInstance.)
Public property | Visibility | Gets the visibility of the introduced member. (Inherited from IntroduceMemberAdviceInstance.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesIAdviceProvider


IntroduceMethodAdviceInstance Constructor

IntroduceMethodAdviceInstance Constructor
Initializes a new instance of the IntroduceMethodAdviceInstance class.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IntroduceMethodAdviceInstance(
    MethodInfo method,
    Visibility visibility,
    Nullable<bool> isVirtual,
    MemberOverrideAction overrideAction
)

Parameters

method
Type: System.ReflectionMethodInfo
A public method of the aspect class.
visibility
Type: PostSharp.ReflectionVisibility
Visibility of the introduced method.
isVirtual
Type: SystemNullable Boolean
true if the introduced method should be virtual, false if it should be non-virtual (or sealed, if the method is overriding another one), or null if the method should be virtual only if the overridden method is also virtual. See IsVirtual for details.
overrideAction
Type: PostSharp.Aspects.AdvicesMemberOverrideAction
Determines the action to be overtaken when the member to be introduced already exists in the type to which the aspect is applied, or to a base type.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IntroduceMethodAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceMethodAdviceInstance Methods

IntroduceMethodAdviceInstance Methods

The IntroduceMethodAdviceInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

IntroduceMethodAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceMethodAdviceInstance Properties

IntroduceMethodAdviceInstance Properties

The IntroduceMethodAdviceInstance type exposes the following members.

Properties
 | Name | Description
Public property | IsVirtual | Determines whether the introduced member should be virtual. (Inherited from IntroduceMemberAdviceInstance.)
Public property | MasterAspectMember | Gets the main field or method of the aspect class that the current AdviceInstance relates to. (Overrides AdviceInstanceMasterAspectMember.)
Public property | OverrideAction | Determines the action to be overtaken when the member to be introduced already exists in the type to which the aspect is applied, or to a base type. (Inherited from IntroduceMemberAdviceInstance.)
Public property | Visibility | Gets the visibility of the introduced member. (Inherited from IntroduceMemberAdviceInstance.)
Top
See Also

Reference

IntroduceMethodAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IntroduceMethodAdviceInstance.MasterAspectMember Property

IntroduceMethodAdviceInstanceMasterAspectMember Property
Gets the main field or method of the aspect class that the current AdviceInstance relates to.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object MasterAspectMember { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IntroduceMethodAdviceInstance Class
PostSharp.Aspects.Advices Namespace


IProperty Interface

IProperty Interface
A weakly-typed interface for the class.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IProperty

The IProperty type exposes the following members.

Methods
 | Name | Description
Public method | GetValue | Gets the property value.
Public method | SetValue | Sets the property value.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesPropertyTValue


IProperty Methods

IProperty Methods

The IProperty type exposes the following members.

Methods
 | Name | Description
Public method | GetValue | Gets the property value.
Public method | SetValue | Sets the property value.
Top
See Also

Reference

IProperty Interface
PostSharp.Aspects.Advices Namespace


IProperty.GetValue Method

IPropertyGetValue Method
Gets the property value.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object GetValue()

Return Value

Type: Object
The property value.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IProperty Interface
PostSharp.Aspects.Advices Namespace


IProperty.SetValue Method

IPropertySetValue Method
Sets the property value.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void SetValue(
    Object value
)

Parameters

value
Type: SystemObject
The new property value.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IProperty Interface
PostSharp.Aspects.Advices Namespace


LocationValidationAdvice Class

LocationValidationAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method has the same semantic as the ValidateValue(T, String, LocationKind) method of the ILocationValidationAspectT interface.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesLocationValidationAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class LocationValidationAdvice : GroupingAdvice

The LocationValidationAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | LocationValidationAdvice | Initializes a new instance of the LocationValidationAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as ValidateValue(T, String, LocationKind), where T can be any type. However, the method can be static.

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsILocationValidationAspectT

Other Resources

Conceptual Documentation: Adding Behaviors to Members


LocationValidationAdvice Constructor

LocationValidationAdvice Constructor
Initializes a new instance of the LocationValidationAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LocationValidationAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationValidationAdvice Class
PostSharp.Aspects.Advices Namespace


LocationValidationAdvice Methods

LocationValidationAdvice Methods

The LocationValidationAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LocationValidationAdvice Class
PostSharp.Aspects.Advices Namespace


LocationValidationAdvice Properties

LocationValidationAdvice Properties

The LocationValidationAdvice type exposes the following members.

Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

LocationValidationAdvice Class
PostSharp.Aspects.Advices Namespace


MemberOverrideAction Enumeration

MemberOverrideAction Enumeration
Enumeration of actions to be overtaken by the IntroduceMemberAttribute aspect extension when the member to be introduced already exists in the aspect target type or its base type.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum MemberOverrideAction
Members
Member name | Value | Description
Default | 0 | Fail
Fail | 0 | Emits a build time error.
Ignore | 1 | Silently ignore the member introduction.
OverrideOrFail | 2 | Tries to override the member, and fails if it is impossible (i.e. if the existing member is defined in a base type and is sealed or non-virtual).
OverrideOrIgnore | 3 | Tries to override the member, and silently ignore if it is impossible (i.e. if the existing member is defined in a base type and is sealed or non-virtual).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace


MethodPointcut Class

MethodPointcut Class
Custom attribute that, when applied on an advice method, specifies the name of the method that will be invoked at build-time to return the set of elements of code to which the advice applies.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesPointcut
PostSharp.Aspects.AdvicesMethodPointcut

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class MethodPointcut : Pointcut

The MethodPointcut type exposes the following members.

Constructors
 | Name | Description
Public method | MethodPointcut | Initializes a new MethodPointcut.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | MethodName | Gets the name of the method returning the set of code elements.
Top
Remarks

This method should have the signature IEnumerable<AdviceTargetType> SelectCodeElements(AspectTargetType target) , where AspectTargetType is either object either a reflection type corresponding to the kind of targets of the aspect (for instance System.Type for a type-level aspect), and AdviceTargetType is either object either a reflection type of the kind of targets of the advice (for instance System.MethodInfo for a method-level advice).

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace

Other Resources

Conceptual Documentation: Adding Behaviors to Members


MethodPointcut Constructor

MethodPointcut Constructor
Initializes a new MethodPointcut.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MethodPointcut(
    string methodName
)

Parameters

methodName
Type: SystemString
Name of the method returning the set of targets. This method should have a specific signature as discussed in the class documentation.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodPointcut Class
PostSharp.Aspects.Advices Namespace


MethodPointcut Methods

MethodPointcut Methods

The MethodPointcut type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MethodPointcut Class
PostSharp.Aspects.Advices Namespace


MethodPointcut Properties

MethodPointcut Properties

The MethodPointcut type exposes the following members.

Properties
 | Name | Description
Public property | MethodName | Gets the name of the method returning the set of code elements.
Top
See Also

Reference

MethodPointcut Class
PostSharp.Aspects.Advices Namespace


MethodPointcut.MethodName Property

MethodPointcutMethodName Property
Gets the name of the method returning the set of code elements.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string MethodName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodPointcut Class
PostSharp.Aspects.Advices Namespace


MulticastPointcut Class

MulticastPointcut Class
Custom attribute that, when applied on an advice method, specifies to which elements of code this advice applies, based on the kind, name and attributes of code elements. Works similarly as MulticastAttribute.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesPointcut
PostSharp.Aspects.AdvicesMulticastPointcut

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class MulticastPointcut : Pointcut

The MulticastPointcut type exposes the following members.

Constructors
 | Name | Description
Public method | MulticastPointcut | Initializes a new instance of the MulticastPointcut class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Attributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies.
Public property | MemberName | Gets or sets the expression specifying to which members the aspect extension applies.
Public property | Targets | Gets or sets the kind of elements to which this aspect extension applies.
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace

Other Resources

Conceptual Documentation: Adding Behaviors to Members


MulticastPointcut Constructor

MulticastPointcut Constructor
Initializes a new instance of the MulticastPointcut class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastPointcut()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastPointcut Class
PostSharp.Aspects.Advices Namespace


MulticastPointcut Methods

MulticastPointcut Methods

The MulticastPointcut type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MulticastPointcut Class
PostSharp.Aspects.Advices Namespace


MulticastPointcut Properties

MulticastPointcut Properties

The MulticastPointcut type exposes the following members.

Properties
 | Name | Description
Public property | Attributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies.
Public property | MemberName | Gets or sets the expression specifying to which members the aspect extension applies.
Public property | Targets | Gets or sets the kind of elements to which this aspect extension applies.
Top
See Also

Reference

MulticastPointcut Class
PostSharp.Aspects.Advices Namespace


MulticastPointcut.Attributes Property

MulticastPointcutAttributes Property
Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes Attributes { get; set; }

Property Value

Type: MulticastAttributes
Remarks

The MulticastAttributes enumeration is a multi-part flag: there is one part for visibility, one for scope, one for virtuality, and one for implementation. If you specify one part, it will override the values defined on the custom attribute definition.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastPointcut Class
PostSharp.Aspects.Advices Namespace


MulticastPointcut.MemberName Property

MulticastPointcutMemberName Property
Gets or sets the expression specifying to which members the aspect extension applies.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string MemberName { get; set; }

Property Value

Type: String
A wildcard or regular expression specifying to which members this instance applies, or null this instance applies either to all members whose kind is given in Targets. Regular expressions should start with the regex: prefix.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastPointcut Class
PostSharp.Aspects.Advices Namespace


MulticastPointcut.Targets Property

MulticastPointcutTargets Property
Gets or sets the kind of elements to which this aspect extension applies.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastTargets Targets { get; set; }

Property Value

Type: MulticastTargets
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastPointcut Class
PostSharp.Aspects.Advices Namespace


OnEventAddHandlerAdvice Class

OnEventAddHandlerAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnAddHandler(EventInterceptionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnEventAddHandlerAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnEventAddHandlerAdvice : GroupingAdvice

The OnEventAddHandlerAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnEventAddHandlerAdvice | Initializes a new instance of the OnEventAddHandlerAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnAddHandler(EventInterceptionArgs). However, it can be static.

If an aspect defines many advices (among OnEventAddHandlerAdvice , OnEventRemoveHandlerAdvice and OnEventInvokeHandlerAdvice ) that are meant to be applied to the same events with consistent ordering, these advices should be grouped together (see Master property).

Note Note
Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut .

Note Note
Because of the way how the C# compiler implements automatic events (i.e. events where you don't implement the Add and Remove semantics manually), the Invoke Event Handler semantic ( OnInvokeHandler(EventInterceptionArgs) or equivalent) shall not be invoked for delegates that have been added from inside the class that declares this event.
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsIEventInterceptionAspect
PostSharp.Aspects.AdvicesOnEventAddHandlerAdvice
PostSharp.Aspects.AdvicesOnEventInvokeHandlerAdvice
PostSharp.AspectsEventInterceptionAspect
PostSharp.Aspects.AdvicesOnEventRemoveHandlerAdvice
PostSharp.Aspects.AdvicesOnEventInvokeHandlerAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnEventAddHandlerAdvice Constructor

OnEventAddHandlerAdvice Constructor
Initializes a new instance of the OnEventAddHandlerAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnEventAddHandlerAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnEventAddHandlerAdvice Class
PostSharp.Aspects.Advices Namespace


OnEventAddHandlerAdvice Methods

OnEventAddHandlerAdvice Methods

The OnEventAddHandlerAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnEventAddHandlerAdvice Class
PostSharp.Aspects.Advices Namespace


OnEventAddHandlerAdvice Properties

OnEventAddHandlerAdvice Properties

The OnEventAddHandlerAdvice type exposes the following members.

Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnEventAddHandlerAdvice Class
PostSharp.Aspects.Advices Namespace


OnEventInvokeHandlerAdvice Class

OnEventInvokeHandlerAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnInvokeHandler(EventInterceptionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnEventInvokeHandlerAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnEventInvokeHandlerAdvice : GroupingAdvice

The OnEventInvokeHandlerAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnEventInvokeHandlerAdvice | Initializes a new instance of the OnEventInvokeHandlerAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnInvokeHandler(EventInterceptionArgs). However, it can be static.

If an aspect defines many advices (among OnEventAddHandlerAdvice , OnEventRemoveHandlerAdvice and OnEventInvokeHandlerAdvice ) that are meant to be applied to the same events with consistent ordering, these advices should be grouped together (see Master property).

Note Note
Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut .

Note Note
Because of the way how the C# compiler implements automatic events (i.e. events where you don't implement the Add and Remove semantics manually), the Invoke Event Handler semantic ( OnInvokeHandler(EventInterceptionArgs) or equivalent) shall not be invoked for delegates that have been added from inside the class that declares this event.
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsIEventInterceptionAspect
PostSharp.Aspects.AdvicesOnEventAddHandlerAdvice
PostSharp.Aspects.AdvicesOnEventInvokeHandlerAdvice
PostSharp.AspectsEventInterceptionAspect
PostSharp.Aspects.AdvicesOnEventRemoveHandlerAdvice
PostSharp.Aspects.AdvicesOnEventAddHandlerAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnEventInvokeHandlerAdvice Constructor

OnEventInvokeHandlerAdvice Constructor
Initializes a new instance of the OnEventInvokeHandlerAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnEventInvokeHandlerAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnEventInvokeHandlerAdvice Class
PostSharp.Aspects.Advices Namespace


OnEventInvokeHandlerAdvice Methods

OnEventInvokeHandlerAdvice Methods

The OnEventInvokeHandlerAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnEventInvokeHandlerAdvice Class
PostSharp.Aspects.Advices Namespace


OnEventInvokeHandlerAdvice Properties

OnEventInvokeHandlerAdvice Properties

The OnEventInvokeHandlerAdvice type exposes the following members.

Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnEventInvokeHandlerAdvice Class
PostSharp.Aspects.Advices Namespace


OnEventRemoveHandlerAdvice Class

OnEventRemoveHandlerAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnRemoveHandler(EventInterceptionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnEventRemoveHandlerAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnEventRemoveHandlerAdvice : GroupingAdvice

The OnEventRemoveHandlerAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnEventRemoveHandlerAdvice | Initializes a new instance of the OnEventRemoveHandlerAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnRemoveHandler(EventInterceptionArgs). However, it can be static.

If an aspect defines many advices (among OnEventAddHandlerAdvice , OnEventRemoveHandlerAdvice and OnEventInvokeHandlerAdvice ) that are meant to be applied to the same events with consistent ordering, these advices should be grouped together (see Master property).

Note Note
Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut .

Note Note
Because of the way how the C# compiler implements automatic events (i.e. events where you don't implement the Add and Remove semantics manually), the Invoke Event Handler semantic ( OnInvokeHandler(EventInterceptionArgs) or equivalent) shall not be invoked for delegates that have been added from inside the class that declares this event.
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsIEventInterceptionAspect
PostSharp.Aspects.AdvicesOnEventAddHandlerAdvice
PostSharp.Aspects.AdvicesOnEventInvokeHandlerAdvice
PostSharp.AspectsEventInterceptionAspect
PostSharp.Aspects.AdvicesOnEventAddHandlerAdvice
PostSharp.Aspects.AdvicesOnEventInvokeHandlerAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnEventRemoveHandlerAdvice Constructor

OnEventRemoveHandlerAdvice Constructor
Initializes a new instance of the OnEventRemoveHandlerAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnEventRemoveHandlerAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnEventRemoveHandlerAdvice Class
PostSharp.Aspects.Advices Namespace


OnEventRemoveHandlerAdvice Methods

OnEventRemoveHandlerAdvice Methods

The OnEventRemoveHandlerAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnEventRemoveHandlerAdvice Class
PostSharp.Aspects.Advices Namespace


OnEventRemoveHandlerAdvice Properties

OnEventRemoveHandlerAdvice Properties

The OnEventRemoveHandlerAdvice type exposes the following members.

Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnEventRemoveHandlerAdvice Class
PostSharp.Aspects.Advices Namespace


OnInstanceConstructedAdvice Class

OnInstanceConstructedAdvice Class
Custom attribute that, when applied to a method of an aspect implementing , specifies that this method should be executed after the last instance constructor of the target class of the aspect has completed execution. That is, this method will be invoked when the target object will be fully constructed. This custom attribute can be applied only on methods that have void return type and accepts no parameter.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesOnInstanceConstructedAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnInstanceConstructedAdvice : Advice

The OnInstanceConstructedAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnInstanceConstructedAdvice | Initializes a new instance of the OnInstanceConstructedAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsIInstanceScopedAspect


OnInstanceConstructedAdvice Constructor

OnInstanceConstructedAdvice Constructor
Initializes a new instance of the OnInstanceConstructedAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnInstanceConstructedAdvice()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OnInstanceConstructedAdvice Class
PostSharp.Aspects.Advices Namespace


OnInstanceConstructedAdvice Methods

OnInstanceConstructedAdvice Methods

The OnInstanceConstructedAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnInstanceConstructedAdvice Class
PostSharp.Aspects.Advices Namespace


OnLocationGetValueAdvice Class

OnLocationGetValueAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnGetValue(LocationInterceptionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnLocationGetValueAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnLocationGetValueAdvice : GroupingAdvice

The OnLocationGetValueAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnLocationGetValueAdvice | Initializes a new instance of the OnLocationGetValueAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnGetValue(LocationInterceptionArgs). However, it can be static.

If an aspect defines many advices (among OnLocationSetValueAdvice, OnLocationGetValueAdvice) and if these advices are meant to be applied to the same properties with consistent ordering, they should be grouped together (see Master property).

Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut.

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsLocationLevelAspect
PostSharp.Aspects.AdvicesOnLocationSetValueAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnLocationGetValueAdvice Constructor

OnLocationGetValueAdvice Constructor
Initializes a new instance of the OnLocationGetValueAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnLocationGetValueAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnLocationGetValueAdvice Class
PostSharp.Aspects.Advices Namespace


OnLocationGetValueAdvice Methods

OnLocationGetValueAdvice Methods

The OnLocationGetValueAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnLocationGetValueAdvice Class
PostSharp.Aspects.Advices Namespace


OnLocationGetValueAdvice Properties

OnLocationGetValueAdvice Properties

The OnLocationGetValueAdvice type exposes the following members.

Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnLocationGetValueAdvice Class
PostSharp.Aspects.Advices Namespace


OnLocationSetValueAdvice Class

OnLocationSetValueAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnSetValue(LocationInterceptionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnLocationSetValueAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnLocationSetValueAdvice : GroupingAdvice

The OnLocationSetValueAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnLocationSetValueAdvice | Initializes a new instance of the OnLocationSetValueAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnSetValue(LocationInterceptionArgs). However, it can be static.

If an aspect defines many advices (among OnLocationSetValueAdvice, OnLocationGetValueAdvice) and if these advices are meant to be applied to the same properties with consistent ordering, they should be grouped together (see Master property).

Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut.

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsLocationLevelAspect
PostSharp.Aspects.AdvicesOnLocationGetValueAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnLocationSetValueAdvice Constructor

OnLocationSetValueAdvice Constructor
Initializes a new instance of the OnLocationSetValueAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnLocationSetValueAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnLocationSetValueAdvice Class
PostSharp.Aspects.Advices Namespace


OnLocationSetValueAdvice Methods

OnLocationSetValueAdvice Methods

The OnLocationSetValueAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnLocationSetValueAdvice Class
PostSharp.Aspects.Advices Namespace


OnLocationSetValueAdvice Properties

OnLocationSetValueAdvice Properties

The OnLocationSetValueAdvice type exposes the following members.

Properties
 | Name | Description
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnLocationSetValueAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodBoundaryAdvice Class

OnMethodBoundaryAdvice Class
Base class for OnMethodEntryAdvice, OnMethodExceptionAdvice, OnMethodSuccessAdvice or OnMethodExitAdvice.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnMethodBoundaryAdvice
More...

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class OnMethodBoundaryAdvice : GroupingAdvice

The OnMethodBoundaryAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines.
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnMethodBoundaryAdvice
PostSharp.Aspects.AdvicesOnMethodEntryAdvice
PostSharp.Aspects.AdvicesOnMethodExceptionAdvice
PostSharp.Aspects.AdvicesOnMethodExitAdvice
PostSharp.Aspects.AdvicesOnMethodResumeAdvice
PostSharp.Aspects.AdvicesOnMethodSuccessAdvice
PostSharp.Aspects.AdvicesOnMethodYieldAdvice


OnMethodBoundaryAdvice Methods

OnMethodBoundaryAdvice Methods

The OnMethodBoundaryAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodBoundaryAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodBoundaryAdvice Properties

OnMethodBoundaryAdvice Properties

The OnMethodBoundaryAdvice type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines.
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnMethodBoundaryAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodBoundaryAdvice.ApplyToStateMachine Property

OnMethodBoundaryAdviceApplyToStateMachine Property
Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool ApplyToStateMachine { get; set; }

Property Value

Type: Boolean
Remarks

For detailed documentation, see ApplyToStateMachine.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodEntryAdvice Class

OnMethodEntryAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnEntry(MethodExecutionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnMethodBoundaryAdvice
PostSharp.Aspects.AdvicesOnMethodEntryAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnMethodEntryAdvice : OnMethodBoundaryAdvice

The OnMethodEntryAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnMethodEntryAdvice | Initializes a new instance of the OnMethodEntryAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnEntry(MethodExecutionArgs). However, it can be static.

If an aspect defines many advices (among OnMethodEntryAdvice , OnMethodExitAdvice , OnMethodSuccessAdvice and OnMethodExceptionAdvice ) that are meant to be applied to the same methods with consistent ordering, these advices should be grouped together (see Master property).

Note Note
Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut .
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsOnMethodBoundaryAspect
PostSharp.Aspects.AdvicesOnMethodExitAdvice
PostSharp.Aspects.AdvicesOnMethodSuccessAdvice
PostSharp.Aspects.AdvicesOnMethodExceptionAdvice
PostSharp.Aspects.AdvicesOnMethodYieldAdvice
PostSharp.Aspects.AdvicesOnMethodResumeAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnMethodEntryAdvice Constructor

OnMethodEntryAdvice Constructor
Initializes a new instance of the OnMethodEntryAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnMethodEntryAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodEntryAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodEntryAdvice Methods

OnMethodEntryAdvice Methods

The OnMethodEntryAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodEntryAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodEntryAdvice Properties

OnMethodEntryAdvice Properties

The OnMethodEntryAdvice type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnMethodEntryAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodExceptionAdvice Class

OnMethodExceptionAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnException(MethodExecutionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnMethodBoundaryAdvice
PostSharp.Aspects.AdvicesOnMethodExceptionAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnMethodExceptionAdvice : OnMethodBoundaryAdvice

The OnMethodExceptionAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnMethodExceptionAdvice | Initializes a new instance of the OnMethodExceptionAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnException(MethodExecutionArgs). However, it can be static.

If an aspect defines many advices (among OnMethodEntryAdvice , OnMethodExitAdvice , OnMethodSuccessAdvice and OnMethodExceptionAdvice ) that are meant to be applied to the same methods with consistent ordering, these advices should be grouped together (see Master property).

Note Note
Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut .
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsOnMethodBoundaryAspect
PostSharp.Aspects.AdvicesOnMethodExitAdvice
PostSharp.Aspects.AdvicesOnMethodSuccessAdvice
PostSharp.Aspects.AdvicesOnMethodEntryAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnMethodExceptionAdvice Constructor

OnMethodExceptionAdvice Constructor
Initializes a new instance of the OnMethodExceptionAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnMethodExceptionAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodExceptionAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodExceptionAdvice Methods

OnMethodExceptionAdvice Methods

The OnMethodExceptionAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodExceptionAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodExceptionAdvice Properties

OnMethodExceptionAdvice Properties

The OnMethodExceptionAdvice type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnMethodExceptionAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodExitAdvice Class

OnMethodExitAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnExit(MethodExecutionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnMethodBoundaryAdvice
PostSharp.Aspects.AdvicesOnMethodExitAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnMethodExitAdvice : OnMethodBoundaryAdvice

The OnMethodExitAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnMethodExitAdvice | Initializes a new instance of the OnMethodExitAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnExit(MethodExecutionArgs). However, it can be static.

If an aspect defines many advices (among OnMethodEntryAdvice , OnMethodExitAdvice , OnMethodSuccessAdvice and OnMethodExceptionAdvice ) that are meant to be applied to the same methods with consistent ordering, these advices should be grouped together (see Master property).

Note Note
Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut .
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsOnMethodBoundaryAspect
PostSharp.Aspects.AdvicesOnMethodExceptionAdvice
PostSharp.Aspects.AdvicesOnMethodSuccessAdvice
PostSharp.Aspects.AdvicesOnMethodEntryAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnMethodExitAdvice Constructor

OnMethodExitAdvice Constructor
Initializes a new instance of the OnMethodExitAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnMethodExitAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodExitAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodExitAdvice Methods

OnMethodExitAdvice Methods

The OnMethodExitAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodExitAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodExitAdvice Properties

OnMethodExitAdvice Properties

The OnMethodExitAdvice type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnMethodExitAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodInvokeAdvice Class

OnMethodInvokeAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnInvoke(MethodInterceptionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesOnMethodInvokeAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnMethodInvokeAdvice : Advice

The OnMethodInvokeAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnMethodInvokeAdvice | Initializes a new instance of the OnMethodInvokeAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnInvoke(MethodInterceptionArgs). However, it can be static.

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsMethodInterceptionAspect

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnMethodInvokeAdvice Constructor

OnMethodInvokeAdvice Constructor
Initializes a new instance of the OnMethodInvokeAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnMethodInvokeAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodInvokeAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodInvokeAdvice Methods

OnMethodInvokeAdvice Methods

The OnMethodInvokeAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodInvokeAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodResumeAdvice Class

OnMethodResumeAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnResume(MethodExecutionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnMethodBoundaryAdvice
PostSharp.Aspects.AdvicesOnMethodResumeAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnMethodResumeAdvice : OnMethodBoundaryAdvice

The OnMethodResumeAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnMethodResumeAdvice | Initializes a new instance of the OnMethodResumeAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnResume(MethodExecutionArgs). However, it can be static.

If an aspect defines many advices (among OnMethodEntryAdvice , OnMethodExitAdvice , OnMethodSuccessAdvice and OnMethodExceptionAdvice ) that are meant to be applied to the same methods with consistent ordering, these advices should be grouped together (see Master property).

Note Note
Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut .
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesOnMethodEntryAdvice
PostSharp.AspectsOnMethodBoundaryAspect
PostSharp.Aspects.AdvicesOnMethodExitAdvice
PostSharp.Aspects.AdvicesOnMethodSuccessAdvice
PostSharp.Aspects.AdvicesOnMethodExceptionAdvice
PostSharp.Aspects.AdvicesOnMethodYieldAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnMethodResumeAdvice Constructor

OnMethodResumeAdvice Constructor
Initializes a new instance of the OnMethodResumeAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnMethodResumeAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodResumeAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodResumeAdvice Methods

OnMethodResumeAdvice Methods

The OnMethodResumeAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodResumeAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodResumeAdvice Properties

OnMethodResumeAdvice Properties

The OnMethodResumeAdvice type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnMethodResumeAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodSuccessAdvice Class

OnMethodSuccessAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnSuccess(MethodExecutionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnMethodBoundaryAdvice
PostSharp.Aspects.AdvicesOnMethodSuccessAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnMethodSuccessAdvice : OnMethodBoundaryAdvice

The OnMethodSuccessAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnMethodSuccessAdvice | Initializes a new instance of the OnMethodSuccessAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnSuccess(MethodExecutionArgs). However, it can be static.

If an aspect defines many advices (among OnMethodEntryAdvice , OnMethodExitAdvice , OnMethodSuccessAdvice and OnMethodExceptionAdvice ) that are meant to be applied to the same methods with consistent ordering, these advices should be grouped together (see Master property).

Note Note
Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut .
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsOnMethodBoundaryAspect
PostSharp.Aspects.AdvicesOnMethodExitAdvice
PostSharp.Aspects.AdvicesOnMethodExceptionAdvice
PostSharp.Aspects.AdvicesOnMethodEntryAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnMethodSuccessAdvice Constructor

OnMethodSuccessAdvice Constructor
Initializes a new instance of the OnMethodSuccessAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnMethodSuccessAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodSuccessAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodSuccessAdvice Methods

OnMethodSuccessAdvice Methods

The OnMethodSuccessAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodSuccessAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodSuccessAdvice Properties

OnMethodSuccessAdvice Properties

The OnMethodSuccessAdvice type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnMethodSuccessAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodYieldAdvice Class

OnMethodYieldAdvice Class
Custom attribute that, when applied on a method of an aspect class, specifies that this method is an advice having the same semantics as OnYield(MethodExecutionArgs).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesAdvice
PostSharp.Aspects.AdvicesGroupingAdvice
PostSharp.Aspects.AdvicesOnMethodBoundaryAdvice
PostSharp.Aspects.AdvicesOnMethodYieldAdvice

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnMethodYieldAdvice : OnMethodBoundaryAdvice

The OnMethodYieldAdvice type exposes the following members.

Constructors
 | Name | Description
Public method | OnMethodYieldAdvice | Initializes a new instance of the OnMethodYieldAdvice class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
Remarks

The method to which this custom attribute is applied must be public and must have the same signature as OnYield(MethodExecutionArgs). However, it can be static.

If an aspect defines many advices (among OnMethodEntryAdvice , OnMethodExitAdvice , OnMethodSuccessAdvice and OnMethodExceptionAdvice ) that are meant to be applied to the same methods with consistent ordering, these advices should be grouped together (see Master property).

Note Note
Standalone advices or group masters should also be annotated by a custom attribute derived from Pointcut .
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.AspectsOnMethodBoundaryAspect
PostSharp.Aspects.AdvicesOnMethodEntryAdvice
PostSharp.Aspects.AdvicesOnMethodExitAdvice
PostSharp.Aspects.AdvicesOnMethodSuccessAdvice
PostSharp.Aspects.AdvicesOnMethodExceptionAdvice
PostSharp.Aspects.AdvicesOnMethodResumeAdvice

Other Resources

Conceptual Documentation: Adding Behaviors to Members


OnMethodYieldAdvice Constructor

OnMethodYieldAdvice Constructor
Initializes a new instance of the OnMethodYieldAdvice class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnMethodYieldAdvice()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodYieldAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodYieldAdvice Methods

OnMethodYieldAdvice Methods

The OnMethodYieldAdvice type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodYieldAdvice Class
PostSharp.Aspects.Advices Namespace


OnMethodYieldAdvice Properties

OnMethodYieldAdvice Properties

The OnMethodYieldAdvice type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the advice should behave when it is applied to an iterator or async methods, which are compiled into state machines. (Inherited from OnMethodBoundaryAdvice.)
Public property | Master | Name of the master advice method. If this property is not set, the current method is itself the master of the group. Only master methods can define selectors (Pointcut) and dependencies (AspectDependencyAttribute). (Inherited from GroupingAdvice.)
Top
See Also

Reference

OnMethodYieldAdvice Class
PostSharp.Aspects.Advices Namespace


Pointcut Class

Pointcut Class
Custom attribute, typically accompanying an advice, specifying to which code elements the advice applies.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesPointcut
PostSharp.Aspects.AdvicesMethodPointcut
PostSharp.Aspects.AdvicesMulticastPointcut
PostSharp.Aspects.AdvicesSelfPointcut

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class Pointcut : Attribute

The Pointcut type exposes the following members.

Constructors
 | Name | Description
Protected method | Pointcut | Initializes a new instance of the Pointcut class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace

Other Resources

Conceptual Documentation: Adding Behaviors to Members


Pointcut Constructor

Pointcut Constructor
Initializes a new instance of the Pointcut class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected Pointcut()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Pointcut Class
PostSharp.Aspects.Advices Namespace


Pointcut Methods

Pointcut Methods

The Pointcut type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

Pointcut Class
PostSharp.Aspects.Advices Namespace


Property(TValue) Class

PropertyTValue Class
Exposes the semantics of a parameterless property for use with the ImportMemberAttribute aspect extension.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.AdvicesPropertyTValue

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class Property<TValue> : IProperty

Type Parameters

TValue
Property value type.

The PropertyTValue type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Get | Gets a delegate enabling to invoke the get accessor of the imported property.
Public property | Set | Gets a delegate enabling to invoke the set accessor of the imported property.
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesPropertyTValue, TIndex
PostSharp.Aspects.AdvicesPropertyGetterTValue
PostSharp.Aspects.AdvicesPropertySetterTValue
PostSharp.Aspects.AdvicesImportMemberAttribute

Other Resources

Conceptual Documentation: Introducing, Overriding and Importing Members


Property(TValue) Methods

PropertyTValue Methods

The PropertyTValue generic type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PropertyTValue Class
PostSharp.Aspects.Advices Namespace


Property(TValue) Properties

PropertyTValue Properties

The PropertyTValue generic type exposes the following members.

Properties
 | Name | Description
Public property | Get | Gets a delegate enabling to invoke the get accessor of the imported property.
Public property | Set | Gets a delegate enabling to invoke the set accessor of the imported property.
Top
See Also

Reference

PropertyTValue Class
PostSharp.Aspects.Advices Namespace


Property(TValue).Get Property

PropertyTValueGet Property
Gets a delegate enabling to invoke the get accessor of the imported property.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PropertyGetter<TValue> Get { get; }

Property Value

Type: PropertyGetter TValue
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PropertyTValue Class
PostSharp.Aspects.Advices Namespace


Property(TValue).Set Property

PropertyTValueSet Property
Gets a delegate enabling to invoke the set accessor of the imported property.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PropertySetter<TValue> Set { get; }

Property Value

Type: PropertySetter TValue
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PropertyTValue Class
PostSharp.Aspects.Advices Namespace


Property(TValue, TIndex) Class

PropertyTValue, TIndex Class
Mimics the semantics of a property accepting a single index parameter, for use with the ImportMemberAttribute aspect extension.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.AdvicesPropertyTValue, TIndex

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class Property<TValue, TIndex>

Type Parameters

TValue
Property value type.
TIndex
Property index type.

The PropertyTValue, TIndex type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Get | Gets a delegate enabling to invoke the get accessor of the imported property.
Public property | Set | Gets a delegate enabling to invoke the set accessor of the imported property.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesPropertyTValue
PostSharp.Aspects.AdvicesPropertyGetterTValue, TIndex
PostSharp.Aspects.AdvicesPropertySetterTValue, TIndex


Property(TValue, TIndex) Methods

PropertyTValue, TIndex Methods

The PropertyTValue, TIndex generic type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PropertyTValue, TIndex Class
PostSharp.Aspects.Advices Namespace


Property(TValue, TIndex) Properties

PropertyTValue, TIndex Properties

The PropertyTValue, TIndex generic type exposes the following members.

Properties
 | Name | Description
Public property | Get | Gets a delegate enabling to invoke the get accessor of the imported property.
Public property | Set | Gets a delegate enabling to invoke the set accessor of the imported property.
Top
See Also

Reference

PropertyTValue, TIndex Class
PostSharp.Aspects.Advices Namespace


Property(TValue, TIndex).Get Property

PropertyTValue, TIndexGet Property
Gets a delegate enabling to invoke the get accessor of the imported property.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PropertyGetter<TValue, TIndex> Get { get; }

Property Value

Type: PropertyGetter TValue, TIndex
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PropertyTValue, TIndex Class
PostSharp.Aspects.Advices Namespace


Property(TValue, TIndex).Set Property

PropertyTValue, TIndexSet Property
Gets a delegate enabling to invoke the set accessor of the imported property.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PropertySetter<TValue, TIndex> Set { get; }

Property Value

Type: PropertySetter TValue, TIndex
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PropertyTValue, TIndex Class
PostSharp.Aspects.Advices Namespace


PropertyGetter(TValue) Delegate

PropertyGetterTValue Delegate
Defines the signature of methods implementing the Get semantic of a parameterless property.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public delegate TValue PropertyGetter<TValue>()

Type Parameters

TValue
Property value type.

Return Value

Type: TValue
The property value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesPropertyTValue


PropertyGetter(TValue, TIndex) Delegate

PropertyGetterTValue, TIndex Delegate
Defines the signature of methods implementing the Get semantic of a property with a single index parameter.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public delegate TValue PropertyGetter<TValue, TIndex>(
    TIndex index
)

Parameters

index
Type: TIndex
Index.

Type Parameters

TValue
Property value type.
TIndex
Property index type.

Return Value

Type: TValue
The property value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesPropertyTValue, TIndex


PropertySetter(TValue) Delegate

PropertySetterTValue Delegate
Defines the signature of methods implementing the Set semantic of a parameterless property.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public delegate void PropertySetter<TValue>(
    TValue value
)

Parameters

value
Type: TValue
The property value.

Type Parameters

TValue
Property value type.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesPropertyTValue


PropertySetter(TValue, TIndex) Delegate

PropertySetterTValue, TIndex Delegate
Defines the signature of methods implementing the Set semantic of a property with a single index parameter.

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public delegate void PropertySetter<TValue, TIndex>(
    TIndex index,
    TValue value
)

Parameters

index
Type: TIndex
Index.
value
Type: TValue
The property value.

Type Parameters

TValue
Property value type.
TIndex
Property index type.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace
PostSharp.Aspects.AdvicesPropertyTValue, TIndex


SelfPointcut Class

SelfPointcut Class
Pointcut that selects exactly the aspect target.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.AdvicesPointcut
PostSharp.Aspects.AdvicesSelfPointcut

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class SelfPointcut : Pointcut

The SelfPointcut type exposes the following members.

Constructors
 | Name | Description
Public method | SelfPointcut | Initializes a new instance of the SelfPointcut class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Advices Namespace

Other Resources

Conceptual Documentation: Adding Behaviors to Members


SelfPointcut Constructor

SelfPointcut Constructor
Initializes a new instance of the SelfPointcut class

Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SelfPointcut()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SelfPointcut Class
PostSharp.Aspects.Advices Namespace


SelfPointcut Methods

SelfPointcut Methods

The SelfPointcut type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SelfPointcut Class
PostSharp.Aspects.Advices Namespace


PostSharp.Aspects.Configuration Namespace

PostSharp.Aspects.Configuration Namespace
The PostSharp.Aspects.Configuration namespace contains classes and custom attributes configuring the aspects of the PostSharp.Aspects namespace.
Classes
 | Class | Description
Public class | AspectConfiguration | Configuration of an IAspect.
Public class | AspectConfigurationAttribute | Configures an aspect of type IAspect.
Public class | AspectConfigurationAttributeTypeAttribute | Custom attribute that, when applied to an aspect, specifies which custom attribute type (derived from AspectConfigurationAttribute) can provide declarative configuration for the aspect.
Public class | CompositionAspectConfiguration | Configuration of aspects of type ICompositionAspect.
Public class | CompositionAspectConfigurationAttribute | Custom attribute that, when applied on a class implementing ICompositionAspect, defines the declarative configuration of that aspect.
Public class | CustomAttributeIntroductionAspectConfiguration | Configuration of aspects of type CustomAttributeIntroductionAspect.
Public class | EventInterceptionAspectConfiguration | Configuration of aspects of type IEventInterceptionAspect.
Public class | EventInterceptionAspectConfigurationAttribute | Custom attribute that, when applied on a class implementing IEventInterceptionAspect, defines the declarative configuration of that aspect.
Public class | ExternalAspectConfiguration | Configuration of aspects of type IExternalAspect.
Public class | LocationInterceptionAspectConfiguration | Configuration of aspects of type ILocationLevelAspect.
Public class | LocationInterceptionAspectConfigurationAttribute | Custom attribute that, when applied on a class implementing ILocationInterceptionAspect, defines the declarative configuration of that aspect.
Public class | ManagedResourceIntroductionAspectConfiguration | Configuration of aspects of type ManagedResourceIntroductionAspect.
Public class | MethodInterceptionAspectConfiguration | Configuration of aspects of type IMethodInterceptionAspect.
Public class | MethodInterceptionAspectConfigurationAttribute | Custom attribute that, when applied on a class implementing IMethodInterceptionAspect, defines the declarative configuration of that aspect.
Public class | OnExceptionAspectConfiguration | Configuration of the IOnExceptionAspect aspect.
Public class | OnExceptionAspectConfigurationAttribute | Custom attribute that, when applied on a class implementing IOnExceptionAspect, defines the configuration of that aspect.
Public class | OnMethodBoundaryAspectConfiguration | Configuration of the IOnMethodBoundaryAspect aspect.
Public class | OnMethodBoundaryAspectConfigurationAttribute | Custom attribute that, when applied on a class implementing IOnMethodBoundaryAspect, defines the configuration of that aspect.
Interfaces
 | Interface | Description
Public interface | IProfileAwareConfiguration | Allows an AspectConfiguration to depend on a profile, i.e. an external piece of configuration stored as a resource in the project file. Classes derived from AspectConfiguration may implement this interface.


AspectConfiguration Class

AspectConfiguration Class
Configuration of an IAspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
More...

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class AspectConfiguration

The AspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | AspectConfiguration | Initializes a new instance of the AspectConfiguration class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero.
Public property | Dependencies | Gets or sets the collection of dependencies.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect.
Top
Remarks
Every concrete aspect class has a corresponding configuration class derived from AspectConfiguration.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace

Other Resources

Conceptual Documentation: Configuring Aspects
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Aspects.ConfigurationCompositionAspectConfiguration
PostSharp.Aspects.ConfigurationCustomAttributeIntroductionAspectConfiguration
PostSharp.Aspects.ConfigurationEventInterceptionAspectConfiguration
PostSharp.Aspects.ConfigurationExternalAspectConfiguration
PostSharp.Aspects.ConfigurationLocationInterceptionAspectConfiguration
PostSharp.Aspects.ConfigurationManagedResourceIntroductionAspectConfiguration
PostSharp.Aspects.ConfigurationMethodInterceptionAspectConfiguration
PostSharp.Aspects.ConfigurationOnExceptionAspectConfiguration
PostSharp.Aspects.ConfigurationOnMethodBoundaryAspectConfiguration
PostSharp.Patterns.DiagnosticsLogAspectConfiguration


AspectConfiguration Constructor

AspectConfiguration Constructor
Initializes a new instance of the AspectConfiguration class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectConfiguration()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


AspectConfiguration Methods

AspectConfiguration Methods

The AspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


AspectConfiguration Properties

AspectConfiguration Properties

The AspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero.
Public property | Dependencies | Gets or sets the collection of dependencies.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect.
Top
See Also

Reference

AspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


AspectConfiguration.AspectPriority Property

AspectConfigurationAspectPriority Property
Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<int> AspectPriority { get; set; }

Property Value

Type: Nullable Int32
Remarks
Whenever possible, use dependencies (Dependencies collection) to specify the ordering of aspects. Unlike priorities, dependencies scale up in complexity, which can be important in larger projects.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


AspectConfiguration.Dependencies Property

AspectConfigurationDependencies Property
Gets or sets the collection of dependencies.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectDependencyAttributeCollection Dependencies { get; set; }

Property Value

Type: AspectDependencyAttributeCollection
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


AspectConfiguration.SerializerType Property

AspectConfigurationSerializerType Property
Gets or sets the type of the serializer that will be used to configure the current aspect.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public TypeIdentity SerializerType { get; set; }

Property Value

Type: TypeIdentity
Remarks
This type should have derive from AspectSerializer and have a default constructor. Use null to specify that the aspect will not be serialized, but will be constructed using MSIL instructions.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttribute Class

AspectConfigurationAttribute Class
Configures an aspect of type IAspect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.ConfigurationAspectConfigurationAttribute
More...

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class AspectConfigurationAttribute : Attribute

The AspectConfigurationAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | AspectConfigurationAttribute | Initializes a new instance of the AspectConfigurationAttribute class
Top
Methods
 | Name | Description
Protected method | CreateAspectConfiguration | Creates a concrete AspectConfiguration instance specifically for the current AspectConfigurationAttribute type.
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute.
Protected method | SetAspectConfiguration | Sets up an AspectConfiguration object according to the current custom attribute instance.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect.
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace

Other Resources

Conceptual Documentation: Configuring Aspects
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.ConfigurationAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationCompositionAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationEventInterceptionAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationLocationInterceptionAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationMethodInterceptionAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationOnExceptionAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationOnMethodBoundaryAspectConfigurationAttribute
PostSharp.Patterns.DiagnosticsLogAspectConfigurationAttribute


AspectConfigurationAttribute Constructor

AspectConfigurationAttribute Constructor
Initializes a new instance of the AspectConfigurationAttribute class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectConfigurationAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttribute Methods

AspectConfigurationAttribute Methods

The AspectConfigurationAttribute type exposes the following members.

Methods
 | Name | Description
Protected method | CreateAspectConfiguration | Creates a concrete AspectConfiguration instance specifically for the current AspectConfigurationAttribute type.
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute.
Protected method | SetAspectConfiguration | Sets up an AspectConfiguration object according to the current custom attribute instance.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttribute.CreateAspectConfiguration Method

AspectConfigurationAttributeCreateAspectConfiguration Method
Creates a concrete AspectConfiguration instance specifically for the current AspectConfigurationAttribute type.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the AspectConfigurationAttribute.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttribute.GetAspectConfiguration Method

AspectConfigurationAttributeGetAspectConfiguration Method
Gets the AspectConfiguration corresponding to the current custom attribute.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectConfiguration GetAspectConfiguration()

Return Value

Type: AspectConfiguration
An AspectConfiguration corresponding to the current custom attribute.
Remarks

This method can be customized by overriding CreateAspectConfiguration and/or SetAspectConfiguration(AspectConfiguration)

.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttribute.SetAspectConfiguration Method

AspectConfigurationAttributeSetAspectConfiguration Method
Sets up an AspectConfiguration object according to the current custom attribute instance.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void SetAspectConfiguration(
    AspectConfiguration aspectConfiguration
)

Parameters

aspectConfiguration
Type: PostSharp.Aspects.ConfigurationAspectConfiguration
The AspectConfiguration instance previously returned by the CreateAspectConfiguration method.
Remarks

Classes overriding this method must always invoke the base implementation before performing their own changes to the AspectConfiguration.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttribute Properties

AspectConfigurationAttribute Properties

The AspectConfigurationAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect.
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect.
Top
See Also

Reference

AspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttribute.AspectPriority Property

AspectConfigurationAttributeAspectPriority Property
Gets or sets the weaving priority of the aspect.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int AspectPriority { get; set; }

Property Value

Type: Int32
The aspect priority, or null if the aspect priority is not specified.
Remarks

Advices with lower priority are executed before in case of 'entry' semantics (entering or invoking a method, setting a field value), but this order is inverted for advices of 'exit' semantics (leaving a method, getting a field value).

This property must not be confused with AttributePriority, which solely influences the multicasting process.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttribute.SerializerType Property

AspectConfigurationAttributeSerializerType Property
Gets or sets the Type of the serializer that will be used to configure the current aspect.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type SerializerType { get; set; }

Property Value

Type: Type
Remarks

This type should have derive from AspectSerializer and have a default constructor. Use null to specify that the aspect will not be serialized, but will be constructed using MSIL instructions.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttributeTypeAttribute Class

AspectConfigurationAttributeTypeAttribute Class
Custom attribute that, when applied to an aspect, specifies which custom attribute type (derived from AspectConfigurationAttribute) can provide declarative configuration for the aspect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.ConfigurationAspectConfigurationAttributeTypeAttribute

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AspectConfigurationAttributeTypeAttribute : Attribute

The AspectConfigurationAttributeTypeAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | AspectConfigurationAttributeTypeAttribute | Initializes a new AspectConfigurationAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttributeTypeAttribute Constructor

AspectConfigurationAttributeTypeAttribute Constructor
Initializes a new AspectConfigurationAttribute.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectConfigurationAttributeTypeAttribute(
    Type type
)

Parameters

type
Type: SystemType
Custom attribute type (derived from AspectConfigurationAttribute).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectConfigurationAttributeTypeAttribute Class
PostSharp.Aspects.Configuration Namespace


AspectConfigurationAttributeTypeAttribute Methods

AspectConfigurationAttributeTypeAttribute Methods

The AspectConfigurationAttributeTypeAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectConfigurationAttributeTypeAttribute Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfiguration Class

CompositionAspectConfiguration Class
Configuration of aspects of type ICompositionAspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Aspects.ConfigurationCompositionAspectConfiguration

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class CompositionAspectConfiguration : AspectConfiguration

The CompositionAspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | CompositionAspectConfiguration | Initializes a new instance of the CompositionAspectConfiguration class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AncestorOverrideAction | Specifies the action (Fail or Ignore) to be overtaken when an ancestor of one of the interfaces specified by PublicInterfaces is already implemented by the type to which the current aspect is applied.
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | GenerateImplementationAccessor | Determines whether the interface IComposedT should be introduced into the type to which the aspect is applied for each interface specified by the PublicInterfaces property.
Public property | NonSerializedImplementation | Determines whether the field containing the interface implementation (and storing the object returned by CreateImplementationObject(AdviceArgs)) should be excluded from serialization by BinaryFormatter. The same effect is typically obtained by applying the NonSerializedAttribute custom attribute to the field.
Public property | OverrideAction | Specifies the action (Fail or Ignore) to be overtaken when one of the interfaces specified by PublicInterfaces or ProtectedInterfaces is already implemented by the type to which the aspect is applied.
Public property | ProtectedInterfaces | Gets or sets the array of interfaces to be introduced indirectly into the target type of the aspect. These interfaces will become accessible through the IProtectedInterfaceT interface.
Public property | PublicInterfaces | Gets or sets the array of interfaces that should be introduced publicly into the target type of the aspect.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.Aspects.ConfigurationCompositionAspectConfigurationAttribute

Other Resources

Conceptual Documentation: Configuring Aspects


CompositionAspectConfiguration Constructor

CompositionAspectConfiguration Constructor
Initializes a new instance of the CompositionAspectConfiguration class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public CompositionAspectConfiguration()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfiguration Methods

CompositionAspectConfiguration Methods

The CompositionAspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CompositionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfiguration Properties

CompositionAspectConfiguration Properties

The CompositionAspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | AncestorOverrideAction | Specifies the action (Fail or Ignore) to be overtaken when an ancestor of one of the interfaces specified by PublicInterfaces is already implemented by the type to which the current aspect is applied.
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | GenerateImplementationAccessor | Determines whether the interface IComposedT should be introduced into the type to which the aspect is applied for each interface specified by the PublicInterfaces property.
Public property | NonSerializedImplementation | Determines whether the field containing the interface implementation (and storing the object returned by CreateImplementationObject(AdviceArgs)) should be excluded from serialization by BinaryFormatter. The same effect is typically obtained by applying the NonSerializedAttribute custom attribute to the field.
Public property | OverrideAction | Specifies the action (Fail or Ignore) to be overtaken when one of the interfaces specified by PublicInterfaces or ProtectedInterfaces is already implemented by the type to which the aspect is applied.
Public property | ProtectedInterfaces | Gets or sets the array of interfaces to be introduced indirectly into the target type of the aspect. These interfaces will become accessible through the IProtectedInterfaceT interface.
Public property | PublicInterfaces | Gets or sets the array of interfaces that should be introduced publicly into the target type of the aspect.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
See Also

Reference

CompositionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfiguration.AncestorOverrideAction Property

CompositionAspectConfigurationAncestorOverrideAction Property
Specifies the action (Fail or Ignore) to be overtaken when an ancestor of one of the interfaces specified by PublicInterfaces is already implemented by the type to which the current aspect is applied.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<InterfaceOverrideAction> AncestorOverrideAction { get; set; }

Property Value

Type: Nullable InterfaceOverrideAction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace
CompositionAspectConfigurationOverrideAction


CompositionAspectConfiguration.GenerateImplementationAccessor Property

CompositionAspectConfigurationGenerateImplementationAccessor Property
Determines whether the interface IComposedT should be introduced into the type to which the aspect is applied for each interface specified by the PublicInterfaces property.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<bool> GenerateImplementationAccessor { get; set; }

Property Value

Type: Nullable Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfiguration.NonSerializedImplementation Property

CompositionAspectConfigurationNonSerializedImplementation Property
Determines whether the field containing the interface implementation (and storing the object returned by CreateImplementationObject(AdviceArgs)) should be excluded from serialization by BinaryFormatter. The same effect is typically obtained by applying the NonSerializedAttribute custom attribute to the field.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<bool> NonSerializedImplementation { get; set; }

Property Value

Type: Nullable Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfiguration.OverrideAction Property

CompositionAspectConfigurationOverrideAction Property
Specifies the action (Fail or Ignore) to be overtaken when one of the interfaces specified by PublicInterfaces or ProtectedInterfaces is already implemented by the type to which the aspect is applied.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<InterfaceOverrideAction> OverrideAction { get; set; }

Property Value

Type: Nullable InterfaceOverrideAction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace
CompositionAspectConfigurationAncestorOverrideAction


CompositionAspectConfiguration.ProtectedInterfaces Property

CompositionAspectConfigurationProtectedInterfaces Property
Gets or sets the array of interfaces to be introduced indirectly into the target type of the aspect. These interfaces will become accessible through the IProtectedInterfaceT interface.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public TypeIdentity[] ProtectedInterfaces { get; set; }

Property Value

Type: TypeIdentity
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfiguration.PublicInterfaces Property

CompositionAspectConfigurationPublicInterfaces Property
Gets or sets the array of interfaces that should be introduced publicly into the target type of the aspect.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public TypeIdentity[] PublicInterfaces { get; set; }

Property Value

Type: TypeIdentity
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfigurationAttribute Class

CompositionAspectConfigurationAttribute Class
Custom attribute that, when applied on a class implementing ICompositionAspect, defines the declarative configuration of that aspect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.ConfigurationAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationCompositionAspectConfigurationAttribute

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class CompositionAspectConfigurationAttribute : AspectConfigurationAttribute

The CompositionAspectConfigurationAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | CompositionAspectConfigurationAttribute | Initializes a new instance of the CompositionAspectConfigurationAttribute class
Top
Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AncestorOverrideAction | Specifies the action (Fail or Ignore) to be overtaken when an ancestor of one of the interfaces specified by PublicInterfaces is already implemented by the type to which the current aspect is applied.
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | GenerateImplementationAccessor | Determines whether the interface IComposedT should be introduced into the type to which the aspect is applied for each interface specified by the PublicInterfaces property.
Public property | NonSerializedImplementation | Determines whether the field containing the interface implementation (and storing the object returned by CreateImplementationObject(AdviceArgs)) should be excluded from serialization by BinaryFormatter. The same effect is typically obtained by applying the NonSerializedAttribute custom attribute to the field.
Public property | OverrideAction | Specifies the action (Fail or Ignore) to be overtaken when one of the interfaces specified by PublicInterfaces or ProtectedInterfaces is already implemented by the type to which the aspect is applied.
Public property | ProtectedInterfaces | Gets or sets the array of type names of interfaces to be introduced indirectly into the target type of the aspect. These interfaces will become accessible through the IProtectedInterfaceT interface.
Public property | PublicInterfaces | Gets or sets the array of type names of interfaces that should be introduced publicly into the target type of the aspect.
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.Aspects.ConfigurationAspectConfigurationAttribute
PostSharp.AspectsCompositionAspect

Other Resources

Conceptual Documentation: Configuring Aspects


CompositionAspectConfigurationAttribute Constructor

CompositionAspectConfigurationAttribute Constructor
Initializes a new instance of the CompositionAspectConfigurationAttribute class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public CompositionAspectConfigurationAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfigurationAttribute Methods

CompositionAspectConfigurationAttribute Methods

The CompositionAspectConfigurationAttribute type exposes the following members.

Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CompositionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfigurationAttribute Properties

CompositionAspectConfigurationAttribute Properties

The CompositionAspectConfigurationAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AncestorOverrideAction | Specifies the action (Fail or Ignore) to be overtaken when an ancestor of one of the interfaces specified by PublicInterfaces is already implemented by the type to which the current aspect is applied.
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | GenerateImplementationAccessor | Determines whether the interface IComposedT should be introduced into the type to which the aspect is applied for each interface specified by the PublicInterfaces property.
Public property | NonSerializedImplementation | Determines whether the field containing the interface implementation (and storing the object returned by CreateImplementationObject(AdviceArgs)) should be excluded from serialization by BinaryFormatter. The same effect is typically obtained by applying the NonSerializedAttribute custom attribute to the field.
Public property | OverrideAction | Specifies the action (Fail or Ignore) to be overtaken when one of the interfaces specified by PublicInterfaces or ProtectedInterfaces is already implemented by the type to which the aspect is applied.
Public property | ProtectedInterfaces | Gets or sets the array of type names of interfaces to be introduced indirectly into the target type of the aspect. These interfaces will become accessible through the IProtectedInterfaceT interface.
Public property | PublicInterfaces | Gets or sets the array of type names of interfaces that should be introduced publicly into the target type of the aspect.
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
See Also

Reference

CompositionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfigurationAttribute.AncestorOverrideAction Property

CompositionAspectConfigurationAttributeAncestorOverrideAction Property
Specifies the action (Fail or Ignore) to be overtaken when an ancestor of one of the interfaces specified by PublicInterfaces is already implemented by the type to which the current aspect is applied.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InterfaceOverrideAction AncestorOverrideAction { get; set; }

Property Value

Type: InterfaceOverrideAction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace
CompositionAspectConfigurationAttributeOverrideAction


CompositionAspectConfigurationAttribute.GenerateImplementationAccessor Property

CompositionAspectConfigurationAttributeGenerateImplementationAccessor Property
Determines whether the interface IComposedT should be introduced into the type to which the aspect is applied for each interface specified by the PublicInterfaces property.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool GenerateImplementationAccessor { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfigurationAttribute.NonSerializedImplementation Property

CompositionAspectConfigurationAttributeNonSerializedImplementation Property
Determines whether the field containing the interface implementation (and storing the object returned by CreateImplementationObject(AdviceArgs)) should be excluded from serialization by BinaryFormatter. The same effect is typically obtained by applying the NonSerializedAttribute custom attribute to the field.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool NonSerializedImplementation { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfigurationAttribute.OverrideAction Property

CompositionAspectConfigurationAttributeOverrideAction Property
Specifies the action (Fail or Ignore) to be overtaken when one of the interfaces specified by PublicInterfaces or ProtectedInterfaces is already implemented by the type to which the aspect is applied.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InterfaceOverrideAction OverrideAction { get; set; }

Property Value

Type: InterfaceOverrideAction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace
CompositionAspectConfigurationAttributeAncestorOverrideAction


CompositionAspectConfigurationAttribute.ProtectedInterfaces Property

CompositionAspectConfigurationAttributeProtectedInterfaces Property
Gets or sets the array of type names of interfaces to be introduced indirectly into the target type of the aspect. These interfaces will become accessible through the IProtectedInterfaceT interface.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string[] ProtectedInterfaces { get; set; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


CompositionAspectConfigurationAttribute.PublicInterfaces Property

CompositionAspectConfigurationAttributePublicInterfaces Property
Gets or sets the array of type names of interfaces that should be introduced publicly into the target type of the aspect.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string[] PublicInterfaces { get; set; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompositionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


CustomAttributeIntroductionAspectConfiguration Class

CustomAttributeIntroductionAspectConfiguration Class
Configuration of aspects of type CustomAttributeIntroductionAspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Aspects.ConfigurationCustomAttributeIntroductionAspectConfiguration

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class CustomAttributeIntroductionAspectConfiguration : AspectConfiguration

The CustomAttributeIntroductionAspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | CustomAttributeIntroductionAspectConfiguration | Initializes a new instance of the CustomAttributeIntroductionAspectConfiguration class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | ObjectConstruction | Gets or sets the construction of the custom attribute that must be applied to the target of this aspect.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


CustomAttributeIntroductionAspectConfiguration Constructor

CustomAttributeIntroductionAspectConfiguration Constructor
Initializes a new instance of the CustomAttributeIntroductionAspectConfiguration class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public CustomAttributeIntroductionAspectConfiguration()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomAttributeIntroductionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


CustomAttributeIntroductionAspectConfiguration Methods

CustomAttributeIntroductionAspectConfiguration Methods

The CustomAttributeIntroductionAspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CustomAttributeIntroductionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


CustomAttributeIntroductionAspectConfiguration Properties

CustomAttributeIntroductionAspectConfiguration Properties

The CustomAttributeIntroductionAspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | ObjectConstruction | Gets or sets the construction of the custom attribute that must be applied to the target of this aspect.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
See Also

Reference

CustomAttributeIntroductionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


CustomAttributeIntroductionAspectConfiguration.ObjectConstruction Property

CustomAttributeIntroductionAspectConfigurationObjectConstruction Property
Gets or sets the construction of the custom attribute that must be applied to the target of this aspect.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectConstruction ObjectConstruction { get; set; }

Property Value

Type: ObjectConstruction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomAttributeIntroductionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


EventInterceptionAspectConfiguration Class

EventInterceptionAspectConfiguration Class
Configuration of aspects of type IEventInterceptionAspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Aspects.ConfigurationEventInterceptionAspectConfiguration

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class EventInterceptionAspectConfiguration : AspectConfiguration

The EventInterceptionAspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | EventInterceptionAspectConfiguration | Initializes a new instance of the EventInterceptionAspectConfiguration class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.Aspects.ConfigurationEventInterceptionAspectConfigurationAttribute

Other Resources

Conceptual Documentation: Configuring Aspects


EventInterceptionAspectConfiguration Constructor

EventInterceptionAspectConfiguration Constructor
Initializes a new instance of the EventInterceptionAspectConfiguration class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EventInterceptionAspectConfiguration()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


EventInterceptionAspectConfiguration Methods

EventInterceptionAspectConfiguration Methods

The EventInterceptionAspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EventInterceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


EventInterceptionAspectConfiguration Properties

EventInterceptionAspectConfiguration Properties

The EventInterceptionAspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
See Also

Reference

EventInterceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


EventInterceptionAspectConfigurationAttribute Class

EventInterceptionAspectConfigurationAttribute Class
Custom attribute that, when applied on a class implementing IEventInterceptionAspect, defines the declarative configuration of that aspect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.ConfigurationAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationEventInterceptionAspectConfigurationAttribute

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class EventInterceptionAspectConfigurationAttribute : AspectConfigurationAttribute

The EventInterceptionAspectConfigurationAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | EventInterceptionAspectConfigurationAttribute | Initializes a new instance of the EventInterceptionAspectConfigurationAttribute class
Top
Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.Aspects.ConfigurationEventInterceptionAspectConfiguration
PostSharp.AspectsEventInterceptionAspect

Other Resources

Conceptual Documentation: Configuring Aspects


EventInterceptionAspectConfigurationAttribute Constructor

EventInterceptionAspectConfigurationAttribute Constructor
Initializes a new instance of the EventInterceptionAspectConfigurationAttribute class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EventInterceptionAspectConfigurationAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EventInterceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


EventInterceptionAspectConfigurationAttribute Methods

EventInterceptionAspectConfigurationAttribute Methods

The EventInterceptionAspectConfigurationAttribute type exposes the following members.

Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EventInterceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


EventInterceptionAspectConfigurationAttribute Properties

EventInterceptionAspectConfigurationAttribute Properties

The EventInterceptionAspectConfigurationAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
See Also

Reference

EventInterceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


ExternalAspectConfiguration Class

ExternalAspectConfiguration Class
Configuration of aspects of type IExternalAspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Aspects.ConfigurationExternalAspectConfiguration

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ExternalAspectConfiguration : AspectConfiguration

The ExternalAspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | ExternalAspectConfiguration | Initializes a new instance of the ExternalAspectConfiguration class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | ImplementationTypeName | Gets or sets the type implementing the aspect. This type must implement the interface IExternalAspectImplementation.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace

Other Resources

Conceptual Documentation: Configuring Aspects
Conceptual Documentation: Using PostSharp with Silverlight, Windows Phone, and the Compact .NET Framework


ExternalAspectConfiguration Constructor

ExternalAspectConfiguration Constructor
Initializes a new instance of the ExternalAspectConfiguration class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ExternalAspectConfiguration()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ExternalAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


ExternalAspectConfiguration Methods

ExternalAspectConfiguration Methods

The ExternalAspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ExternalAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


ExternalAspectConfiguration Properties

ExternalAspectConfiguration Properties

The ExternalAspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | ImplementationTypeName | Gets or sets the type implementing the aspect. This type must implement the interface IExternalAspectImplementation.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
See Also

Reference

ExternalAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


ExternalAspectConfiguration.ImplementationTypeName Property

ExternalAspectConfigurationImplementationTypeName Property
Gets or sets the type implementing the aspect. This type must implement the interface IExternalAspectImplementation.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public TypeIdentity ImplementationTypeName { get; set; }

Property Value

Type: TypeIdentity
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ExternalAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


IProfileAwareConfiguration Interface

IProfileAwareConfiguration Interface
Allows an AspectConfiguration to depend on a profile, i.e. an external piece of configuration stored as a resource in the project file. Classes derived from AspectConfiguration may implement this interface.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IProfileAwareConfiguration

The IProfileAwareConfiguration type exposes the following members.

Methods
 | Name | Description
Public method | ApplyProfile | Applies the profile to the current configuration object.
Top
Properties
 | Name | Description
Public property | ProfileName | Gets the name of the profile, i.e. the name of the resource representing the profile.
Public property | ProfileSectionName | Gets the name of the project section in which the profile resource is stored.
Public property | ProfileSectionNamespace | Gets the namespace of the project section in which the profile resource is stored.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace


IProfileAwareConfiguration Methods

IProfileAwareConfiguration Methods

The IProfileAwareConfiguration type exposes the following members.

Methods
 | Name | Description
Public method | ApplyProfile | Applies the profile to the current configuration object.
Top
See Also

Reference

IProfileAwareConfiguration Interface
PostSharp.Aspects.Configuration Namespace


IProfileAwareConfiguration.ApplyProfile Method

IProfileAwareConfigurationApplyProfile Method
Applies the profile to the current configuration object.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void ApplyProfile(
    Object profile
)

Parameters

profile
Type: SystemObject
The profile object, represented by the resource named ProfileName in section named ProfileSectionName, with namespace ProfileSectionNamespace.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IProfileAwareConfiguration Interface
PostSharp.Aspects.Configuration Namespace


IProfileAwareConfiguration Properties

IProfileAwareConfiguration Properties

The IProfileAwareConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | ProfileName | Gets the name of the profile, i.e. the name of the resource representing the profile.
Public property | ProfileSectionName | Gets the name of the project section in which the profile resource is stored.
Public property | ProfileSectionNamespace | Gets the namespace of the project section in which the profile resource is stored.
Top
See Also

Reference

IProfileAwareConfiguration Interface
PostSharp.Aspects.Configuration Namespace


IProfileAwareConfiguration.ProfileName Property

IProfileAwareConfigurationProfileName Property
Gets the name of the profile, i.e. the name of the resource representing the profile.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string ProfileName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IProfileAwareConfiguration Interface
PostSharp.Aspects.Configuration Namespace


IProfileAwareConfiguration.ProfileSectionName Property

IProfileAwareConfigurationProfileSectionName Property
Gets the name of the project section in which the profile resource is stored.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string ProfileSectionName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IProfileAwareConfiguration Interface
PostSharp.Aspects.Configuration Namespace


IProfileAwareConfiguration.ProfileSectionNamespace Property

IProfileAwareConfigurationProfileSectionNamespace Property
Gets the namespace of the project section in which the profile resource is stored.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string ProfileSectionNamespace { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IProfileAwareConfiguration Interface
PostSharp.Aspects.Configuration Namespace


LocationInterceptionAspectConfiguration Class

LocationInterceptionAspectConfiguration Class
Configuration of aspects of type ILocationLevelAspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Aspects.ConfigurationLocationInterceptionAspectConfiguration

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class LocationInterceptionAspectConfiguration : AspectConfiguration

The LocationInterceptionAspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | LocationInterceptionAspectConfiguration | Initializes a new instance of the LocationInterceptionAspectConfiguration class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


LocationInterceptionAspectConfiguration Constructor

LocationInterceptionAspectConfiguration Constructor
Initializes a new instance of the LocationInterceptionAspectConfiguration class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LocationInterceptionAspectConfiguration()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


LocationInterceptionAspectConfiguration Methods

LocationInterceptionAspectConfiguration Methods

The LocationInterceptionAspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LocationInterceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


LocationInterceptionAspectConfiguration Properties

LocationInterceptionAspectConfiguration Properties

The LocationInterceptionAspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
See Also

Reference

LocationInterceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


LocationInterceptionAspectConfigurationAttribute Class

LocationInterceptionAspectConfigurationAttribute Class
Custom attribute that, when applied on a class implementing ILocationInterceptionAspect, defines the declarative configuration of that aspect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.ConfigurationAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationLocationInterceptionAspectConfigurationAttribute

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class LocationInterceptionAspectConfigurationAttribute : AspectConfigurationAttribute

The LocationInterceptionAspectConfigurationAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | LocationInterceptionAspectConfigurationAttribute | Initializes a new instance of the LocationInterceptionAspectConfigurationAttribute class
Top
Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.Aspects.ConfigurationLocationInterceptionAspectConfiguration
PostSharp.AspectsLocationLevelAspect

Other Resources

Conceptual Documentation: Configuring Aspects


LocationInterceptionAspectConfigurationAttribute Constructor

LocationInterceptionAspectConfigurationAttribute Constructor
Initializes a new instance of the LocationInterceptionAspectConfigurationAttribute class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LocationInterceptionAspectConfigurationAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInterceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


LocationInterceptionAspectConfigurationAttribute Methods

LocationInterceptionAspectConfigurationAttribute Methods

The LocationInterceptionAspectConfigurationAttribute type exposes the following members.

Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LocationInterceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


LocationInterceptionAspectConfigurationAttribute Properties

LocationInterceptionAspectConfigurationAttribute Properties

The LocationInterceptionAspectConfigurationAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
See Also

Reference

LocationInterceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


ManagedResourceIntroductionAspectConfiguration Class

ManagedResourceIntroductionAspectConfiguration Class
Configuration of aspects of type ManagedResourceIntroductionAspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Aspects.ConfigurationManagedResourceIntroductionAspectConfiguration

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ManagedResourceIntroductionAspectConfiguration : AspectConfiguration

The ManagedResourceIntroductionAspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | ManagedResourceIntroductionAspectConfiguration | Initializes a new ManagedResourceIntroductionAspectConfiguration.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Data | Gets the content of the managed resource.
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | Name | Gets the name of the managed resource.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


ManagedResourceIntroductionAspectConfiguration Constructor

ManagedResourceIntroductionAspectConfiguration Constructor
Initializes a new ManagedResourceIntroductionAspectConfiguration.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ManagedResourceIntroductionAspectConfiguration(
    string name,
    byte[] data
)

Parameters

name
Type: SystemString
Name of the managed resource.
data
Type: SystemByte
Content of the managed resource.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ManagedResourceIntroductionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


ManagedResourceIntroductionAspectConfiguration Methods

ManagedResourceIntroductionAspectConfiguration Methods

The ManagedResourceIntroductionAspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ManagedResourceIntroductionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


ManagedResourceIntroductionAspectConfiguration Properties

ManagedResourceIntroductionAspectConfiguration Properties

The ManagedResourceIntroductionAspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Data | Gets the content of the managed resource.
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | Name | Gets the name of the managed resource.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
See Also

Reference

ManagedResourceIntroductionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


ManagedResourceIntroductionAspectConfiguration.Data Property

ManagedResourceIntroductionAspectConfigurationData Property
Gets the content of the managed resource.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public byte[] Data { get; }

Property Value

Type: Byte
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ManagedResourceIntroductionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


ManagedResourceIntroductionAspectConfiguration.Name Property

ManagedResourceIntroductionAspectConfigurationName Property
Gets the name of the managed resource.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Name { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ManagedResourceIntroductionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


MethodInterceptionAspectConfiguration Class

MethodInterceptionAspectConfiguration Class
Configuration of aspects of type IMethodInterceptionAspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Aspects.ConfigurationMethodInterceptionAspectConfiguration

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class MethodInterceptionAspectConfiguration : AspectConfiguration

The MethodInterceptionAspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | MethodInterceptionAspectConfiguration | Initializes a new instance of the MethodInterceptionAspectConfiguration class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.Aspects.ConfigurationMethodInterceptionAspectConfigurationAttribute
PostSharp.AspectsMethodInterceptionAspect

Other Resources

Conceptual Documentation: Configuring Aspects


MethodInterceptionAspectConfiguration Constructor

MethodInterceptionAspectConfiguration Constructor
Initializes a new instance of the MethodInterceptionAspectConfiguration class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MethodInterceptionAspectConfiguration()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


MethodInterceptionAspectConfiguration Methods

MethodInterceptionAspectConfiguration Methods

The MethodInterceptionAspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MethodInterceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


MethodInterceptionAspectConfiguration Properties

MethodInterceptionAspectConfiguration Properties

The MethodInterceptionAspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
See Also

Reference

MethodInterceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


MethodInterceptionAspectConfigurationAttribute Class

MethodInterceptionAspectConfigurationAttribute Class
Custom attribute that, when applied on a class implementing IMethodInterceptionAspect, defines the declarative configuration of that aspect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.ConfigurationAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationMethodInterceptionAspectConfigurationAttribute

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class MethodInterceptionAspectConfigurationAttribute : AspectConfigurationAttribute

The MethodInterceptionAspectConfigurationAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | MethodInterceptionAspectConfigurationAttribute | Initializes a new instance of the MethodInterceptionAspectConfigurationAttribute class
Top
Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.AspectsMethodInterceptionAspect
PostSharp.Aspects.ConfigurationMethodInterceptionAspectConfiguration

Other Resources

Conceptual Documentation: Configuring Aspects


MethodInterceptionAspectConfigurationAttribute Constructor

MethodInterceptionAspectConfigurationAttribute Constructor
Initializes a new instance of the MethodInterceptionAspectConfigurationAttribute class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MethodInterceptionAspectConfigurationAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodInterceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


MethodInterceptionAspectConfigurationAttribute Methods

MethodInterceptionAspectConfigurationAttribute Methods

The MethodInterceptionAspectConfigurationAttribute type exposes the following members.

Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MethodInterceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


MethodInterceptionAspectConfigurationAttribute Properties

MethodInterceptionAspectConfigurationAttribute Properties

The MethodInterceptionAspectConfigurationAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
See Also

Reference

MethodInterceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


OnExceptionAspectConfiguration Class

OnExceptionAspectConfiguration Class
Configuration of the IOnExceptionAspect aspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Aspects.ConfigurationOnExceptionAspectConfiguration

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnExceptionAspectConfiguration : AspectConfiguration

The OnExceptionAspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | OnExceptionAspectConfiguration | Initializes a new instance of the OnExceptionAspectConfiguration class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | ExceptionType | Gets or sets the type of exceptions that are caught by this aspect.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.AspectsOnExceptionAspect
PostSharp.Aspects.ConfigurationOnExceptionAspectConfigurationAttribute

Other Resources

Conceptual Documentation: Configuring Aspects


OnExceptionAspectConfiguration Constructor

OnExceptionAspectConfiguration Constructor
Initializes a new instance of the OnExceptionAspectConfiguration class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnExceptionAspectConfiguration()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnExceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


OnExceptionAspectConfiguration Methods

OnExceptionAspectConfiguration Methods

The OnExceptionAspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnExceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


OnExceptionAspectConfiguration Properties

OnExceptionAspectConfiguration Properties

The OnExceptionAspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | ExceptionType | Gets or sets the type of exceptions that are caught by this aspect.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
See Also

Reference

OnExceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


OnExceptionAspectConfiguration.ApplyToStateMachine Property

OnExceptionAspectConfigurationApplyToStateMachine Property
Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<bool> ApplyToStateMachine { get; set; }

Property Value

Type: Nullable Boolean
true if the aspect should be applied to the state machine, or false if it should be applied to the method instantiating the state machine.
Remarks

Assigning this property to true results in an aspect that is consistent with the level of abstraction of the programming language. The false value is consistent with the level of abstraction of MSIL and is backward-compatible with versions of PostSharp prior to 3.1.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

OnExceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


OnExceptionAspectConfiguration.ExceptionType Property

OnExceptionAspectConfigurationExceptionType Property
Gets or sets the type of exceptions that are caught by this aspect.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public TypeIdentity ExceptionType { get; set; }

Property Value

Type: TypeIdentity
Remarks
If this property is null, any Exception shall be caught.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnExceptionAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


OnExceptionAspectConfigurationAttribute Class

OnExceptionAspectConfigurationAttribute Class
Custom attribute that, when applied on a class implementing IOnExceptionAspect, defines the configuration of that aspect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.ConfigurationAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationOnExceptionAspectConfigurationAttribute

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnExceptionAspectConfigurationAttribute : AspectConfigurationAttribute

The OnExceptionAspectConfigurationAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | OnExceptionAspectConfigurationAttribute | Initializes a new instance of the OnExceptionAspectConfigurationAttribute class
Top
Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | ExceptionType | Gets or sets the type of exceptions that are caught by this aspect.
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.AspectsOnExceptionAspect

Other Resources

Conceptual Documentation: Configuring Aspects


OnExceptionAspectConfigurationAttribute Constructor

OnExceptionAspectConfigurationAttribute Constructor
Initializes a new instance of the OnExceptionAspectConfigurationAttribute class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnExceptionAspectConfigurationAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnExceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


OnExceptionAspectConfigurationAttribute Methods

OnExceptionAspectConfigurationAttribute Methods

The OnExceptionAspectConfigurationAttribute type exposes the following members.

Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnExceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


OnExceptionAspectConfigurationAttribute Properties

OnExceptionAspectConfigurationAttribute Properties

The OnExceptionAspectConfigurationAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | ExceptionType | Gets or sets the type of exceptions that are caught by this aspect.
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
See Also

Reference

OnExceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


OnExceptionAspectConfigurationAttribute.ExceptionType Property

OnExceptionAspectConfigurationAttributeExceptionType Property
Gets or sets the type of exceptions that are caught by this aspect.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type ExceptionType { get; set; }

Property Value

Type: Type
Remarks
If this property is null, any Exception shall be caught.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnExceptionAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


OnMethodBoundaryAspectConfiguration Class

OnMethodBoundaryAspectConfiguration Class
Configuration of the IOnMethodBoundaryAspect aspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Aspects.ConfigurationOnMethodBoundaryAspectConfiguration

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnMethodBoundaryAspectConfiguration : AspectConfiguration

The OnMethodBoundaryAspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | OnMethodBoundaryAspectConfiguration | Initializes a new instance of the OnMethodBoundaryAspectConfiguration class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.Aspects.ConfigurationOnMethodBoundaryAspectConfigurationAttribute
PostSharp.AspectsOnMethodBoundaryAspect

Other Resources

Conceptual Documentation: Configuring Aspects


OnMethodBoundaryAspectConfiguration Constructor

OnMethodBoundaryAspectConfiguration Constructor
Initializes a new instance of the OnMethodBoundaryAspectConfiguration class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnMethodBoundaryAspectConfiguration()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


OnMethodBoundaryAspectConfiguration Methods

OnMethodBoundaryAspectConfiguration Methods

The OnMethodBoundaryAspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodBoundaryAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


OnMethodBoundaryAspectConfiguration Properties

OnMethodBoundaryAspectConfiguration Properties

The OnMethodBoundaryAspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | ApplyToStateMachine | Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
See Also

Reference

OnMethodBoundaryAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


OnMethodBoundaryAspectConfiguration.ApplyToStateMachine Property

OnMethodBoundaryAspectConfigurationApplyToStateMachine Property
Determines how the aspect should behave when it is applied to an iterator or async methods, which are compiled into state machines.

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<bool> ApplyToStateMachine { get; set; }

Property Value

Type: Nullable Boolean
true if the aspect should be applied to the state machine, or false if it should be applied to the the method instantiating the state machine.
Remarks

The default value is false unless the aspect class implements the IOnStateMachineBoundaryAspect interface, or true if the aspect class implements the interface.

Assigning this property to true results in an aspect that is consistent with the level of abstraction of the programming language. The false value is consistent with the level of abstraction of MSIL and is backward-compatible with versions of PostSharp prior to 3.1.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspectConfiguration Class
PostSharp.Aspects.Configuration Namespace


OnMethodBoundaryAspectConfigurationAttribute Class

OnMethodBoundaryAspectConfigurationAttribute Class
Custom attribute that, when applied on a class implementing IOnMethodBoundaryAspect, defines the configuration of that aspect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.ConfigurationAspectConfigurationAttribute
PostSharp.Aspects.ConfigurationOnMethodBoundaryAspectConfigurationAttribute

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OnMethodBoundaryAspectConfigurationAttribute : AspectConfigurationAttribute

The OnMethodBoundaryAspectConfigurationAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | OnMethodBoundaryAspectConfigurationAttribute | Initializes a new instance of the OnMethodBoundaryAspectConfigurationAttribute class
Top
Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Configuration Namespace
PostSharp.Aspects.ConfigurationOnMethodBoundaryAspectConfiguration
PostSharp.AspectsOnMethodBoundaryAspect

Other Resources

Conceptual Documentation: Configuring Aspects


OnMethodBoundaryAspectConfigurationAttribute Constructor

OnMethodBoundaryAspectConfigurationAttribute Constructor
Initializes a new instance of the OnMethodBoundaryAspectConfigurationAttribute class

Namespace: PostSharp.Aspects.Configuration
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OnMethodBoundaryAspectConfigurationAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

OnMethodBoundaryAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


OnMethodBoundaryAspectConfigurationAttribute Methods

OnMethodBoundaryAspectConfigurationAttribute Methods

The OnMethodBoundaryAspectConfigurationAttribute type exposes the following members.

Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OnMethodBoundaryAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


OnMethodBoundaryAspectConfigurationAttribute Properties

OnMethodBoundaryAspectConfigurationAttribute Properties

The OnMethodBoundaryAspectConfigurationAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
See Also

Reference

OnMethodBoundaryAspectConfigurationAttribute Class
PostSharp.Aspects.Configuration Namespace


PostSharp.Aspects.Dependencies Namespace

PostSharp.Aspects.Dependencies Namespace
The PostSharp.Aspects.Dependencies namespace contains types and custom attributes that allow to define dependencies between aspects and advices, so that the aspect weaver behaves determistically even if the same element of code is the target of several aspects provided by multiple vendors.
Classes
 | Class | Description
Public class | AdviceDependencyAttribute | Specifies an aspect dependency matching an advice of the same aspect instance.
Public class | AspectDependencyAttribute | Base class for all custom attributes defining aspect dependencies. An aspect dependency determines the behavior of aspects or advices when used in conjunction with other aspects and advices. Aspect dependencies determine ordering, requirements, conflicts, and commutativity of aspects and advices.
Public class | AspectDependencyAttributeCollection | Collection of AspectDependencyAttribute.
Public class | AspectEffectDependencyAttribute | Specifies an aspect dependency matching aspects or advices having a given effect.
Public class | AspectRoleDependencyAttribute | Specifies an aspect dependency matching aspects or advices that are a part of a given role.
Public class | AspectTypeDependencyAttribute | Specifies an aspect dependency matching aspects of a specified type, and all its advices.
Public class | ProvideAspectRoleAttribute | Specifies that the aspect or aspect advice to which this custom attribute is applied is a part of a given role. This aspect or advice can then be matched by AspectRoleDependencyAttribute/
Public class | StandardEffects | List of standard effects.
Public class | StandardRoles | List of standard roles.
Public class | WaiveAspectEffectAttribute | Declares that the aspect class or advice to which this custom attribute is applied is exempt of a given effect.
Enumerations
 | Enumeration | Description
Public enumeration | AspectDependencyAction | Enumeration of the different kinds of relationships of specified by aspect dependencies.
Public enumeration | AspectDependencyPosition | Enumeration of the direction of the relationship specified by an aspect dependency.
Public enumeration | AspectDependencyTarget | Enumeration of targets (Default or Type) to which the aspect dependency apply.


AdviceDependencyAttribute Class

AdviceDependencyAttribute Class
Specifies an aspect dependency matching an advice of the same aspect instance.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.DependenciesAspectDependencyAttribute
PostSharp.Aspects.DependenciesAdviceDependencyAttribute

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AdviceDependencyAttribute : AspectDependencyAttribute

The AdviceDependencyAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | AdviceDependencyAttribute(AspectDependencyAction, String) | Initializes a new AdviceDependencyAttribute without specifying the position, implicitly set to Any.
Public method | AdviceDependencyAttribute(AspectDependencyAction, AspectDependencyPosition, String) | Initializes a new AdviceDependencyAttribute and specifies a position.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute). (Inherited from AspectDependencyAttribute.)
Public property | AdviceMethodName | Gets the name of the method implementing the advice.
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected. (Inherited from AspectDependencyAttribute.)
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency. (Inherited from AspectDependencyAttribute.)
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply. (Inherited from AspectDependencyAttribute.)
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level. (Inherited from AspectDependencyAttribute.)
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


AdviceDependencyAttribute Constructor

AdviceDependencyAttribute Constructor
Overload List
 | Name | Description
Public method | AdviceDependencyAttribute(AspectDependencyAction, String) | Initializes a new AdviceDependencyAttribute without specifying the position, implicitly set to Any.
Public method | AdviceDependencyAttribute(AspectDependencyAction, AspectDependencyPosition, String) | Initializes a new AdviceDependencyAttribute and specifies a position.
Top
See Also

Reference

AdviceDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AdviceDependencyAttribute Constructor (AspectDependencyAction, String)

AdviceDependencyAttribute Constructor (AspectDependencyAction, String)
Initializes a new AdviceDependencyAttribute without specifying the position, implicitly set to Any.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdviceDependencyAttribute(
    AspectDependencyAction action,
    string adviceMethodName
)

Parameters

action
Type: PostSharp.Aspects.DependenciesAspectDependencyAction
Dependency action.
adviceMethodName
Type: SystemString
Name of the advice method.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AdviceDependencyAttribute Class
AdviceDependencyAttribute Overload
PostSharp.Aspects.Dependencies Namespace


AdviceDependencyAttribute Constructor (AspectDependencyAction, AspectDependencyPosition, String)

AdviceDependencyAttribute Constructor (AspectDependencyAction, AspectDependencyPosition, String)
Initializes a new AdviceDependencyAttribute and specifies a position.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdviceDependencyAttribute(
    AspectDependencyAction action,
    AspectDependencyPosition position,
    string adviceMethodName
)

Parameters

action
Type: PostSharp.Aspects.DependenciesAspectDependencyAction
Dependency action.
position
Type: PostSharp.Aspects.DependenciesAspectDependencyPosition
Dependency position.
adviceMethodName
Type: SystemString
Name of the advice method.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AdviceDependencyAttribute Class
AdviceDependencyAttribute Overload
PostSharp.Aspects.Dependencies Namespace


AdviceDependencyAttribute Methods

AdviceDependencyAttribute Methods

The AdviceDependencyAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdviceDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AdviceDependencyAttribute Properties

AdviceDependencyAttribute Properties

The AdviceDependencyAttribute type exposes the following members.

Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute). (Inherited from AspectDependencyAttribute.)
Public property | AdviceMethodName | Gets the name of the method implementing the advice.
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected. (Inherited from AspectDependencyAttribute.)
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency. (Inherited from AspectDependencyAttribute.)
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply. (Inherited from AspectDependencyAttribute.)
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level. (Inherited from AspectDependencyAttribute.)
Top
See Also

Reference

AdviceDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AdviceDependencyAttribute.AdviceMethodName Property

AdviceDependencyAttributeAdviceMethodName Property
Gets the name of the method implementing the advice.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string AdviceMethodName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AdviceDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAction Enumeration

AspectDependencyAction Enumeration
Enumeration of the different kinds of relationships of specified by aspect dependencies.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum AspectDependencyAction
Members
Member name | Value | Description
None | 0 | The dependency is ignored.
Order | 1 | The dependency specifies an order relationship.
Require | 2 | The dependency specifies that the current aspect or advice requires another aspect or advice.
Conflict | 3 | The dependency specifies that the current aspect or advice conflicts with another aspect or advice.
Commute | 4 | The dependency specifies that the current aspect or advice commutes with another aspect or advice.
Remarks

The combined values of AspectDependencyAction and AspectDependencyPosition is interpreted as follows:

Action | Position | Description
Order | After | The current aspect or advice should be positioned after the other aspect or advice matched by the custom attribute.
Order | Before | The current aspect or advice should be positioned before the other aspect or advice matched by the custom attribute.
Require | Any | The current aspect or advice requires another aspect or advice matched by the custom attribute, at any position.
Require | After | The current aspect or advice requires another aspect or advice matched by the custom attribute positioned after the current one.
Require | Before | The current aspect or advice requires another aspect or advice matched by the custom attribute positioned before the current one.
Conflict | Any | The current aspect or advice conflicts with any aspect or advice matched by the custom attribute, at any position.
Conflict | After | The current aspect or advice conflicts with any aspect or advice matched by the custom attribute, if positioned after the current one.
Conflict | Before | The current aspect or advice conflicts with any aspect or advice matched by the custom attribute, if positioned before the current one.
Commute |  | The current aspect or advice commute with any other aspect or advice matched by the custom attribute.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttribute Class

AspectDependencyAttribute Class
Base class for all custom attributes defining aspect dependencies. An aspect dependency determines the behavior of aspects or advices when used in conjunction with other aspects and advices. Aspect dependencies determine ordering, requirements, conflicts, and commutativity of aspects and advices.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.DependenciesAspectDependencyAttribute
PostSharp.Aspects.DependenciesAdviceDependencyAttribute
PostSharp.Aspects.DependenciesAspectEffectDependencyAttribute
PostSharp.Aspects.DependenciesAspectRoleDependencyAttribute
PostSharp.Aspects.DependenciesAspectTypeDependencyAttribute
PostSharp.Aspects.DependenciesProvideAspectRoleAttribute

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class AspectDependencyAttribute : Attribute

The AspectDependencyAttribute type exposes the following members.

Constructors
 | Name | Description
Protected method | AspectDependencyAttribute(AspectDependencyAction) | Initializes a new AspectDependencyAttribute without specifying the position, implicitly set to Any.
Protected method | AspectDependencyAttribute(AspectDependencyAction, AspectDependencyPosition) | Initializes a new AspectDependencyAttribute and specifies a position.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute).
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected.
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency.
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply.
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level.
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


AspectDependencyAttribute Constructor

AspectDependencyAttribute Constructor
Overload List
 | Name | Description
Protected method | AspectDependencyAttribute(AspectDependencyAction) | Initializes a new AspectDependencyAttribute without specifying the position, implicitly set to Any.
Protected method | AspectDependencyAttribute(AspectDependencyAction, AspectDependencyPosition) | Initializes a new AspectDependencyAttribute and specifies a position.
Top
See Also

Reference

AspectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttribute Constructor (AspectDependencyAction)

AspectDependencyAttribute Constructor (AspectDependencyAction)
Initializes a new AspectDependencyAttribute without specifying the position, implicitly set to Any.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AspectDependencyAttribute(
    AspectDependencyAction action
)

Parameters

action
Type: PostSharp.Aspects.DependenciesAspectDependencyAction
Dependency action.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectDependencyAttribute Class
AspectDependencyAttribute Overload
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttribute Constructor (AspectDependencyAction, AspectDependencyPosition)

AspectDependencyAttribute Constructor (AspectDependencyAction, AspectDependencyPosition)
Initializes a new AspectDependencyAttribute and specifies a position.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AspectDependencyAttribute(
    AspectDependencyAction action,
    AspectDependencyPosition position
)

Parameters

action
Type: PostSharp.Aspects.DependenciesAspectDependencyAction
Dependency action.
position
Type: PostSharp.Aspects.DependenciesAspectDependencyPosition
Dependency position.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectDependencyAttribute Class
AspectDependencyAttribute Overload
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttribute Methods

AspectDependencyAttribute Methods

The AspectDependencyAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttribute Properties

AspectDependencyAttribute Properties

The AspectDependencyAttribute type exposes the following members.

Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute).
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected.
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency.
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply.
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level.
Top
See Also

Reference

AspectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttribute.Action Property

AspectDependencyAttributeAction Property
Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute).

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectDependencyAction Action { get; }

Property Value

Type: AspectDependencyAction
Remarks
See documentation of AspectDependencyAction for a description of the meaning of combined Action and Position properties.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttribute.IsWarning Property

AspectDependencyAttributeIsWarning Property
If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsWarning { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttribute.Position Property

AspectDependencyAttributePosition Property
Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectDependencyPosition Position { get; }

Property Value

Type: AspectDependencyPosition
Remarks
See documentation of AspectDependencyAction for a description of the meaning of combined Action and Position properties.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttribute.Target Property

AspectDependencyAttributeTarget Property
Determines the target (Default or Type) to which the aspect dependency apply.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectDependencyTarget Target { get; set; }

Property Value

Type: AspectDependencyTarget
Remarks
See the documentation of AspectDependencyTarget for details.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttribute.TargetType Property

AspectDependencyAttributeTargetType Property
Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type TargetType { get; set; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttributeCollection Class

AspectDependencyAttributeCollection Class
Collection of AspectDependencyAttribute.
Inheritance Hierarchy
SystemObject
System.Collections.ObjectModelCollection AspectDependencyAttribute
PostSharp.Aspects.DependenciesAspectDependencyAttributeCollection

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AspectDependencyAttributeCollection : Collection<AspectDependencyAttribute>

The AspectDependencyAttributeCollection type exposes the following members.

Constructors
 | Name | Description
Public method | AspectDependencyAttributeCollection | Initializes a new instance of the AspectDependencyAttributeCollection class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttributeCollection Constructor

AspectDependencyAttributeCollection Constructor
Initializes a new instance of the AspectDependencyAttributeCollection class

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectDependencyAttributeCollection()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectDependencyAttributeCollection Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyAttributeCollection Methods

AspectDependencyAttributeCollection Methods

The AspectDependencyAttributeCollection type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectDependencyAttributeCollection Class
PostSharp.Aspects.Dependencies Namespace


AspectDependencyPosition Enumeration

AspectDependencyPosition Enumeration
Enumeration of the direction of the relationship specified by an aspect dependency.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum AspectDependencyPosition
Members
Member name | Value | Description
Any | 0 | Any order possible (or order not relevant).
Before | -1 | The current aspect or advice is positioned before the other aspect or handler.
After | 1 | The current aspect or advice is positioned after the other aspect or handler.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace


AspectDependencyTarget Enumeration

AspectDependencyTarget Enumeration
Enumeration of targets (Default or Type) to which the aspect dependency apply.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum AspectDependencyTarget
Members
Member name | Value | Description
Default | 0 | Natural target of the aspect.
Type | 1 | Declaring type of the natural target of the aspect.
Remarks

This property is meaningful only for aspects that apply to type members. For aspects that apply to types, type-level and default-level dependencies are the same thing.

Member-level aspects may have semantics that actually apply at type level (for instance member introductions and imports). By setting the dependency target to Type, you can specify that the aspect dependency applies to type-level semantics. Otherwise, it will apply to member-level semantics.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace


AspectEffectDependencyAttribute Class

AspectEffectDependencyAttribute Class
Specifies an aspect dependency matching aspects or advices having a given effect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.DependenciesAspectDependencyAttribute
PostSharp.Aspects.DependenciesAspectEffectDependencyAttribute

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AspectEffectDependencyAttribute : AspectDependencyAttribute

The AspectEffectDependencyAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | AspectEffectDependencyAttribute(AspectDependencyAction, String) | Initializes a new AspectEffectDependencyAttribute without specifying the position, implicitly set to Any.
Public method | AspectEffectDependencyAttribute(AspectDependencyAction, AspectDependencyPosition, String) | Initializes a new AspectEffectDependencyAttribute and specifies a position.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute). (Inherited from AspectDependencyAttribute.)
Public property | Effect | Gets the effect that the aspects or advices must have in order to match the current dependency.
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected. (Inherited from AspectDependencyAttribute.)
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency. (Inherited from AspectDependencyAttribute.)
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply. (Inherited from AspectDependencyAttribute.)
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level. (Inherited from AspectDependencyAttribute.)
Top
Remarks

All aspects (except the ones that have an empty implementation) have an effect on the program execution. The current custom attribute allows to express dependencies to aspects according to their effect.

The list of standard effects is given in class StandardEffects. All advices have implicitly the effect Custom. Most advices also have the effect ChangeControlFlow, because they are able to modify the control flow (for instance, skip the execution of the intercepted method or throwing an exception). An aspect or advice can declare it does not have a given effect by using the WaiveAspectEffectAttribute custom attribute.

Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace
PostSharp.Aspects.DependenciesStandardEffects
PostSharp.Aspects.DependenciesWaiveAspectEffectAttribute

Other Resources

Conceptual Documentation: Configuring Aspects


AspectEffectDependencyAttribute Constructor

AspectEffectDependencyAttribute Constructor
Overload List
 | Name | Description
Public method | AspectEffectDependencyAttribute(AspectDependencyAction, String) | Initializes a new AspectEffectDependencyAttribute without specifying the position, implicitly set to Any.
Public method | AspectEffectDependencyAttribute(AspectDependencyAction, AspectDependencyPosition, String) | Initializes a new AspectEffectDependencyAttribute and specifies a position.
Top
See Also

Reference

AspectEffectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectEffectDependencyAttribute Constructor (AspectDependencyAction, String)

AspectEffectDependencyAttribute Constructor (AspectDependencyAction, String)
Initializes a new AspectEffectDependencyAttribute without specifying the position, implicitly set to Any.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectEffectDependencyAttribute(
    AspectDependencyAction action,
    string effect
)

Parameters

action
Type: PostSharp.Aspects.DependenciesAspectDependencyAction
Dependency action.
effect
Type: SystemString
Effect (see StandardEffects).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectEffectDependencyAttribute Class
AspectEffectDependencyAttribute Overload
PostSharp.Aspects.Dependencies Namespace


AspectEffectDependencyAttribute Constructor (AspectDependencyAction, AspectDependencyPosition, String)

AspectEffectDependencyAttribute Constructor (AspectDependencyAction, AspectDependencyPosition, String)
Initializes a new AspectEffectDependencyAttribute and specifies a position.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectEffectDependencyAttribute(
    AspectDependencyAction action,
    AspectDependencyPosition position,
    string effect
)

Parameters

action
Type: PostSharp.Aspects.DependenciesAspectDependencyAction
Dependency action.
position
Type: PostSharp.Aspects.DependenciesAspectDependencyPosition
Dependency position.
effect
Type: SystemString
Effect (see StandardEffects).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectEffectDependencyAttribute Class
AspectEffectDependencyAttribute Overload
PostSharp.Aspects.Dependencies Namespace


AspectEffectDependencyAttribute Methods

AspectEffectDependencyAttribute Methods

The AspectEffectDependencyAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectEffectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectEffectDependencyAttribute Properties

AspectEffectDependencyAttribute Properties

The AspectEffectDependencyAttribute type exposes the following members.

Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute). (Inherited from AspectDependencyAttribute.)
Public property | Effect | Gets the effect that the aspects or advices must have in order to match the current dependency.
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected. (Inherited from AspectDependencyAttribute.)
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency. (Inherited from AspectDependencyAttribute.)
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply. (Inherited from AspectDependencyAttribute.)
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level. (Inherited from AspectDependencyAttribute.)
Top
See Also

Reference

AspectEffectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectEffectDependencyAttribute.Effect Property

AspectEffectDependencyAttributeEffect Property
Gets the effect that the aspects or advices must have in order to match the current dependency.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Effect { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectEffectDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectRoleDependencyAttribute Class

AspectRoleDependencyAttribute Class
Specifies an aspect dependency matching aspects or advices that are a part of a given role.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.DependenciesAspectDependencyAttribute
PostSharp.Aspects.DependenciesAspectRoleDependencyAttribute

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AspectRoleDependencyAttribute : AspectDependencyAttribute

The AspectRoleDependencyAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | AspectRoleDependencyAttribute(AspectDependencyAction, String) | Initializes a new AspectEffectDependencyAttribute without specifying the position, implicitly set to Any.
Public method | AspectRoleDependencyAttribute(AspectDependencyAction, AspectDependencyPosition, String) | Initializes a new AspectRoleDependencyAttribute and specifies a position.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute). (Inherited from AspectDependencyAttribute.)
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected. (Inherited from AspectDependencyAttribute.)
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency. (Inherited from AspectDependencyAttribute.)
Public property | Role | Gets the role that the aspects or advices must be a part of in order to match the current dependency.
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply. (Inherited from AspectDependencyAttribute.)
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level. (Inherited from AspectDependencyAttribute.)
Top
Remarks

A role describes what the aspect actually does. A list of standard roles is available on the class StandardRoles. Aspect vendors are encouraged to enroll their aspects in one of these roles whenever it makes sense, and to document the other roles they have used.

An aspect or advice can be enrolled in a role by using the ProvideAspectRoleAttribute custom attribute.

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace
PostSharp.Aspects.DependenciesProvideAspectRoleAttribute
PostSharp.Aspects.DependenciesStandardRoles

Other Resources

Conceptual Documentation: Configuring Aspects


AspectRoleDependencyAttribute Constructor

AspectRoleDependencyAttribute Constructor
Overload List
 | Name | Description
Public method | AspectRoleDependencyAttribute(AspectDependencyAction, String) | Initializes a new AspectEffectDependencyAttribute without specifying the position, implicitly set to Any.
Public method | AspectRoleDependencyAttribute(AspectDependencyAction, AspectDependencyPosition, String) | Initializes a new AspectRoleDependencyAttribute and specifies a position.
Top
See Also

Reference

AspectRoleDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectRoleDependencyAttribute Constructor (AspectDependencyAction, String)

AspectRoleDependencyAttribute Constructor (AspectDependencyAction, String)
Initializes a new AspectEffectDependencyAttribute without specifying the position, implicitly set to Any.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectRoleDependencyAttribute(
    AspectDependencyAction action,
    string role
)

Parameters

action
Type: PostSharp.Aspects.DependenciesAspectDependencyAction
Dependency action.
role
Type: SystemString
Role.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectRoleDependencyAttribute Class
AspectRoleDependencyAttribute Overload
PostSharp.Aspects.Dependencies Namespace


AspectRoleDependencyAttribute Constructor (AspectDependencyAction, AspectDependencyPosition, String)

AspectRoleDependencyAttribute Constructor (AspectDependencyAction, AspectDependencyPosition, String)
Initializes a new AspectRoleDependencyAttribute and specifies a position.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectRoleDependencyAttribute(
    AspectDependencyAction action,
    AspectDependencyPosition position,
    string role
)

Parameters

action
Type: PostSharp.Aspects.DependenciesAspectDependencyAction
Dependency action.
position
Type: PostSharp.Aspects.DependenciesAspectDependencyPosition
Dependency position.
role
Type: SystemString
Role.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectRoleDependencyAttribute Class
AspectRoleDependencyAttribute Overload
PostSharp.Aspects.Dependencies Namespace


AspectRoleDependencyAttribute Methods

AspectRoleDependencyAttribute Methods

The AspectRoleDependencyAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectRoleDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectRoleDependencyAttribute Properties

AspectRoleDependencyAttribute Properties

The AspectRoleDependencyAttribute type exposes the following members.

Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute). (Inherited from AspectDependencyAttribute.)
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected. (Inherited from AspectDependencyAttribute.)
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency. (Inherited from AspectDependencyAttribute.)
Public property | Role | Gets the role that the aspects or advices must be a part of in order to match the current dependency.
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply. (Inherited from AspectDependencyAttribute.)
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level. (Inherited from AspectDependencyAttribute.)
Top
See Also

Reference

AspectRoleDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectRoleDependencyAttribute.Role Property

AspectRoleDependencyAttributeRole Property
Gets the role that the aspects or advices must be a part of in order to match the current dependency.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Role { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectRoleDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectTypeDependencyAttribute Class

AspectTypeDependencyAttribute Class
Specifies an aspect dependency matching aspects of a specified type, and all its advices.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.DependenciesAspectDependencyAttribute
PostSharp.Aspects.DependenciesAspectTypeDependencyAttribute

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AspectTypeDependencyAttribute : AspectDependencyAttribute

The AspectTypeDependencyAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | AspectTypeDependencyAttribute(AspectDependencyAction, Type) | Initializes a new AspectTypeDependencyAttribute without specifying the position, implicitly set to Any.
Public method | AspectTypeDependencyAttribute(AspectDependencyAction, AspectDependencyPosition, Type) | Initializes a new AspectTypeDependencyAttribute and specifies a position.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute). (Inherited from AspectDependencyAttribute.)
Public property | AspectType | Gets the type from which the aspects should be derived in order to match the current dependency.
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected. (Inherited from AspectDependencyAttribute.)
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency. (Inherited from AspectDependencyAttribute.)
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply. (Inherited from AspectDependencyAttribute.)
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level. (Inherited from AspectDependencyAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


AspectTypeDependencyAttribute Constructor

AspectTypeDependencyAttribute Constructor
Overload List
 | Name | Description
Public method | AspectTypeDependencyAttribute(AspectDependencyAction, Type) | Initializes a new AspectTypeDependencyAttribute without specifying the position, implicitly set to Any.
Public method | AspectTypeDependencyAttribute(AspectDependencyAction, AspectDependencyPosition, Type) | Initializes a new AspectTypeDependencyAttribute and specifies a position.
Top
See Also

Reference

AspectTypeDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectTypeDependencyAttribute Constructor (AspectDependencyAction, Type)

AspectTypeDependencyAttribute Constructor (AspectDependencyAction, Type)
Initializes a new AspectTypeDependencyAttribute without specifying the position, implicitly set to Any.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectTypeDependencyAttribute(
    AspectDependencyAction action,
    Type aspectType
)

Parameters

action
Type: PostSharp.Aspects.DependenciesAspectDependencyAction
Dependency action.
aspectType
Type: SystemType
Aspect type (derived from IAspect).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectTypeDependencyAttribute Class
AspectTypeDependencyAttribute Overload
PostSharp.Aspects.Dependencies Namespace


AspectTypeDependencyAttribute Constructor (AspectDependencyAction, AspectDependencyPosition, Type)

AspectTypeDependencyAttribute Constructor (AspectDependencyAction, AspectDependencyPosition, Type)
Initializes a new AspectTypeDependencyAttribute and specifies a position.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AspectTypeDependencyAttribute(
    AspectDependencyAction action,
    AspectDependencyPosition position,
    Type aspectType
)

Parameters

action
Type: PostSharp.Aspects.DependenciesAspectDependencyAction
Dependency action.
position
Type: PostSharp.Aspects.DependenciesAspectDependencyPosition
Dependency position.
aspectType
Type: SystemType
Aspect type (derived from IAspect).
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectTypeDependencyAttribute Class
AspectTypeDependencyAttribute Overload
PostSharp.Aspects.Dependencies Namespace


AspectTypeDependencyAttribute Methods

AspectTypeDependencyAttribute Methods

The AspectTypeDependencyAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectTypeDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectTypeDependencyAttribute Properties

AspectTypeDependencyAttribute Properties

The AspectTypeDependencyAttribute type exposes the following members.

Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute). (Inherited from AspectDependencyAttribute.)
Public property | AspectType | Gets the type from which the aspects should be derived in order to match the current dependency.
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected. (Inherited from AspectDependencyAttribute.)
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency. (Inherited from AspectDependencyAttribute.)
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply. (Inherited from AspectDependencyAttribute.)
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level. (Inherited from AspectDependencyAttribute.)
Top
See Also

Reference

AspectTypeDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


AspectTypeDependencyAttribute.AspectType Property

AspectTypeDependencyAttributeAspectType Property
Gets the type from which the aspects should be derived in order to match the current dependency.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type AspectType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectTypeDependencyAttribute Class
PostSharp.Aspects.Dependencies Namespace


ProvideAspectRoleAttribute Class

ProvideAspectRoleAttribute Class
Specifies that the aspect or aspect advice to which this custom attribute is applied is a part of a given role. This aspect or advice can then be matched by AspectRoleDependencyAttribute/
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.DependenciesAspectDependencyAttribute
PostSharp.Aspects.DependenciesProvideAspectRoleAttribute

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ProvideAspectRoleAttribute : AspectDependencyAttribute

The ProvideAspectRoleAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ProvideAspectRoleAttribute | Initializes a new ProvideAspectRoleAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute). (Inherited from AspectDependencyAttribute.)
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected. (Inherited from AspectDependencyAttribute.)
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency. (Inherited from AspectDependencyAttribute.)
Public property | Role | Gets the role into which the aspect or advice to which this custom attribute is applied will be enrolled.
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply. (Inherited from AspectDependencyAttribute.)
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level. (Inherited from AspectDependencyAttribute.)
Top
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace
PostSharp.Aspects.DependenciesAspectRoleDependencyAttribute

Other Resources

Conceptual Documentation: Configuring Aspects


ProvideAspectRoleAttribute Constructor

ProvideAspectRoleAttribute Constructor
Initializes a new ProvideAspectRoleAttribute.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ProvideAspectRoleAttribute(
    string role
)

Parameters

role
Type: SystemString
Role.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProvideAspectRoleAttribute Class
PostSharp.Aspects.Dependencies Namespace


ProvideAspectRoleAttribute Methods

ProvideAspectRoleAttribute Methods

The ProvideAspectRoleAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ProvideAspectRoleAttribute Class
PostSharp.Aspects.Dependencies Namespace


ProvideAspectRoleAttribute Properties

ProvideAspectRoleAttribute Properties

The ProvideAspectRoleAttribute type exposes the following members.

Properties
 | Name | Description
Public property | Action | Gets the dependency action, i.e. the kind of relationship specified by the dependency (Order, Require, Conflict, or Commute). (Inherited from AspectDependencyAttribute.)
Public property | IsWarning | If true, specifies that the constraint (of type Require or Conflict) should emit a warning instead of an error if not respected. (Inherited from AspectDependencyAttribute.)
Public property | Position | Gets the position of the current dependency, i.e. actually the position of the other aspect or advices with respect to the one related to this dependency. (Inherited from AspectDependencyAttribute.)
Public property | Role | Gets the role into which the aspect or advice to which this custom attribute is applied will be enrolled.
Public property | Target | Determines the target (Default or Type) to which the aspect dependency apply. (Inherited from AspectDependencyAttribute.)
Public property | TargetType | Aspect type to which this dependency applies. This property is required when the custom attribute is applied at assembly level. It is ignored when applied on class or method level. (Inherited from AspectDependencyAttribute.)
Top
See Also

Reference

ProvideAspectRoleAttribute Class
PostSharp.Aspects.Dependencies Namespace


ProvideAspectRoleAttribute.Role Property

ProvideAspectRoleAttributeRole Property
Gets the role into which the aspect or advice to which this custom attribute is applied will be enrolled.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Role { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProvideAspectRoleAttribute Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects Class

StandardEffects Class
List of standard effects.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.DependenciesStandardEffects

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class StandardEffects

The StandardEffects type exposes the following members.

Methods
Name | Description
GetInterfaceIntroductionEffect | Gets a string representing the effect of introducing an interface into a type.
GetMemberImportEffect | Gets a string representing the effect of importing a member into from the target type into the aspect.
GetMemberIntroductionEffect | Gets a string representing the effect of introducing a member into a type.
Top
Fields
Name | Description
ChangeControlFlow | Change the flow control (for instance by having the possibility to skip execution of an intercepted method).
Custom | Custom effect (implemented in an aspect advice). All advices have this effect by default, unless they are annotated by WaiveAspectEffectAttribute.
CustomAttributeIntroduction | Introduction of a custom attribute.
InterfaceIntroduction | Introduction of an interface.
MemberImport | Import of a type member.
MemberIntroduction | Introduction of a type member.
Top
Remarks

See AspectEffectDependencyAttribute for a discussion of effects.

This list is not meant to be extended by vendors providing concrete aspects (implementing some business functionality). Roles should be used to categorized the business effect of concrete aspects. However, if you implement a new kind of abstract aspect (for instance member suppression), you may need to define new effects.

In that case, we at PostSharp encourage you contact us to define a new role string. If you define a new role string, we recommend you clearly define it so that users of your aspect can express dependencies with their own aspects, or third-party aspects.

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace
PostSharp.Aspects.DependenciesAspectEffectDependencyAttribute
PostSharp.Aspects.DependenciesWaiveAspectEffectAttribute
PostSharp.Aspects.DependenciesStandardRoles

Other Resources

Conceptual Documentation: Configuring Aspects


StandardEffects Fields

StandardEffects Fields

The StandardEffects type exposes the following members.

Fields
Name | Description
ChangeControlFlow | Change the flow control (for instance by having the possibility to skip execution of an intercepted method).
Custom | Custom effect (implemented in an aspect advice). All advices have this effect by default, unless they are annotated by WaiveAspectEffectAttribute.
CustomAttributeIntroduction | Introduction of a custom attribute.
InterfaceIntroduction | Introduction of an interface.
MemberImport | Import of a type member.
MemberIntroduction | Introduction of a type member.
Top
See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects.ChangeControlFlow Field

StandardEffectsChangeControlFlow Field
Change the flow control (for instance by having the possibility to skip execution of an intercepted method).

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string ChangeControlFlow

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects.Custom Field

StandardEffectsCustom Field
Custom effect (implemented in an aspect advice). All advices have this effect by default, unless they are annotated by WaiveAspectEffectAttribute.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Custom

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects.CustomAttributeIntroduction Field

StandardEffectsCustomAttributeIntroduction Field
Introduction of a custom attribute.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string CustomAttributeIntroduction

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects.InterfaceIntroduction Field

StandardEffectsInterfaceIntroduction Field
Introduction of an interface.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string InterfaceIntroduction

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects.MemberImport Field

StandardEffectsMemberImport Field
Import of a type member.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string MemberImport

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects.MemberIntroduction Field

StandardEffectsMemberIntroduction Field
Introduction of a type member.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string MemberIntroduction

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects Methods

StandardEffects Methods

The StandardEffects type exposes the following members.

Methods
Name | Description
GetInterfaceIntroductionEffect | Gets a string representing the effect of introducing an interface into a type.
GetMemberImportEffect | Gets a string representing the effect of importing a member into from the target type into the aspect.
GetMemberIntroductionEffect | Gets a string representing the effect of introducing a member into a type.
Top
See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects.GetInterfaceIntroductionEffect Method

StandardEffectsGetInterfaceIntroductionEffect Method
Gets a string representing the effect of introducing an interface into a type.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static string GetInterfaceIntroductionEffect(
    string typeName
)

Parameters

typeName
Type: SystemString
Name of the introduced interface.

Return Value

Type: String
A string that, by convention, represents the introduction of an interface named typeName into a type.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects.GetMemberImportEffect Method

StandardEffectsGetMemberImportEffect Method
Gets a string representing the effect of importing a member into from the target type into the aspect.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static string GetMemberImportEffect(
    string memberName
)

Parameters

memberName
Type: SystemString
Name of the imported member.

Return Value

Type: String
A string that, by convention, represents the import of a member named memberName from the target type into the aspect.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardEffects.GetMemberIntroductionEffect Method

StandardEffectsGetMemberIntroductionEffect Method
Gets a string representing the effect of introducing a member into a type.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static string GetMemberIntroductionEffect(
    string memberName
)

Parameters

memberName
Type: SystemString
Name of the introduced member.

Return Value

Type: String
A string that, by convention, represents the introduction of a member named memberName into a type.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardEffects Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles Class

StandardRoles Class
List of standard roles.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.DependenciesStandardRoles

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class StandardRoles

The StandardRoles type exposes the following members.

Fields
Name | Description
Caching | Caching.
DataBinding | Data binding (for instance implementation of INotifyPropertyChanged).
EventBroker | Event broker (a system role used internally by PostSharp to realize the OnInvokeHandler(EventInterceptionArgs) handler).
ExceptionHandling | Exception handling.
PerformanceInstrumentation | Performance instrumentation (for instance performance counters).
Persistence | Object persistence (for instance Object-Relational Mapper).
Security | Security enforcing (typically authorization).
Threading | Threading (locking).
Tracing | Tracing and logging.
TransactionHandling | Transaction handling.
Validation | Validation of field, property, or parameter value.
Top
Remarks

See AspectRoleDependencyAttribute for a discussion of aspect roles.

Roles are used to categorize aspects according to their function. This class defines standard names for the most commonly used aspect roles. If you are an aspect vendor, you are encouraged to enroll your aspects (using ProvideAspectRoleAttribute) into one of these roles.

If this list is not sufficient, we at PostSharp encourage you contact us to define a new role string. In any case, if you define a new role string, we recommend you clearly define it so that users of your aspect can express dependencies with their own aspects, or third-party aspects.

Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


StandardRoles Fields

StandardRoles Fields

The StandardRoles type exposes the following members.

Fields
Name | Description
Caching | Caching.
DataBinding | Data binding (for instance implementation of INotifyPropertyChanged).
EventBroker | Event broker (a system role used internally by PostSharp to realize the OnInvokeHandler(EventInterceptionArgs) handler).
ExceptionHandling | Exception handling.
PerformanceInstrumentation | Performance instrumentation (for instance performance counters).
Persistence | Object persistence (for instance Object-Relational Mapper).
Security | Security enforcing (typically authorization).
Threading | Threading (locking).
Tracing | Tracing and logging.
TransactionHandling | Transaction handling.
Validation | Validation of field, property, or parameter value.
Top
See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.Caching Field

StandardRolesCaching Field
Caching.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Caching

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.DataBinding Field

StandardRolesDataBinding Field
Data binding (for instance implementation of INotifyPropertyChanged).

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string DataBinding

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.EventBroker Field

StandardRolesEventBroker Field
Event broker (a system role used internally by PostSharp to realize the OnInvokeHandler(EventInterceptionArgs) handler).

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string EventBroker

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.ExceptionHandling Field

StandardRolesExceptionHandling Field
Exception handling.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string ExceptionHandling

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.PerformanceInstrumentation Field

StandardRolesPerformanceInstrumentation Field
Performance instrumentation (for instance performance counters).

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string PerformanceInstrumentation

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.Persistence Field

StandardRolesPersistence Field
Object persistence (for instance Object-Relational Mapper).

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Persistence

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.Security Field

StandardRolesSecurity Field
Security enforcing (typically authorization).

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Security

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.Threading Field

StandardRolesThreading Field
Threading (locking).

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Threading

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.Tracing Field

StandardRolesTracing Field
Tracing and logging.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Tracing

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.TransactionHandling Field

StandardRolesTransactionHandling Field
Transaction handling.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string TransactionHandling

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


StandardRoles.Validation Field

StandardRolesValidation Field
Validation of field, property, or parameter value.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Validation

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StandardRoles Class
PostSharp.Aspects.Dependencies Namespace


WaiveAspectEffectAttribute Class

WaiveAspectEffectAttribute Class
Declares that the aspect class or advice to which this custom attribute is applied is exempt of a given effect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.DependenciesWaiveAspectEffectAttribute

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class WaiveAspectEffectAttribute : Attribute

The WaiveAspectEffectAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | WaiveAspectEffectAttribute | Initializes a new WaiveAspectEffectAttribute declaring that the aspect class or advice to which this custom attribute is applied has no effect at all.
Public method | WaiveAspectEffectAttribute(String) | Initializes a new WaiveAspectEffectAttribute declaring that the aspect class or advice to which this custom attribute is applied is exempt of the specified effects.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
See AspectEffectDependencyAttribute for details about effects.
Remarks
Note Note
PostSharp Professional Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Dependencies Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


WaiveAspectEffectAttribute Constructor

WaiveAspectEffectAttribute Constructor
Overload List
 | Name | Description
Public method | WaiveAspectEffectAttribute | Initializes a new WaiveAspectEffectAttribute declaring that the aspect class or advice to which this custom attribute is applied has no effect at all.
Public method | WaiveAspectEffectAttribute(String) | Initializes a new WaiveAspectEffectAttribute declaring that the aspect class or advice to which this custom attribute is applied is exempt of the specified effects.
Top
See Also

Reference

WaiveAspectEffectAttribute Class
PostSharp.Aspects.Dependencies Namespace


WaiveAspectEffectAttribute Constructor

WaiveAspectEffectAttribute Constructor
Initializes a new WaiveAspectEffectAttribute declaring that the aspect class or advice to which this custom attribute is applied has no effect at all.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public WaiveAspectEffectAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

WaiveAspectEffectAttribute Class
WaiveAspectEffectAttribute Overload
PostSharp.Aspects.Dependencies Namespace


WaiveAspectEffectAttribute Constructor (String[])

WaiveAspectEffectAttribute Constructor (String)
Initializes a new WaiveAspectEffectAttribute declaring that the aspect class or advice to which this custom attribute is applied is exempt of the specified effects.

Namespace: PostSharp.Aspects.Dependencies
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public WaiveAspectEffectAttribute(
    params string[] effects
)

Parameters

effects
Type: SystemString
List of effects of which the aspect class or advice to which this custom attribute is applied is guaranteed to be exempt.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

WaiveAspectEffectAttribute Class
WaiveAspectEffectAttribute Overload
PostSharp.Aspects.Dependencies Namespace


WaiveAspectEffectAttribute Methods

WaiveAspectEffectAttribute Methods

The WaiveAspectEffectAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

WaiveAspectEffectAttribute Class
PostSharp.Aspects.Dependencies Namespace


PostSharp.Aspects.Serialization Namespace

PostSharp.Aspects.Serialization Namespace
The PostSharp.Aspects.Serialization namespace contains types taking care of the process of serializing aspects at build time and deserializing them at run time.
Classes
 | Class | Description
Public class | AspectSerializer | Base class for Laos serializers, whose role is to serialize aspect instances at compile-time and deserialize them at runtime.
Public class | BinaryAspectSerializationBinder | Implementation of SerializationBinder used at runtime when aspect instances are deserialized. By overriding the default binder, you can resolve assembly names differently. This can be useful if assemblies have been renamed or merged between PostSharp run and execution
Public class | BinaryAspectSerializer | Implementation of AspectSerializer based on the BinaryFormatter provided by the full version of the .NET Framework.
Public class | MsilAspectSerializer | When used as a value of AspectConfigurationAttribute.SerializerType property, specifies that the aspect should not be serialized but should instead be constructed at runtime using MSIL instructions.
Public class | PortableAspectSerializer | Implementation of AspectSerializer based on the PortableFormatter, for use on any other platform than the fully-trusted .NET Framework.
Interfaces
 | Interface | Description
Public interface | IMetadataAwareSurrogateSelector | A SurrogateSelector that receives an IMetadataEmitter before serialization.


AspectSerializer Class

AspectSerializer Class
Base class for Laos serializers, whose role is to serialize aspect instances at compile-time and deserialize them at runtime.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.SerializationAspectSerializer
PostSharp.Aspects.SerializationBinaryAspectSerializer
PostSharp.Aspects.SerializationMsilAspectSerializer
PostSharp.Aspects.SerializationPortableAspectSerializer

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class AspectSerializer

The AspectSerializer type exposes the following members.

Constructors
 | Name | Description
Protected method | AspectSerializer | Initializes a new instance of the AspectSerializer class
Top
Methods
 | Name | Description
Protected method | Deserialize(Stream, IMetadataDispenser) | Deserializes a stream into an array if aspects.
Public method | Deserialize(Assembly, String, IMetadataDispenser) | Deserializes aspects contained in a managed resource of an assembly.
Public method | Serialize | Serializes an array of aspects into a stream.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Serialization Namespace


AspectSerializer Constructor

AspectSerializer Constructor
Initializes a new instance of the AspectSerializer class

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AspectSerializer()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectSerializer Class
PostSharp.Aspects.Serialization Namespace


AspectSerializer Methods

AspectSerializer Methods

The AspectSerializer type exposes the following members.

Methods
 | Name | Description
Protected method | Deserialize(Stream, IMetadataDispenser) | Deserializes a stream into an array if aspects.
Public method | Deserialize(Assembly, String, IMetadataDispenser) | Deserializes aspects contained in a managed resource of an assembly.
Public method | Serialize | Serializes an array of aspects into a stream.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AspectSerializer Class
PostSharp.Aspects.Serialization Namespace


AspectSerializer.Deserialize Method

AspectSerializerDeserialize Method
Overload List
 | Name | Description
Protected method | Deserialize(Stream, IMetadataDispenser) | Deserializes a stream into an array if aspects.
Public method | Deserialize(Assembly, String, IMetadataDispenser) | Deserializes aspects contained in a managed resource of an assembly.
Top
See Also

Reference

AspectSerializer Class
PostSharp.Aspects.Serialization Namespace


AspectSerializer.Deserialize Method (Stream, IMetadataDispenser)

AspectSerializerDeserialize Method (Stream, IMetadataDispenser)
Deserializes a stream into an array if aspects.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected abstract IAspect[] Deserialize(
    Stream stream,
    IMetadataDispenser metadataDispenser
)

Parameters

stream
Type: System.IOStream
Stream containing serialized aspects.
metadataDispenser
Type: PostSharp.ReflectionIMetadataDispenser
Metadata dispenser to be used to resolve serialized metadata references in stream.

Return Value

Type: IAspect
An array of aspects.
Remarks
The implementation is not allowed to change the order or array elements.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectSerializer Class
Deserialize Overload
PostSharp.Aspects.Serialization Namespace


AspectSerializer.Deserialize Method (Assembly, String, IMetadataDispenser)

AspectSerializerDeserialize Method (Assembly, String, IMetadataDispenser)
Deserializes aspects contained in a managed resource of an assembly.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IAspect[] Deserialize(
    Assembly assembly,
    string resourceName,
    IMetadataDispenser metadataDispenser
)

Parameters

assembly
Type: System.ReflectionAssembly
Assembly containing the serialized aspects.
resourceName
Type: SystemString
Name of the managed resources into which aspects have been serialized.
metadataDispenser
Type: PostSharp.ReflectionIMetadataDispenser
Metadata dispenser to be used to resolve serialized metadata references in this resource.

Return Value

Type: IAspect
An array of aspects.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectSerializer Class
Deserialize Overload
PostSharp.Aspects.Serialization Namespace


AspectSerializer.Serialize Method

AspectSerializerSerialize Method
Serializes an array of aspects into a stream.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void Serialize(
    IAspect[] aspects,
    Stream stream,
    IMetadataEmitter metadataEmitter
)

Parameters

aspects
Type: PostSharp.AspectsIAspect
Array of aspects to be serialized.
stream
Type: System.IOStream
Stream into which aspects have to be serialized.
metadataEmitter
Type: PostSharp.ReflectionIMetadataEmitter
A metadata emitter for the current module.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AspectSerializer Class
PostSharp.Aspects.Serialization Namespace


BinaryAspectSerializationBinder Class

BinaryAspectSerializationBinder Class
Implementation of SerializationBinder used at runtime when aspect instances are deserialized. By overriding the default binder, you can resolve assembly names differently. This can be useful if assemblies have been renamed or merged between PostSharp run and execution
Inheritance Hierarchy
SystemObject
System.Runtime.SerializationSerializationBinder
PostSharp.Aspects.SerializationBinaryAspectSerializationBinder

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class BinaryAspectSerializationBinder : SerializationBinder

The BinaryAspectSerializationBinder type exposes the following members.

Constructors
 | Name | Description
Public method | BinaryAspectSerializationBinder | Initializes a new .
Top
Methods
 | Name | Description
Public method | BindToType | When overridden in a derived class, controls the binding of a serialized object to a type. (Overrides SerializationBinderBindToType(String, String).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Serialization Namespace


BinaryAspectSerializationBinder Constructor

BinaryAspectSerializationBinder Constructor
Initializes a new .

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public BinaryAspectSerializationBinder()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

BinaryAspectSerializationBinder Class
PostSharp.Aspects.Serialization Namespace
PostSharp.Aspects.SerializationBinaryAspectSerializationBinder


BinaryAspectSerializationBinder Methods

BinaryAspectSerializationBinder Methods

The BinaryAspectSerializationBinder type exposes the following members.

Methods
 | Name | Description
Public method | BindToType | When overridden in a derived class, controls the binding of a serialized object to a type. (Overrides SerializationBinderBindToType(String, String).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

BinaryAspectSerializationBinder Class
PostSharp.Aspects.Serialization Namespace


BinaryAspectSerializationBinder.BindToType Method

BinaryAspectSerializationBinderBindToType Method
When overridden in a derived class, controls the binding of a serialized object to a type.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Type BindToType(
    string assemblyName,
    string typeName
)

Parameters

assemblyName
Type: SystemString
Specifies the Assembly name of the serialized object.
typeName
Type: SystemString
Specifies the Type name of the serialized object.

Return Value

Type: Type
The type of the object the formatter creates a new instance of.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

BinaryAspectSerializationBinder Class
PostSharp.Aspects.Serialization Namespace


BinaryAspectSerializer Class

BinaryAspectSerializer Class
Implementation of AspectSerializer based on the BinaryFormatter provided by the full version of the .NET Framework.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.SerializationAspectSerializer
PostSharp.Aspects.SerializationBinaryAspectSerializer

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class BinaryAspectSerializer : AspectSerializer

The BinaryAspectSerializer type exposes the following members.

Constructors
 | Name | Description
Public method | BinaryAspectSerializer | Initializes a new instance of the BinaryAspectSerializer class
Top
Methods
 | Name | Description
 | ChainSurrogateSelector | Adds an item to the chain of surrogate selectors used during the process of serializing aspects.
Protected method | Deserialize(Stream, IMetadataDispenser) | Deserializes a stream into an array if aspects. (Overrides AspectSerializerDeserialize(Stream, IMetadataDispenser).)
Public method | Deserialize(Assembly, String, IMetadataDispenser) | Deserializes aspects contained in a managed resource of an assembly. (Inherited from AspectSerializer.)
Public method | Serialize | Serializes an array of aspects into a stream. (Overrides AspectSerializerSerialize(IAspect, Stream, IMetadataEmitter).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Serialization Namespace


BinaryAspectSerializer Constructor

BinaryAspectSerializer Constructor
Initializes a new instance of the BinaryAspectSerializer class

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public BinaryAspectSerializer()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

BinaryAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


BinaryAspectSerializer Methods

BinaryAspectSerializer Methods

The BinaryAspectSerializer type exposes the following members.

Methods
 | Name | Description
 | ChainSurrogateSelector | Adds an item to the chain of surrogate selectors used during the process of serializing aspects.
Protected method | Deserialize(Stream, IMetadataDispenser) | Deserializes a stream into an array if aspects. (Overrides AspectSerializerDeserialize(Stream, IMetadataDispenser).)
Public method | Deserialize(Assembly, String, IMetadataDispenser) | Deserializes aspects contained in a managed resource of an assembly. (Inherited from AspectSerializer.)
Public method | Serialize | Serializes an array of aspects into a stream. (Overrides AspectSerializerSerialize(IAspect, Stream, IMetadataEmitter).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

BinaryAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


BinaryAspectSerializer.ChainSurrogateSelector Method

BinaryAspectSerializerChainSurrogateSelector Method
Adds an item to the chain of surrogate selectors used during the process of serializing aspects.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void ChainSurrogateSelector(
    ISurrogateSelector selector
)

Parameters

selector
Type: System.Runtime.SerializationISurrogateSelector
A new surrogate selector.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

BinaryAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


BinaryAspectSerializer.Deserialize Method

BinaryAspectSerializerDeserialize Method
Overload List
 | Name | Description
Protected method | Deserialize(Stream, IMetadataDispenser) | Deserializes a stream into an array if aspects. (Overrides AspectSerializerDeserialize(Stream, IMetadataDispenser).)
Public method | Deserialize(Assembly, String, IMetadataDispenser) | Deserializes aspects contained in a managed resource of an assembly. (Inherited from AspectSerializer.)
Top
See Also

Reference

BinaryAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


BinaryAspectSerializer.Deserialize Method (Stream, IMetadataDispenser)

BinaryAspectSerializerDeserialize Method (Stream, IMetadataDispenser)
Deserializes a stream into an array if aspects.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override IAspect[] Deserialize(
    Stream stream,
    IMetadataDispenser metadataDispenser
)

Parameters

stream
Type: System.IOStream
Stream containing serialized aspects.
metadataDispenser
Type: PostSharp.ReflectionIMetadataDispenser
Metadata dispenser to be used to resolve serialized metadata references in stream.

Return Value

Type: IAspect
An array of aspects.
Remarks
The implementation is not allowed to change the order or array elements.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

BinaryAspectSerializer Class
Deserialize Overload
PostSharp.Aspects.Serialization Namespace


BinaryAspectSerializer.Serialize Method

BinaryAspectSerializerSerialize Method
Serializes an array of aspects into a stream.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void Serialize(
    IAspect[] aspects,
    Stream stream,
    IMetadataEmitter metadataEmitter
)

Parameters

aspects
Type: PostSharp.AspectsIAspect
Array of aspects to be serialized.
stream
Type: System.IOStream
Stream into which aspects have to be serialized.
metadataEmitter
Type: PostSharp.ReflectionIMetadataEmitter
A metadata emitter for the current module.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

BinaryAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


IMetadataAwareSurrogateSelector Interface

IMetadataAwareSurrogateSelector Interface
A SurrogateSelector that receives an IMetadataEmitter before serialization.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMetadataAwareSurrogateSelector : ISurrogateSelector

The IMetadataAwareSurrogateSelector type exposes the following members.

Methods
 | Name | Description
Public method | SetMetadataEmitter | Sets the IMetadataEmitter.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Serialization Namespace


IMetadataAwareSurrogateSelector Methods

IMetadataAwareSurrogateSelector Methods

The IMetadataAwareSurrogateSelector type exposes the following members.

Methods
 | Name | Description
Public method | SetMetadataEmitter | Sets the IMetadataEmitter.
Top
See Also

Reference

IMetadataAwareSurrogateSelector Interface
PostSharp.Aspects.Serialization Namespace


IMetadataAwareSurrogateSelector.SetMetadataEmitter Method

IMetadataAwareSurrogateSelectorSetMetadataEmitter Method
Sets the IMetadataEmitter.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void SetMetadataEmitter(
    IMetadataEmitter metadataEmitter
)

Parameters

metadataEmitter
Type: PostSharp.ReflectionIMetadataEmitter
An IMetadataEmitter.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMetadataAwareSurrogateSelector Interface
PostSharp.Aspects.Serialization Namespace


MsilAspectSerializer Class

MsilAspectSerializer Class
When used as a value of AspectConfigurationAttribute.SerializerType property, specifies that the aspect should not be serialized but should instead be constructed at runtime using MSIL instructions.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.SerializationAspectSerializer
PostSharp.Aspects.SerializationMsilAspectSerializer

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class MsilAspectSerializer : AspectSerializer

The MsilAspectSerializer type exposes the following members.

Constructors
 | Name | Description
Public method | MsilAspectSerializer | Initializes a new instance of the MsilAspectSerializer class
Top
Methods
 | Name | Description
Public method | Deserialize(Assembly, String, IMetadataDispenser) | Deserializes aspects contained in a managed resource of an assembly. (Inherited from AspectSerializer.)
Public method | Serialize | Serializes an array of aspects into a stream. (Overrides AspectSerializerSerialize(IAspect, Stream, IMetadataEmitter).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
This class is not a serializer. When you use MSIL aspect construction, the aspect is built at runtime just as normal custom attributes, and any change made at build time is lost.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Serialization Namespace


MsilAspectSerializer Constructor

MsilAspectSerializer Constructor
Initializes a new instance of the MsilAspectSerializer class

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MsilAspectSerializer()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MsilAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


MsilAspectSerializer Methods

MsilAspectSerializer Methods

The MsilAspectSerializer type exposes the following members.

Methods
 | Name | Description
Public method | Deserialize(Assembly, String, IMetadataDispenser) | Deserializes aspects contained in a managed resource of an assembly. (Inherited from AspectSerializer.)
Public method | Serialize | Serializes an array of aspects into a stream. (Overrides AspectSerializerSerialize(IAspect, Stream, IMetadataEmitter).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MsilAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


MsilAspectSerializer.Serialize Method

MsilAspectSerializerSerialize Method
Serializes an array of aspects into a stream.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void Serialize(
    IAspect[] aspects,
    Stream stream,
    IMetadataEmitter metadataEmitter
)

Parameters

aspects
Type: PostSharp.AspectsIAspect
Array of aspects to be serialized.
stream
Type: System.IOStream
Stream into which aspects have to be serialized.
metadataEmitter
Type: PostSharp.ReflectionIMetadataEmitter
A metadata emitter for the current module.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MsilAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


PortableAspectSerializer Class

PortableAspectSerializer Class
Implementation of AspectSerializer based on the PortableFormatter, for use on any other platform than the fully-trusted .NET Framework.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.SerializationAspectSerializer
PostSharp.Aspects.SerializationPortableAspectSerializer

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class PortableAspectSerializer : AspectSerializer

The PortableAspectSerializer type exposes the following members.

Constructors
 | Name | Description
Public method | PortableAspectSerializer | Initializes a new instance of the PortableAspectSerializer class
Top
Methods
 | Name | Description
Public method | Deserialize(Assembly, String, IMetadataDispenser) | Deserializes aspects contained in a managed resource of an assembly. (Inherited from AspectSerializer.)
Public method | Serialize | Serializes an array of aspects into a stream. (Overrides AspectSerializerSerialize(IAspect, Stream, IMetadataEmitter).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
Name | Description
Binder | Gets or sets the PortableSerializationBinder used to deserialize aspects.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Aspects.Serialization Namespace
PostSharp.Aspects.SerializationAspectSerializer


PortableAspectSerializer Constructor

PortableAspectSerializer Constructor
Initializes a new instance of the PortableAspectSerializer class

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PortableAspectSerializer()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


PortableAspectSerializer Methods

PortableAspectSerializer Methods

The PortableAspectSerializer type exposes the following members.

Methods
 | Name | Description
Public method | Deserialize(Assembly, String, IMetadataDispenser) | Deserializes aspects contained in a managed resource of an assembly. (Inherited from AspectSerializer.)
Public method | Serialize | Serializes an array of aspects into a stream. (Overrides AspectSerializerSerialize(IAspect, Stream, IMetadataEmitter).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PortableAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


PortableAspectSerializer.Serialize Method

PortableAspectSerializerSerialize Method
Serializes an array of aspects into a stream.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void Serialize(
    IAspect[] aspects,
    Stream stream,
    IMetadataEmitter metadataEmitter
)

Parameters

aspects
Type: PostSharp.AspectsIAspect
Array of aspects to be serialized.
stream
Type: System.IOStream
Stream into which aspects have to be serialized.
metadataEmitter
Type: PostSharp.ReflectionIMetadataEmitter
A metadata emitter for the current module.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


PortableAspectSerializer Properties

PortableAspectSerializer Properties

The PortableAspectSerializer type exposes the following members.

Properties
Name | Description
Binder | Gets or sets the PortableSerializationBinder used to deserialize aspects.
Top
See Also

Reference

PortableAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


PortableAspectSerializer.Binder Property

PortableAspectSerializerBinder Property
Gets or sets the PortableSerializationBinder used to deserialize aspects.

Namespace: PostSharp.Aspects.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static PortableSerializationBinder Binder { get; set; }

Property Value

Type: PortableSerializationBinder
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableAspectSerializer Class
PostSharp.Aspects.Serialization Namespace


PostSharp.Collections Namespace

PostSharp.Collections Namespace
The PostSharp.Collections namespace contains collection types used by the PostSharp library.
Classes
 | Class | Description
Public class | LinkedListExtensions | Extensions to the IReadOnlyLinkedListT interface.
Interfaces
 | Interface | Description
Public interface | ILinkedListNodeT | Represents a node in a double-linked list.
Public interface | IReadOnlyLinkedListT | Represents a double linked list.


ILinkedListNode(T) Interface

ILinkedListNodeT Interface
Represents a node in a double-linked list.

Namespace: PostSharp.Collections
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILinkedListNode<out T>

Type Parameters

T
Type of values stored in the list.

The ILinkedListNodeT type exposes the following members.

Properties
 | Name | Description
Public property | Next | Gets the next node in the list, or null if the current node is the last one in the list.
Public property | Previous | Gets the previous node in the list, or null if the current node is the first one in the list.
Public property | Value | Gets the value stored in the current node.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Collections Namespace


ILinkedListNode(T) Properties

ILinkedListNodeT Properties

The ILinkedListNodeT generic type exposes the following members.

Properties
 | Name | Description
Public property | Next | Gets the next node in the list, or null if the current node is the last one in the list.
Public property | Previous | Gets the previous node in the list, or null if the current node is the first one in the list.
Public property | Value | Gets the value stored in the current node.
Top
See Also

Reference

ILinkedListNodeT Interface
PostSharp.Collections Namespace


ILinkedListNode(T).Next Property

ILinkedListNodeTNext Property
Gets the next node in the list, or null if the current node is the last one in the list.

Namespace: PostSharp.Collections
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ILinkedListNode<T> Next { get; }

Property Value

Type: ILinkedListNode T
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILinkedListNodeT Interface
PostSharp.Collections Namespace


ILinkedListNode(T).Previous Property

ILinkedListNodeTPrevious Property
Gets the previous node in the list, or null if the current node is the first one in the list.

Namespace: PostSharp.Collections
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ILinkedListNode<T> Previous { get; }

Property Value

Type: ILinkedListNode T
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILinkedListNodeT Interface
PostSharp.Collections Namespace


ILinkedListNode(T).Value Property

ILinkedListNodeTValue Property
Gets the value stored in the current node.

Namespace: PostSharp.Collections
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
T Value { get; }

Property Value

Type: T
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILinkedListNodeT Interface
PostSharp.Collections Namespace


IReadOnlyLinkedList(T) Interface

IReadOnlyLinkedListT Interface
Represents a double linked list.

Namespace: PostSharp.Collections
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IReadOnlyLinkedList<out T>

Type Parameters

T
Type of values stored in the link list.

The IReadOnlyLinkedListT type exposes the following members.

Properties
 | Name | Description
Public property | First | Gets the first node in the list, or null if the list is empty.
Public property | IsEmpty | Determines whether the list is empty.
Public property | Last | Gets the last node in the list, or null if the list is empty.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Collections Namespace
PostSharp.CollectionsLinkedListExtensions


IReadOnlyLinkedList(T) Properties

IReadOnlyLinkedListT Properties

The IReadOnlyLinkedListT generic type exposes the following members.

Properties
 | Name | Description
Public property | First | Gets the first node in the list, or null if the list is empty.
Public property | IsEmpty | Determines whether the list is empty.
Public property | Last | Gets the last node in the list, or null if the list is empty.
Top
See Also

Reference

IReadOnlyLinkedListT Interface
PostSharp.Collections Namespace


IReadOnlyLinkedList(T).First Property

IReadOnlyLinkedListTFirst Property
Gets the first node in the list, or null if the list is empty.

Namespace: PostSharp.Collections
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ILinkedListNode<T> First { get; }

Property Value

Type: ILinkedListNode T
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IReadOnlyLinkedListT Interface
PostSharp.Collections Namespace


IReadOnlyLinkedList(T).IsEmpty Property

IReadOnlyLinkedListTIsEmpty Property
Determines whether the list is empty.

Namespace: PostSharp.Collections
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsEmpty { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IReadOnlyLinkedListT Interface
PostSharp.Collections Namespace


IReadOnlyLinkedList(T).Last Property

IReadOnlyLinkedListTLast Property
Gets the last node in the list, or null if the list is empty.

Namespace: PostSharp.Collections
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ILinkedListNode<T> Last { get; }

Property Value

Type: ILinkedListNode T
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IReadOnlyLinkedListT Interface
PostSharp.Collections Namespace


LinkedListExtensions Class

LinkedListExtensions Class
Extensions to the IReadOnlyLinkedListT interface.
Inheritance Hierarchy
SystemObject
PostSharp.CollectionsLinkedListExtensions

Namespace: PostSharp.Collections
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class LinkedListExtensions

The LinkedListExtensions type exposes the following members.

Methods
Name | Description
ToEnumerableT | Transforms an IReadOnlyLinkedListT into an IEnumerableT.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Collections Namespace


LinkedListExtensions Methods

LinkedListExtensions Methods

The LinkedListExtensions type exposes the following members.

Methods
Name | Description
ToEnumerableT | Transforms an IReadOnlyLinkedListT into an IEnumerableT.
Top
See Also

Reference

LinkedListExtensions Class
PostSharp.Collections Namespace


LinkedListExtensions.ToEnumerable(T) Method

LinkedListExtensionsToEnumerableT Method
Transforms an IReadOnlyLinkedListT into an IEnumerableT.

Namespace: PostSharp.Collections
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static IEnumerable<T> ToEnumerable<T>(
    IReadOnlyLinkedList<T> linkedList
)

Parameters

linkedList
Type: PostSharp.CollectionsIReadOnlyLinkedList T
A IReadOnlyLinkedListT, or null.

Type Parameters

T
Type of values.

Return Value

Type: IEnumerable T
An IEnumerableT that can enumerate all elements in linkedList. If linkedList is null, an empty enumerable is returned.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LinkedListExtensions Class
PostSharp.Collections Namespace


PostSharp.Constraints Namespace

PostSharp.Constraints Namespace
The PostSharp.Constraints namespace allows you to validate your code against predefined or custom design rules.
Classes
 | Class | Description
Public class | ComponentInternalAttribute | ReferentialConstraint that, when applied on a declaration, limits the scope (namespace or type) in which this declaration can be used. This constraint is useful to isolate several components from each other, even if they are implemented in the same assembly. The ComponentInternal constraint sets the visibility of a declaration between internal and private. The constraint cannot be applied to public or protected declarations.
Public class | Constraint | Root class for all constraints based on MulticastAttribute. A constraint is a piece validation logic executed at build time. Constraints are applied to elements of code ((Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo) typically using multicast custom attributes, and verified at build time for every assembly using this element of code.
Public class | ExperimentalAttribute | Custom attribute that, when applied on a declaration, causes PostSharp to emit a warning if the declaration is being used.
Public class | InternalAttribute | ReferentialConstraint, when applied to a declaration, prevents it to be used from an different assembly. This constraint can be used when a declaration must be made public for technical reasons, but its author do not want it to be used in external code.
Public class | InternalImplementAttribute | ReferentialConstraint that, when applied on an interface, prevents it to be implemented in a different assembly. This constraint should be used when the author of an interface does not expect users to implement the interface and wants to reserve the possibility to add new methods to the interface.
Public class | ProtectedAttribute | Custom attribute that, when applied to a target declaration, causes PostSharp to emit a warning if the declaration is being referenced from classes that are not derived from the target class. This constraint is similar to the C# keyword protected and should be used only when the target declaration must be made public or internal for non-architectural reasons.
Public class | ReferentialConstraint | Implementation of IReferentialConstraint based on MulticastAttribute.
Public class | ScalarConstraint | Implementation of IScalarConstraint based on MulticastAttribute.
Interfaces
 | Interface | Description
Public interface | IConstraint | A constraint is a piece of validation logic executed at build time. Constraints are applied to elements of code (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo), typically (but not necessarily) using custom attributes or MulticastAttribute.
Public interface | IReferentialConstraint | A constraint is a piece validation logic executed at build time. Constraints are applied to elements of code ((Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo), typically using custom attributes or MulticastAttribute, and verified at build time for every assembly using this element of code.
Public interface | IScalarConstraint | A constraint that validates a specific element of code. Use an IReferentialConstraint to validate relationships between elements of code.


ComponentInternalAttribute Class

ComponentInternalAttribute Class
ReferentialConstraint that, when applied on a declaration, limits the scope (namespace or type) in which this declaration can be used. This constraint is useful to isolate several components from each other, even if they are implemented in the same assembly. The ComponentInternal constraint sets the visibility of a declaration between internal and private. The constraint cannot be applied to public or protected declarations.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.ConstraintsConstraint
PostSharp.ConstraintsReferentialConstraint
PostSharp.ConstraintsComponentInternalAttribute

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ComponentInternalAttribute : ReferentialConstraint

The ComponentInternalAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ComponentInternalAttribute | Initializes a ComponentInternalAttribute restricting the target declaration from being used from another namespace than the namespace of the declaration.
Public method | ComponentInternalAttribute(String) | Initializes a ComponentInternalAttribute restricting the target declaration from being used outside of given types or namespaces, given by strings.
Public method | ComponentInternalAttribute(Type) | Initializes a ComponentInternalAttribute restricting the target declaration from being used outside of given types or namespaces, given as Type.
Top
Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint. (Overrides ReferentialConstraintValidateCode(Object, Assembly).)
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Overrides ConstraintValidateConstraint(Object).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Severity | Gets or sets the severity of messages emitted by this constraint.
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace


ComponentInternalAttribute Constructor

ComponentInternalAttribute Constructor
Overload List
 | Name | Description
Public method | ComponentInternalAttribute | Initializes a ComponentInternalAttribute restricting the target declaration from being used from another namespace than the namespace of the declaration.
Public method | ComponentInternalAttribute(String) | Initializes a ComponentInternalAttribute restricting the target declaration from being used outside of given types or namespaces, given by strings.
Public method | ComponentInternalAttribute(Type) | Initializes a ComponentInternalAttribute restricting the target declaration from being used outside of given types or namespaces, given as Type.
Top
See Also

Reference

ComponentInternalAttribute Class
PostSharp.Constraints Namespace


ComponentInternalAttribute Constructor

ComponentInternalAttribute Constructor
Initializes a ComponentInternalAttribute restricting the target declaration from being used from another namespace than the namespace of the declaration.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ComponentInternalAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ComponentInternalAttribute Class
ComponentInternalAttribute Overload
PostSharp.Constraints Namespace


ComponentInternalAttribute Constructor (String[])

ComponentInternalAttribute Constructor (String)
Initializes a ComponentInternalAttribute restricting the target declaration from being used outside of given types or namespaces, given by strings.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ComponentInternalAttribute(
    params string[] friendNamespaces
)

Parameters

friendNamespaces
Type: SystemString
List of types or namespaces from which the target declaration can be used.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ComponentInternalAttribute Class
ComponentInternalAttribute Overload
PostSharp.Constraints Namespace


ComponentInternalAttribute Constructor (Type[])

ComponentInternalAttribute Constructor (Type)
Initializes a ComponentInternalAttribute restricting the target declaration from being used outside of given types or namespaces, given as Type.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ComponentInternalAttribute(
    params Type[] friendTypes
)

Parameters

friendTypes
Type: SystemType
List of types from which the target declaration can be used. If the name of a type is NamespaceType, the whole namespace of this type is allowed.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ComponentInternalAttribute Class
ComponentInternalAttribute Overload
PostSharp.Constraints Namespace


ComponentInternalAttribute Methods

ComponentInternalAttribute Methods

The ComponentInternalAttribute type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint. (Overrides ReferentialConstraintValidateCode(Object, Assembly).)
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Overrides ConstraintValidateConstraint(Object).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ComponentInternalAttribute Class
PostSharp.Constraints Namespace


ComponentInternalAttribute.ValidateCode Method

ComponentInternalAttributeValidateCode Method
Validates the constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void ValidateCode(
    Object target,
    Assembly assembly
)

Parameters

target
Type: SystemObject
Declaration (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo) to which the constraint has been applied.
assembly
Type: System.ReflectionAssembly
The assembly being currently processed.

Implements

IReferentialConstraintValidateCode(Object, Assembly)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ComponentInternalAttribute Class
PostSharp.Constraints Namespace


ComponentInternalAttribute.ValidateConstraint Method

ComponentInternalAttributeValidateConstraint Method
Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool ValidateConstraint(
    Object target
)

Parameters

target
Type: SystemObject

Return Value

Type: Boolean
true if the constraint has been applied on a valid element of code, otherwise false.

Implements

IConstraintValidateConstraint(Object)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ComponentInternalAttribute Class
PostSharp.Constraints Namespace


ComponentInternalAttribute Properties

ComponentInternalAttribute Properties

The ComponentInternalAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Severity | Gets or sets the severity of messages emitted by this constraint.
Top
See Also

Reference

ComponentInternalAttribute Class
PostSharp.Constraints Namespace


ComponentInternalAttribute.Severity Property

ComponentInternalAttributeSeverity Property
Gets or sets the severity of messages emitted by this constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SeverityType Severity { get; set; }

Property Value

Type: SeverityType
Remarks

The default value is Warning.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ComponentInternalAttribute Class
PostSharp.Constraints Namespace


Constraint Class

Constraint Class
Root class for all constraints based on MulticastAttribute. A constraint is a piece validation logic executed at build time. Constraints are applied to elements of code ((Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo) typically using multicast custom attributes, and verified at build time for every assembly using this element of code.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.ConstraintsConstraint
PostSharp.ConstraintsReferentialConstraint
PostSharp.ConstraintsScalarConstraint

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class Constraint : MulticastAttribute,
    IConstraint

The Constraint type exposes the following members.

Constructors
 | Name | Description
Protected method | Constraint | Initializes a new instance of the Constraint class
Top
Methods
 | Name | Description
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace


Constraint Constructor

Constraint Constructor
Initializes a new instance of the Constraint class

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected Constraint()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Constraint Class
PostSharp.Constraints Namespace


Constraint Methods

Constraint Methods

The Constraint type exposes the following members.

Methods
 | Name | Description
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

Constraint Class
PostSharp.Constraints Namespace


Constraint.ValidateConstraint Method

ConstraintValidateConstraint Method
Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual bool ValidateConstraint(
    Object target
)

Parameters

target
Type: SystemObject

Return Value

Type: Boolean
true if the constraint has been applied on a valid element of code, otherwise false.

Implements

IConstraintValidateConstraint(Object)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Constraint Class
PostSharp.Constraints Namespace


Constraint Properties

Constraint Properties

The Constraint type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

Constraint Class
PostSharp.Constraints Namespace


ExperimentalAttribute Class

ExperimentalAttribute Class
Custom attribute that, when applied on a declaration, causes PostSharp to emit a warning if the declaration is being used.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.ConstraintsConstraint
PostSharp.ConstraintsReferentialConstraint
PostSharp.ConstraintsExperimentalAttribute

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ExperimentalAttribute : ReferentialConstraint

The ExperimentalAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ExperimentalAttribute | Initializes a new instance of the ExperimentalAttribute class
Top
Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint. (Overrides ReferentialConstraintValidateCode(Object, Assembly).)
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from Constraint.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace


ExperimentalAttribute Constructor

ExperimentalAttribute Constructor
Initializes a new instance of the ExperimentalAttribute class

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ExperimentalAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ExperimentalAttribute Class
PostSharp.Constraints Namespace


ExperimentalAttribute Methods

ExperimentalAttribute Methods

The ExperimentalAttribute type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint. (Overrides ReferentialConstraintValidateCode(Object, Assembly).)
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from Constraint.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ExperimentalAttribute Class
PostSharp.Constraints Namespace


ExperimentalAttribute.ValidateCode Method

ExperimentalAttributeValidateCode Method
Validates the constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void ValidateCode(
    Object target,
    Assembly assembly
)

Parameters

target
Type: SystemObject
Declaration (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo) to which the constraint has been applied.
assembly
Type: System.ReflectionAssembly
The assembly being currently processed.

Implements

IReferentialConstraintValidateCode(Object, Assembly)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ExperimentalAttribute Class
PostSharp.Constraints Namespace


ExperimentalAttribute Properties

ExperimentalAttribute Properties

The ExperimentalAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

ExperimentalAttribute Class
PostSharp.Constraints Namespace


IConstraint Interface

IConstraint Interface
A constraint is a piece of validation logic executed at build time. Constraints are applied to elements of code (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo), typically (but not necessarily) using custom attributes or MulticastAttribute.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IConstraint

The IConstraint type exposes the following members.

Methods
 | Name | Description
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored.
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace


IConstraint Methods

IConstraint Methods

The IConstraint type exposes the following members.

Methods
 | Name | Description
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored.
Top
See Also

Reference

IConstraint Interface
PostSharp.Constraints Namespace


IConstraint.ValidateConstraint Method

IConstraintValidateConstraint Method
Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool ValidateConstraint(
    Object target
)

Parameters

target
Type: SystemObject

Return Value

Type: Boolean
true if the constraint has been applied on a valid element of code, otherwise false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IConstraint Interface
PostSharp.Constraints Namespace


InternalAttribute Class

InternalAttribute Class
ReferentialConstraint, when applied to a declaration, prevents it to be used from an different assembly. This constraint can be used when a declaration must be made public for technical reasons, but its author do not want it to be used in external code.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.ConstraintsConstraint
PostSharp.ConstraintsReferentialConstraint
PostSharp.ConstraintsInternalAttribute

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class InternalAttribute : ReferentialConstraint

The InternalAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | InternalAttribute | Initializes a new InternalAttribute.
Top
Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint. (Overrides ReferentialConstraintValidateCode(Object, Assembly).)
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Overrides ConstraintValidateConstraint(Object).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Severity | Gets or sets the severity of messages emitted by this constraint.
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace


InternalAttribute Constructor

InternalAttribute Constructor
Initializes a new InternalAttribute.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InternalAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InternalAttribute Class
PostSharp.Constraints Namespace


InternalAttribute Methods

InternalAttribute Methods

The InternalAttribute type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint. (Overrides ReferentialConstraintValidateCode(Object, Assembly).)
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Overrides ConstraintValidateConstraint(Object).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

InternalAttribute Class
PostSharp.Constraints Namespace


InternalAttribute.ValidateCode Method

InternalAttributeValidateCode Method
Validates the constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void ValidateCode(
    Object target,
    Assembly assembly
)

Parameters

target
Type: SystemObject
Declaration (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo) to which the constraint has been applied.
assembly
Type: System.ReflectionAssembly
The assembly being currently processed.

Implements

IReferentialConstraintValidateCode(Object, Assembly)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InternalAttribute Class
PostSharp.Constraints Namespace


InternalAttribute.ValidateConstraint Method

InternalAttributeValidateConstraint Method
Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool ValidateConstraint(
    Object target
)

Parameters

target
Type: SystemObject

Return Value

Type: Boolean
true if the constraint has been applied on a valid element of code, otherwise false.

Implements

IConstraintValidateConstraint(Object)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InternalAttribute Class
PostSharp.Constraints Namespace


InternalAttribute Properties

InternalAttribute Properties

The InternalAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Severity | Gets or sets the severity of messages emitted by this constraint.
Top
See Also

Reference

InternalAttribute Class
PostSharp.Constraints Namespace


InternalAttribute.Severity Property

InternalAttributeSeverity Property
Gets or sets the severity of messages emitted by this constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SeverityType Severity { get; set; }

Property Value

Type: SeverityType
Remarks

The default value is Warning.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InternalAttribute Class
PostSharp.Constraints Namespace


InternalImplementAttribute Class

InternalImplementAttribute Class
ReferentialConstraint that, when applied on an interface, prevents it to be implemented in a different assembly. This constraint should be used when the author of an interface does not expect users to implement the interface and wants to reserve the possibility to add new methods to the interface.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.ConstraintsConstraint
PostSharp.ConstraintsReferentialConstraint
PostSharp.ConstraintsInternalImplementAttribute

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class InternalImplementAttribute : ReferentialConstraint

The InternalImplementAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | InternalImplementAttribute | Initializes a new InternalImplementAttribute.
Top
Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint. (Overrides ReferentialConstraintValidateCode(Object, Assembly).)
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from Constraint.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Severity | Gets or sets the severity of messages emitted by this constraint.
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace


InternalImplementAttribute Constructor

InternalImplementAttribute Constructor
Initializes a new InternalImplementAttribute.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InternalImplementAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InternalImplementAttribute Class
PostSharp.Constraints Namespace


InternalImplementAttribute Methods

InternalImplementAttribute Methods

The InternalImplementAttribute type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint. (Overrides ReferentialConstraintValidateCode(Object, Assembly).)
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from Constraint.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

InternalImplementAttribute Class
PostSharp.Constraints Namespace


InternalImplementAttribute.ValidateCode Method

InternalImplementAttributeValidateCode Method
Validates the constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void ValidateCode(
    Object target,
    Assembly assembly
)

Parameters

target
Type: SystemObject
Declaration (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo) to which the constraint has been applied.
assembly
Type: System.ReflectionAssembly
The assembly being currently processed.

Implements

IReferentialConstraintValidateCode(Object, Assembly)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InternalImplementAttribute Class
PostSharp.Constraints Namespace


InternalImplementAttribute Properties

InternalImplementAttribute Properties

The InternalImplementAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Severity | Gets or sets the severity of messages emitted by this constraint.
Top
See Also

Reference

InternalImplementAttribute Class
PostSharp.Constraints Namespace


InternalImplementAttribute.Severity Property

InternalImplementAttributeSeverity Property
Gets or sets the severity of messages emitted by this constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SeverityType Severity { get; set; }

Property Value

Type: SeverityType
Remarks

The default value is Warning.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InternalImplementAttribute Class
PostSharp.Constraints Namespace


IReferentialConstraint Interface

IReferentialConstraint Interface
A constraint is a piece validation logic executed at build time. Constraints are applied to elements of code ((Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo), typically using custom attributes or MulticastAttribute, and verified at build time for every assembly using this element of code.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IReferentialConstraint : IConstraint

The IReferentialConstraint type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint.
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from IConstraint.)
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace


IReferentialConstraint Methods

IReferentialConstraint Methods

The IReferentialConstraint type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint.
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from IConstraint.)
Top
See Also

Reference

IReferentialConstraint Interface
PostSharp.Constraints Namespace


IReferentialConstraint.ValidateCode Method

IReferentialConstraintValidateCode Method
Validates the constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void ValidateCode(
    Object target,
    Assembly assembly
)

Parameters

target
Type: SystemObject
Declaration (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo) to which the constraint has been applied.
assembly
Type: System.ReflectionAssembly
The assembly being currently processed.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IReferentialConstraint Interface
PostSharp.Constraints Namespace


IScalarConstraint Interface

IScalarConstraint Interface
A constraint that validates a specific element of code. Use an IReferentialConstraint to validate relationships between elements of code.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IScalarConstraint : IConstraint

The IScalarConstraint type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the element of code to which the constraint is applied.
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from IConstraint.)
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace
PostSharp.ConstraintsScalarConstraint


IScalarConstraint Methods

IScalarConstraint Methods

The IScalarConstraint type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the element of code to which the constraint is applied.
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from IConstraint.)
Top
See Also

Reference

IScalarConstraint Interface
PostSharp.Constraints Namespace


IScalarConstraint.ValidateCode Method

IScalarConstraintValidateCode Method
Validates the element of code to which the constraint is applied.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void ValidateCode(
    Object target
)

Parameters

target
Type: SystemObject
Element of code to which the constraint is applied (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IScalarConstraint Interface
PostSharp.Constraints Namespace


ProtectedAttribute Class

ProtectedAttribute Class
Custom attribute that, when applied to a target declaration, causes PostSharp to emit a warning if the declaration is being referenced from classes that are not derived from the target class. This constraint is similar to the C# keyword protected and should be used only when the target declaration must be made public or internal for non-architectural reasons.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.ConstraintsConstraint
PostSharp.ConstraintsReferentialConstraint
PostSharp.ConstraintsProtectedAttribute

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ProtectedAttribute : ReferentialConstraint

The ProtectedAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ProtectedAttribute | Initializes a new ProtectedAttribute.
Top
Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint. (Overrides ReferentialConstraintValidateCode(Object, Assembly).)
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Overrides ConstraintValidateConstraint(Object).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Severity | Gets or sets the severity of messages emitted by this constraint.
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace


ProtectedAttribute Constructor

ProtectedAttribute Constructor
Initializes a new ProtectedAttribute.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ProtectedAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProtectedAttribute Class
PostSharp.Constraints Namespace


ProtectedAttribute Methods

ProtectedAttribute Methods

The ProtectedAttribute type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint. (Overrides ReferentialConstraintValidateCode(Object, Assembly).)
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Overrides ConstraintValidateConstraint(Object).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ProtectedAttribute Class
PostSharp.Constraints Namespace


ProtectedAttribute.ValidateCode Method

ProtectedAttributeValidateCode Method
Validates the constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void ValidateCode(
    Object target,
    Assembly assembly
)

Parameters

target
Type: SystemObject
Declaration (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo) to which the constraint has been applied.
assembly
Type: System.ReflectionAssembly
The assembly being currently processed.

Implements

IReferentialConstraintValidateCode(Object, Assembly)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProtectedAttribute Class
PostSharp.Constraints Namespace


ProtectedAttribute.ValidateConstraint Method

ProtectedAttributeValidateConstraint Method
Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool ValidateConstraint(
    Object target
)

Parameters

target
Type: SystemObject

Return Value

Type: Boolean
true if the constraint has been applied on a valid element of code, otherwise false.

Implements

IConstraintValidateConstraint(Object)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProtectedAttribute Class
PostSharp.Constraints Namespace


ProtectedAttribute Properties

ProtectedAttribute Properties

The ProtectedAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Severity | Gets or sets the severity of messages emitted by this constraint.
Top
See Also

Reference

ProtectedAttribute Class
PostSharp.Constraints Namespace


ProtectedAttribute.Severity Property

ProtectedAttributeSeverity Property
Gets or sets the severity of messages emitted by this constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SeverityType Severity { get; set; }

Property Value

Type: SeverityType
Remarks

The default value is Warning.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProtectedAttribute Class
PostSharp.Constraints Namespace


ReferentialConstraint Class

ReferentialConstraint Class
Implementation of IReferentialConstraint based on MulticastAttribute.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.ConstraintsConstraint
PostSharp.ConstraintsReferentialConstraint
PostSharp.ConstraintsComponentInternalAttribute
PostSharp.ConstraintsExperimentalAttribute
PostSharp.ConstraintsInternalAttribute
PostSharp.ConstraintsInternalImplementAttribute
PostSharp.ConstraintsProtectedAttribute

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class ReferentialConstraint : Constraint,
    IReferentialConstraint, IConstraint

The ReferentialConstraint type exposes the following members.

Constructors
 | Name | Description
Protected method | ReferentialConstraint | Initializes a new instance of the ReferentialConstraint class
Top
Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint.
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from Constraint.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace


ReferentialConstraint Constructor

ReferentialConstraint Constructor
Initializes a new instance of the ReferentialConstraint class

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected ReferentialConstraint()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReferentialConstraint Class
PostSharp.Constraints Namespace


ReferentialConstraint Methods

ReferentialConstraint Methods

The ReferentialConstraint type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the constraint.
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from Constraint.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReferentialConstraint Class
PostSharp.Constraints Namespace


ReferentialConstraint.ValidateCode Method

ReferentialConstraintValidateCode Method
Validates the constraint.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void ValidateCode(
    Object target,
    Assembly assembly
)

Parameters

target
Type: SystemObject
Declaration (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo) to which the constraint has been applied.
assembly
Type: System.ReflectionAssembly
The assembly being currently processed.

Implements

IReferentialConstraintValidateCode(Object, Assembly)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReferentialConstraint Class
PostSharp.Constraints Namespace


ReferentialConstraint Properties

ReferentialConstraint Properties

The ReferentialConstraint type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

ReferentialConstraint Class
PostSharp.Constraints Namespace


ScalarConstraint Class

ScalarConstraint Class
Implementation of IScalarConstraint based on MulticastAttribute.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.ConstraintsConstraint
PostSharp.ConstraintsScalarConstraint

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class ScalarConstraint : Constraint,
    IScalarConstraint, IConstraint

The ScalarConstraint type exposes the following members.

Constructors
 | Name | Description
Public method | ScalarConstraint | Initializes a new instance of the ScalarConstraint class
Top
Methods
 | Name | Description
Public method | ValidateCode | Validates the element of code to which the constraint is applied.
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from Constraint.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Constraints Namespace


ScalarConstraint Constructor

ScalarConstraint Constructor
Initializes a new instance of the ScalarConstraint class

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ScalarConstraint()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ScalarConstraint Class
PostSharp.Constraints Namespace


ScalarConstraint Methods

ScalarConstraint Methods

The ScalarConstraint type exposes the following members.

Methods
 | Name | Description
Public method | ValidateCode | Validates the element of code to which the constraint is applied.
Public method | ValidateConstraint | Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored. (Inherited from Constraint.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ScalarConstraint Class
PostSharp.Constraints Namespace


ScalarConstraint.ValidateCode Method

ScalarConstraintValidateCode Method
Validates the element of code to which the constraint is applied.

Namespace: PostSharp.Constraints
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void ValidateCode(
    Object target
)

Parameters

target
Type: SystemObject
Element of code to which the constraint is applied (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo).

Implements

IScalarConstraintValidateCode(Object)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ScalarConstraint Class
PostSharp.Constraints Namespace


ScalarConstraint Properties

ScalarConstraint Properties

The ScalarConstraint type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

ScalarConstraint Class
PostSharp.Constraints Namespace


PostSharp.Extensibility Namespace

PostSharp.Extensibility Namespace
The PostSharp.Extensibility namespace defines the semantics of the attribute multicasting mechanism and exposes other types that allow user code to interact with the PostSharp,platform.
Classes
 | Class | Description
Public class | AssemblyIdAttribute | Assigns a unique identifier to an assembly. This assembly identifier is used to generate unique attribute identifiers.
Public class | CompatibilityLevelAttribute | Sets the level of backward compatibility required by aspects in the current assembly.
Public class | EnhancedByPostSharpAttribute | Obsolete. Custom attribute added to the assembly manifest of modules processed by PostSharp.
Public class | EscalatePostSharpMessageAttribute | Custom attribute that, when applied on an assembly, means that a given message should be escalated to an error during the current PostSharp session.
Public class | FrameworkVariants | Obsolete. Defines constants identifying the different variants of the .NET Framework (Full, Compact, Silverlight).
Public class | HasInheritedAttributeAttribute | Internal Only. Custom attribute used internally by PostSharp to mark elements having inherited custom attributes. This custom attribute should not be used in custom code, otherwise PostSharp may not work properly.
Public class | ImplementationBoundAttributeAttribute | Custom attribute meaning that custom attributes of a given type are bound to the implementation, not to the semantics.
Public class | InvalidAnnotationException | Exception thrown at build time by implementation of CompileTimeValidate(Object) when an annotation is invalid.
Public class | Message | Encapsulates a message (error, warning, info, ...).
Public class | MessageDispenser | Provides a base implementation of IMessageDispenser where the message key is supposed to be in format PRE0000, where PRE is a prefix and 0000 is an integer. Keys for help URLs have the format PRE0000?.
Public class | MessageException | Exception embedding a Message.
Public class | MessageSource | Provides commodity methods to work with an IMessageSink.
Public class | MetricAttribute | Custom attribute that, when applied on an aspect, causes the aspect to increment some metric at build time.
Public class | MulticastAttribute | Custom attribute that can be applied to multiple elements using wildcards.
Public class | MulticastAttributeUsageAttribute | Custom attribute that determines the usage of a MulticastAttribute.
Public class | PostSharpEnvironment | Provides access to the current PostSharp environment (IPostSharpEnvironment).
Public class | PostSharpTrace | Provides tracing functionality. An instance of the PostSharpTrace type implements a trace sink.
Public class | ProjectExtensionElement | Represents a custom element (or section) in the XML project type.
Public class | ProjectResource | Represents an element of a resource section, i.e. a named object deserialized from XML.
Public class | RequirePostSharpAttribute | Custom attribute that, when applied on another custom attribute (a class derived from Attribute), means that assemblies with elements annotated with that custom attribute should be processed by PostSharp.
Public class | RequireReflectionWrapperAttribute | Obsolete. Custom attribute that, when applied on a type, specifies that all build-time semantics of this type require reflection wrappers to be passed instead of real reflection objects.
Public class | SuppressAnnotationValidationAttribute | Instructs PostSharp that the validation of IValidableAnnotation is done by another component, and should not be processed by the default component.
Structures
 | Structure | Description
Public structure | TargetFrameworkFamily | Represents a variant of family (variant) of the .NET Framework, e.g. NetCore, NetFramework, Silverlight or NetPortable.
Interfaces
 | Interface | Description
Public interface | IMessageDispenser | Gets a text given its key.
Public interface | IMessageSink | Receives messages.
Public interface | IPostSharpEnvironment | Provides information about the current PostSharp environment.
Public interface | IProject | Provides information about the currently executing project.
Public interface | IReflectionBindingManagerService | Exposes the ResolveAssembly(Type) method, which gets the reference identity of the assembly declaring a given type.
Public interface | IService | A service exposed by the build-time part of PostSharp.
Public interface | IServiceLocator | Exposes build-time services.
Public interface | ITargetFramework | Represents a version and variant of the .NET framework (running on a device) on which the project being built is design to run.
Public interface | IValidableAnnotation | Interface that, when implemented by a custom attribute (Attribute), causes PostSharp to invoke a validation method for every instance of that custom attribute.
Enumerations
 | Enumeration | Description
Public enumeration | AssemblyLoadContext | Enumeration of contexts in which assemblies can be loaded.
Public enumeration | CompatibilityLevel | Enumeration of standard levels of backward compatibility.
Public enumeration | MulticastAttributes | Attributes of elements to which multicast custom attributes (MulticastAttribute) apply.
Public enumeration | MulticastInheritance | Kind of inheritance of MulticastAttribute.
Public enumeration | MulticastTargets | Kinds of targets to which multicast custom attributes (MulticastAttribute) can apply.
Public enumeration | SeverityType | Types of message severities.


AssemblyIdAttribute Class

AssemblyIdAttribute Class
Assigns a unique identifier to an assembly. This assembly identifier is used to generate unique attribute identifiers.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityAssemblyIdAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AssemblyIdAttribute : Attribute

The AssemblyIdAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | AssemblyIdAttribute | Initializes a new AssemblyIdAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
By default, the assembly identifier is computed from the module name (by using the first 4 bytes of the MD5 sum of the module name).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


AssemblyIdAttribute Constructor

AssemblyIdAttribute Constructor
Initializes a new AssemblyIdAttribute.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AssemblyIdAttribute(
    int id
)

Parameters

id
Type: SystemInt32
Assembly identifier.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

AssemblyIdAttribute Class
PostSharp.Extensibility Namespace


AssemblyIdAttribute Methods

AssemblyIdAttribute Methods

The AssemblyIdAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AssemblyIdAttribute Class
PostSharp.Extensibility Namespace


AssemblyLoadContext Enumeration

AssemblyLoadContext Enumeration
Enumeration of contexts in which assemblies can be loaded.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum AssemblyLoadContext
Members
Member name | Value | Description
Reference | 0 | Reference assemblies the ones the project is being linked against. They are typically located in directory C:\Program Files\Reference Assemblies for the proper target platform.
Runtime | 1 | Runtime assemblies are the ones loaded at build time in the CLR. They are typically located in GAC.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


CompatibilityLevel Enumeration

CompatibilityLevel Enumeration
Enumeration of standard levels of backward compatibility.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum CompatibilityLevel
Members
Member name | Value | Description
Undefined | 0 | No compatibility level defined (latest at execution time).
PostSharp30 | 844424930131968 | Compatibility level for PostSharp 3.0.
Latest | 844424930131968 | Latest at build time.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


CompatibilityLevelAttribute Class

CompatibilityLevelAttribute Class
Sets the level of backward compatibility required by aspects in the current assembly.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityCompatibilityLevelAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class CompatibilityLevelAttribute : Attribute

The CompatibilityLevelAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | CompatibilityLevelAttribute | Initializes a new CompatibilityLevelAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


CompatibilityLevelAttribute Constructor

CompatibilityLevelAttribute Constructor
Initializes a new CompatibilityLevelAttribute.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public CompatibilityLevelAttribute(
    CompatibilityLevel level
)

Parameters

level
Type: PostSharp.ExtensibilityCompatibilityLevel
Level of backward compatibility required by aspects in the current assembly.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CompatibilityLevelAttribute Class
PostSharp.Extensibility Namespace


CompatibilityLevelAttribute Methods

CompatibilityLevelAttribute Methods

The CompatibilityLevelAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CompatibilityLevelAttribute Class
PostSharp.Extensibility Namespace


EnhancedByPostSharpAttribute Class

EnhancedByPostSharpAttribute Class

Note: This API is now obsolete.

Custom attribute added to the assembly manifest of modules processed by PostSharp.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityEnhancedByPostSharpAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute]
public sealed class EnhancedByPostSharpAttribute : Attribute

The EnhancedByPostSharpAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | EnhancedByPostSharpAttribute(Int32) | Instantiates a new EnhancedByPostSharpAttribute and specifies the license number (not the full license key).
Public method | EnhancedByPostSharpAttribute(String) | Instantiate a new EnhancedByPostSharpAttribute with a text message, typically used when PostSharp runs in evaluation mode.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

PostSharp.Extensibility Namespace


EnhancedByPostSharpAttribute Constructor

EnhancedByPostSharpAttribute Constructor
Overload List
 | Name | Description
Public method | EnhancedByPostSharpAttribute(Int32) | Instantiates a new EnhancedByPostSharpAttribute and specifies the license number (not the full license key).
Public method | EnhancedByPostSharpAttribute(String) | Instantiate a new EnhancedByPostSharpAttribute with a text message, typically used when PostSharp runs in evaluation mode.
Top
See Also

Reference

EnhancedByPostSharpAttribute Class
PostSharp.Extensibility Namespace


EnhancedByPostSharpAttribute Constructor (Int32)

EnhancedByPostSharpAttribute Constructor (Int32)
Instantiates a new EnhancedByPostSharpAttribute and specifies the license number (not the full license key).

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EnhancedByPostSharpAttribute(
    int licenseId
)

Parameters

licenseId
Type: SystemInt32
License number.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EnhancedByPostSharpAttribute Class
EnhancedByPostSharpAttribute Overload
PostSharp.Extensibility Namespace


EnhancedByPostSharpAttribute Constructor (String)

EnhancedByPostSharpAttribute Constructor (String)
Instantiate a new EnhancedByPostSharpAttribute with a text message, typically used when PostSharp runs in evaluation mode.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EnhancedByPostSharpAttribute(
    string message
)

Parameters

message
Type: SystemString
The watermark text.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EnhancedByPostSharpAttribute Class
EnhancedByPostSharpAttribute Overload
PostSharp.Extensibility Namespace


EnhancedByPostSharpAttribute Methods

EnhancedByPostSharpAttribute Methods

The EnhancedByPostSharpAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EnhancedByPostSharpAttribute Class
PostSharp.Extensibility Namespace


EscalatePostSharpMessageAttribute Class

EscalatePostSharpMessageAttribute Class
Custom attribute that, when applied on an assembly, means that a given message should be escalated to an error during the current PostSharp session.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityEscalatePostSharpMessageAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class EscalatePostSharpMessageAttribute : Attribute

The EscalatePostSharpMessageAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | EscalatePostSharpMessageAttribute | Initializes a new EscalatePostSharpMessageAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | MessageId | Gets the identifier of the message to be disabled.
Top
Remarks
Errors and fatal errors cannot be disabled.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


EscalatePostSharpMessageAttribute Constructor

EscalatePostSharpMessageAttribute Constructor
Initializes a new EscalatePostSharpMessageAttribute.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EscalatePostSharpMessageAttribute(
    string messageId
)

Parameters

messageId
Type: SystemString
Identifier of the message to be disabled.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EscalatePostSharpMessageAttribute Class
PostSharp.Extensibility Namespace


EscalatePostSharpMessageAttribute Methods

EscalatePostSharpMessageAttribute Methods

The EscalatePostSharpMessageAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EscalatePostSharpMessageAttribute Class
PostSharp.Extensibility Namespace


EscalatePostSharpMessageAttribute Properties

EscalatePostSharpMessageAttribute Properties

The EscalatePostSharpMessageAttribute type exposes the following members.

Properties
 | Name | Description
Public property | MessageId | Gets the identifier of the message to be disabled.
Top
See Also

Reference

EscalatePostSharpMessageAttribute Class
PostSharp.Extensibility Namespace


EscalatePostSharpMessageAttribute.MessageId Property

EscalatePostSharpMessageAttributeMessageId Property
Gets the identifier of the message to be disabled.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string MessageId { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EscalatePostSharpMessageAttribute Class
PostSharp.Extensibility Namespace


FrameworkVariants Class

FrameworkVariants Class

Note: This API is now obsolete.

Defines constants identifying the different variants of the .NET Framework (Full, Compact, Silverlight).
Inheritance Hierarchy
SystemObject
PostSharp.ExtensibilityFrameworkVariants

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use ITargetDevice")]
public static class FrameworkVariants

The FrameworkVariants type exposes the following members.

Methods
Name | Description
FromBytes | Convert a byte array (typically containing the public key token of mscorlib) into a string that can be compared to one of the constants defined in this class.
Top
Fields
Name | Description
Compact | .NET Compact Framework.
Full | Normal, full .NET Framework.
Micro | Micro Framework.
Silverlight | Silverlight.
Top
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

PostSharp.Extensibility Namespace


FrameworkVariants Fields

FrameworkVariants Fields

The FrameworkVariants type exposes the following members.

Fields
Name | Description
Compact | .NET Compact Framework.
Full | Normal, full .NET Framework.
Micro | Micro Framework.
Silverlight | Silverlight.
Top
See Also

Reference

FrameworkVariants Class
PostSharp.Extensibility Namespace


FrameworkVariants.Compact Field

FrameworkVariantsCompact Field
.NET Compact Framework.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Compact

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FrameworkVariants Class
PostSharp.Extensibility Namespace


FrameworkVariants.Full Field

FrameworkVariantsFull Field
Normal, full .NET Framework.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Full

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FrameworkVariants Class
PostSharp.Extensibility Namespace


FrameworkVariants.Micro Field

FrameworkVariantsMicro Field
Micro Framework.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Micro

Field Value

Type: String
Remarks
There is strong name in the Micro Framework.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FrameworkVariants Class
PostSharp.Extensibility Namespace


FrameworkVariants.Silverlight Field

FrameworkVariantsSilverlight Field
Silverlight.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string Silverlight

Field Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FrameworkVariants Class
PostSharp.Extensibility Namespace


FrameworkVariants Methods

FrameworkVariants Methods

The FrameworkVariants type exposes the following members.

Methods
Name | Description
FromBytes | Convert a byte array (typically containing the public key token of mscorlib) into a string that can be compared to one of the constants defined in this class.
Top
See Also

Reference

FrameworkVariants Class
PostSharp.Extensibility Namespace


FrameworkVariants.FromBytes Method

FrameworkVariantsFromBytes Method
Convert a byte array (typically containing the public key token of mscorlib) into a string that can be compared to one of the constants defined in this class.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static string FromBytes(
    byte[] bytes
)

Parameters

bytes
Type: SystemByte
A byte array (typically containing the public key token of mscorlib)

Return Value

Type: String
A string that can be compared to one of the constants defined in this class
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

FrameworkVariants Class
PostSharp.Extensibility Namespace


HasInheritedAttributeAttribute Class

HasInheritedAttributeAttribute Class
Internal Only. Custom attribute used internally by PostSharp to mark elements having inherited custom attributes. This custom attribute should not be used in custom code, otherwise PostSharp may not work properly.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityHasInheritedAttributeAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class HasInheritedAttributeAttribute : Attribute
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


IMessageDispenser Interface

IMessageDispenser Interface
Gets a text given its key.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMessageDispenser

The IMessageDispenser type exposes the following members.

Methods
 | Name | Description
Public method | GetMessage | Gets a message text given a message key.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace
PostSharp.ExtensibilityMessageDispenser


IMessageDispenser Methods

IMessageDispenser Methods

The IMessageDispenser type exposes the following members.

Methods
 | Name | Description
Public method | GetMessage | Gets a message text given a message key.
Top
See Also

Reference

IMessageDispenser Interface
PostSharp.Extensibility Namespace


IMessageDispenser.GetMessage Method

IMessageDispenserGetMessage Method
Gets a message text given a message key.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string GetMessage(
    string key
)

Parameters

key
Type: SystemString
Message key.

Return Value

Type: String
The text corresponding to key.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMessageDispenser Interface
PostSharp.Extensibility Namespace


IMessageSink Interface

IMessageSink Interface
Receives messages.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMessageSink

The IMessageSink type exposes the following members.

Methods
 | Name | Description
Public method | Write | Writes a message to the sink.
Top
Remarks
Use this interface instead of events for cross-domain communication.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


IMessageSink Methods

IMessageSink Methods

The IMessageSink type exposes the following members.

Methods
 | Name | Description
Public method | Write | Writes a message to the sink.
Top
See Also

Reference

IMessageSink Interface
PostSharp.Extensibility Namespace


IMessageSink.Write Method

IMessageSinkWrite Method
Writes a message to the sink.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void Write(
    Message message
)

Parameters

message
Type: PostSharp.ExtensibilityMessage
A message.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMessageSink Interface
PostSharp.Extensibility Namespace


ImplementationBoundAttributeAttribute Class

ImplementationBoundAttributeAttribute Class
Custom attribute meaning that custom attributes of a given type are bound to the implementation, not to the semantics.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityImplementationBoundAttributeAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ImplementationBoundAttributeAttribute : Attribute

The ImplementationBoundAttributeAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ImplementationBoundAttributeAttribute | Initializes the new ImplementationBoundAttributeAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeType | Gets the type of the custom attribute that should not be moved from implementation to semantic
Top
Remarks

This custom attribute influences whether instances of a given other custom attribute should be moved from the semantic to the implementation, when the semantic is detached from the implementation. This happens for instance when a property is generated from a field; the property become the semantic (and is made public) and the field the implementation (and is made private). Most custom attributes apply to semantics, so they are moved from the field to the property. If a custom attribute must not be moved, it should be marked with the ImplementationBoundAttributeAttribute custom attribute.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


ImplementationBoundAttributeAttribute Constructor

ImplementationBoundAttributeAttribute Constructor
Initializes the new ImplementationBoundAttributeAttribute.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ImplementationBoundAttributeAttribute(
    Type attributeType
)

Parameters

attributeType
Type: SystemType
Type of the custom attribute that should not be moved from implementation to semantic.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ImplementationBoundAttributeAttribute Class
PostSharp.Extensibility Namespace


ImplementationBoundAttributeAttribute Methods

ImplementationBoundAttributeAttribute Methods

The ImplementationBoundAttributeAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ImplementationBoundAttributeAttribute Class
PostSharp.Extensibility Namespace


ImplementationBoundAttributeAttribute Properties

ImplementationBoundAttributeAttribute Properties

The ImplementationBoundAttributeAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeType | Gets the type of the custom attribute that should not be moved from implementation to semantic
Top
See Also

Reference

ImplementationBoundAttributeAttribute Class
PostSharp.Extensibility Namespace


ImplementationBoundAttributeAttribute.AttributeType Property

ImplementationBoundAttributeAttributeAttributeType Property
Gets the type of the custom attribute that should not be moved from implementation to semantic

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type AttributeType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ImplementationBoundAttributeAttribute Class
PostSharp.Extensibility Namespace


InvalidAnnotationException Class

InvalidAnnotationException Class
Exception thrown at build time by implementation of CompileTimeValidate(Object) when an annotation is invalid.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.ExtensibilityInvalidAnnotationException

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public class InvalidAnnotationException : Exception

The InvalidAnnotationException type exposes the following members.

Constructors
 | Name | Description
Public method | InvalidAnnotationException | Initializes a new InvalidAnnotationException with default message.
Public method | InvalidAnnotationException(String) | Initializes a new InvalidAnnotationException and with a specified exception message.
Protected method | InvalidAnnotationException(SerializationInfo, StreamingContext) | Deserialization constructor.
Public method | InvalidAnnotationException(String, Exception) | Initializes a new InvalidAnnotationException with a specified exception message and inner Exception.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


InvalidAnnotationException Constructor

InvalidAnnotationException Constructor
Overload List
 | Name | Description
Public method | InvalidAnnotationException | Initializes a new InvalidAnnotationException with default message.
Public method | InvalidAnnotationException(String) | Initializes a new InvalidAnnotationException and with a specified exception message.
Protected method | InvalidAnnotationException(SerializationInfo, StreamingContext) | Deserialization constructor.
Public method | InvalidAnnotationException(String, Exception) | Initializes a new InvalidAnnotationException with a specified exception message and inner Exception.
Top
See Also

Reference

InvalidAnnotationException Class
PostSharp.Extensibility Namespace


InvalidAnnotationException Constructor

InvalidAnnotationException Constructor
Initializes a new InvalidAnnotationException with default message.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InvalidAnnotationException()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InvalidAnnotationException Class
InvalidAnnotationException Overload
PostSharp.Extensibility Namespace


InvalidAnnotationException Constructor (String)

InvalidAnnotationException Constructor (String)
Initializes a new InvalidAnnotationException and with a specified exception message.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InvalidAnnotationException(
    string message
)

Parameters

message
Type: SystemString
Exception message
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InvalidAnnotationException Class
InvalidAnnotationException Overload
PostSharp.Extensibility Namespace


InvalidAnnotationException Constructor (SerializationInfo, StreamingContext)

InvalidAnnotationException Constructor (SerializationInfo, StreamingContext)
Deserialization constructor.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected InvalidAnnotationException(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
Info.
context
Type: System.Runtime.SerializationStreamingContext
Context.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InvalidAnnotationException Class
InvalidAnnotationException Overload
PostSharp.Extensibility Namespace


InvalidAnnotationException Constructor (String, Exception)

InvalidAnnotationException Constructor (String, Exception)
Initializes a new InvalidAnnotationException with a specified exception message and inner Exception.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public InvalidAnnotationException(
    string message,
    Exception inner
)

Parameters

message
Type: SystemString
Exception message.
inner
Type: SystemException
Inner exception.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InvalidAnnotationException Class
InvalidAnnotationException Overload
PostSharp.Extensibility Namespace


InvalidAnnotationException Methods

InvalidAnnotationException Methods

The InvalidAnnotationException type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

InvalidAnnotationException Class
PostSharp.Extensibility Namespace


IPostSharpEnvironment Interface

IPostSharpEnvironment Interface
Provides information about the current PostSharp environment.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IPostSharpEnvironment

The IPostSharpEnvironment type exposes the following members.

Methods
 | Name | Description
Public method | FindAssembly(AssemblyName) | Obsolete.
Public method | FindAssembly(AssemblyName, AssemblyLoadContext) | Finds the location of an assembly given its name.
Public method | LoadAssemblyFromFile | Loads an Assembly given its file name.
Top
Properties
 | Name | Description
Public property | CurrentProject | Gets the currently executing project.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


IPostSharpEnvironment Methods

IPostSharpEnvironment Methods

The IPostSharpEnvironment type exposes the following members.

Methods
 | Name | Description
Public method | FindAssembly(AssemblyName) | Obsolete.
Public method | FindAssembly(AssemblyName, AssemblyLoadContext) | Finds the location of an assembly given its name.
Public method | LoadAssemblyFromFile | Loads an Assembly given its file name.
Top
See Also

Reference

IPostSharpEnvironment Interface
PostSharp.Extensibility Namespace


IPostSharpEnvironment.FindAssembly Method

IPostSharpEnvironmentFindAssembly Method
Overload List
 | Name | Description
Public method | FindAssembly(AssemblyName) | Obsolete.
Public method | FindAssembly(AssemblyName, AssemblyLoadContext) | Finds the location of an assembly given its name.
Top
See Also

Reference

IPostSharpEnvironment Interface
PostSharp.Extensibility Namespace


IPostSharpEnvironment.FindAssembly Method (AssemblyName)

IPostSharpEnvironmentFindAssembly Method (AssemblyName)

Note: This API is now obsolete.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use the second overload.")]
string FindAssembly(
    AssemblyName name
)

Parameters

name
Type: System.ReflectionAssemblyName

Return Value

Type: String
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

IPostSharpEnvironment Interface
FindAssembly Overload
PostSharp.Extensibility Namespace


IPostSharpEnvironment.FindAssembly Method (AssemblyName, AssemblyLoadContext)

IPostSharpEnvironmentFindAssembly Method (AssemblyName, AssemblyLoadContext)
Finds the location of an assembly given its name.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string FindAssembly(
    AssemblyName name,
    AssemblyLoadContext loadContext
)

Parameters

name
Type: System.ReflectionAssemblyName
Assembly name.
loadContext
Type: PostSharp.ExtensibilityAssemblyLoadContext
Reference or Runtime.

Return Value

Type: String
The full path of the assembly, or null if the assembly could not be found.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IPostSharpEnvironment Interface
FindAssembly Overload
PostSharp.Extensibility Namespace


IPostSharpEnvironment.LoadAssemblyFromFile Method

IPostSharpEnvironmentLoadAssemblyFromFile Method
Loads an Assembly given its file name.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Assembly LoadAssemblyFromFile(
    string fileName
)

Parameters

fileName
Type: SystemString
Full assembly path.

Return Value

Type: Assembly
The Assembly.
Remarks

Use this method instead of LoadFile(String).

Note Note
You cannot load two assemblies with a different path and the same identity (strong name) into PostSharp.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IPostSharpEnvironment Interface
PostSharp.Extensibility Namespace


IPostSharpEnvironment Properties

IPostSharpEnvironment Properties

The IPostSharpEnvironment type exposes the following members.

Properties
 | Name | Description
Public property | CurrentProject | Gets the currently executing project.
Top
See Also

Reference

IPostSharpEnvironment Interface
PostSharp.Extensibility Namespace


IPostSharpEnvironment.CurrentProject Property

IPostSharpEnvironmentCurrentProject Property
Gets the currently executing project.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IProject CurrentProject { get; }

Property Value

Type: IProject
The current project, or null if there is no current project.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IPostSharpEnvironment Interface
PostSharp.Extensibility Namespace


IProject Interface

IProject Interface
Provides information about the currently executing project.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IProject : IServiceLocator,
    IService

The IProject type exposes the following members.

Methods
 | Name | Description
Public method | EvaluateExpression | Evaluates an expression (that is, replace parameters by their actual value).
Public method | GetExtensionElements | Gets the set of project extension elements (ProjectExtensionElement) given their name and XML namespace.
Public method | GetFrameworkVariant | Obsolete. Gets the variant of the .NET Framework against which the .NET assembly currently processed is linked.
Public method | GetServiceT | Gets a build-time service exposed by PostSharp.
Public method | GetTargetAssembly | Gets the assembly that is being transformed by PostSharp.
Top
Properties
 | Name | Description
Public property | TargetFramework | Gets the variant and version of the .NET Framework that the assembly being built targets.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


IProject Methods

IProject Methods

The IProject type exposes the following members.

Methods
 | Name | Description
Public method | EvaluateExpression | Evaluates an expression (that is, replace parameters by their actual value).
Public method | GetExtensionElements | Gets the set of project extension elements (ProjectExtensionElement) given their name and XML namespace.
Public method | GetFrameworkVariant | Obsolete. Gets the variant of the .NET Framework against which the .NET assembly currently processed is linked.
Public method | GetServiceT | Gets a build-time service exposed by PostSharp.
Public method | GetTargetAssembly | Gets the assembly that is being transformed by PostSharp.
Top
See Also

Reference

IProject Interface
PostSharp.Extensibility Namespace


IProject.EvaluateExpression Method

IProjectEvaluateExpression Method
Evaluates an expression (that is, replace parameters by their actual value).

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string EvaluateExpression(
    string expression
)

Parameters

expression
Type: SystemString
An expression.

Return Value

Type: String
The evaluated expression, or null if one parameter could not be resolved.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IProject Interface
PostSharp.Extensibility Namespace


IProject.GetExtensionElements Method

IProjectGetExtensionElements Method
Gets the set of project extension elements (ProjectExtensionElement) given their name and XML namespace.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IEnumerable<ProjectExtensionElement> GetExtensionElements(
    string name,
    string ns
)

Parameters

name
Type: SystemString
Local name of the project extension element.
ns
Type: SystemString
XML namespace of the project extension element.

Return Value

Type: IEnumerable ProjectExtensionElement
The set of project elements named name in all loaded projects.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IProject Interface
PostSharp.Extensibility Namespace


IProject.GetFrameworkVariant Method

IProjectGetFrameworkVariant Method

Note: This API is now obsolete.

Gets the variant of the .NET Framework against which the .NET assembly currently processed is linked.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use TargetDevice property.")]
string GetFrameworkVariant()

Return Value

Type: String
A string uniquely identifying the framework variant, to be compared to the constants defined in the FrameworkVariants class. Actually, the public key token of mscorlib is returned.
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

IProject Interface
PostSharp.Extensibility Namespace


IProject.GetService(T) Method

IProjectGetServiceT Method
Gets a build-time service exposed by PostSharp.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
T GetService<T>(
    bool throwing = true
)
where T : class, IService

Parameters

throwing (Optional)
Type: SystemBoolean
true whether an exception should be thrown in case the service cannot be acquired, otherwise false. The default value is true.

Type Parameters

T
An interface derived from IService.

Return Value

Type: T
The service T, or null if the service could not be acquired and throwing was set to false.

Implements

IServiceLocatorGetServiceT(Boolean)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IProject Interface
PostSharp.Extensibility Namespace


IProject.GetTargetAssembly Method

IProjectGetTargetAssembly Method
Gets the assembly that is being transformed by PostSharp.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Assembly GetTargetAssembly(
    bool reflectionOnly = false
)

Parameters

reflectionOnly (Optional)
Type: SystemBoolean
false if the system Assembly has to be returned, true if a wrapper has to be returned.

Return Value

Type: Assembly
The assembly being processed. If reflectionOnly is true, this method returns an instance of a PostSharp internal type implementing the Assembly interface. Otherwise, the reflection Assembly is returned.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IProject Interface
PostSharp.Extensibility Namespace


IProject Properties

IProject Properties

The IProject type exposes the following members.

Properties
 | Name | Description
Public property | TargetFramework | Gets the variant and version of the .NET Framework that the assembly being built targets.
Top
See Also

Reference

IProject Interface
PostSharp.Extensibility Namespace


IProject.TargetFramework Property

IProjectTargetFramework Property
Gets the variant and version of the .NET Framework that the assembly being built targets.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ITargetFramework TargetFramework { get; }

Property Value

Type: ITargetFramework
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IProject Interface
PostSharp.Extensibility Namespace


IReflectionBindingManagerService Interface

IReflectionBindingManagerService Interface
Exposes the ResolveAssembly(Type) method, which gets the reference identity of the assembly declaring a given type.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IReflectionBindingManagerService : IService

The IReflectionBindingManagerService type exposes the following members.

Methods
 | Name | Description
Public method | ResolveAssembly | Returns the reference identity of the assembly declaring a type.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


IReflectionBindingManagerService Methods

IReflectionBindingManagerService Methods

The IReflectionBindingManagerService type exposes the following members.

Methods
 | Name | Description
Public method | ResolveAssembly | Returns the reference identity of the assembly declaring a type.
Top
See Also

Reference

IReflectionBindingManagerService Interface
PostSharp.Extensibility Namespace


IReflectionBindingManagerService.ResolveAssembly Method

IReflectionBindingManagerServiceResolveAssembly Method
Returns the reference identity of the assembly declaring a type.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string ResolveAssembly(
    Type type
)

Parameters

type
Type: SystemType
A Type.

Return Value

Type: String
The identity of the reference assembly defining Type. This assembly is possibly different than the runtime assembly, which is available from the Assembly property of the Type class. This method may return null if type is an internal type of a system assembly.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IReflectionBindingManagerService Interface
PostSharp.Extensibility Namespace


IService Interface

IService Interface
A service exposed by the build-time part of PostSharp.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IService
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


IServiceLocator Interface

IServiceLocator Interface
Exposes build-time services.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IServiceLocator : IService

The IServiceLocator type exposes the following members.

Methods
 | Name | Description
Public method | GetServiceT | Gets a build-time service exposed by PostSharp.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


IServiceLocator Methods

IServiceLocator Methods

The IServiceLocator type exposes the following members.

Methods
 | Name | Description
Public method | GetServiceT | Gets a build-time service exposed by PostSharp.
Top
See Also

Reference

IServiceLocator Interface
PostSharp.Extensibility Namespace


IServiceLocator.GetService(T) Method

IServiceLocatorGetServiceT Method
Gets a build-time service exposed by PostSharp.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
T GetService<T>(
    bool throwing = true
)
where T : class, IService

Parameters

throwing (Optional)
Type: SystemBoolean
true whether an exception should be thrown in case the service cannot be acquired, otherwise false. The default value is true.

Type Parameters

T
An interface derived from IService.

Return Value

Type: T
The service T, or null if the service could not be acquired and throwing was set to false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IServiceLocator Interface
PostSharp.Extensibility Namespace


ITargetFramework Interface

ITargetFramework Interface
Represents a version and variant of the .NET framework (running on a device) on which the project being built is design to run.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ITargetFramework

The ITargetFramework type exposes the following members.

Properties
 | Name | Description
Public property | FrameworkMoniker | Unique string identifier of the target device.
Public property | FrameworkProfile | Gets the target profile of the framework (e.g. WindowsPhone).
Public property | TargetFrameworkFamily | Identifier of the framework family (NetFramework, NetCore, Silverlight, NetPortable).
Public property | Version | Gets the version of the target profile.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


ITargetFramework Properties

ITargetFramework Properties

The ITargetFramework type exposes the following members.

Properties
 | Name | Description
Public property | FrameworkMoniker | Unique string identifier of the target device.
Public property | FrameworkProfile | Gets the target profile of the framework (e.g. WindowsPhone).
Public property | TargetFrameworkFamily | Identifier of the framework family (NetFramework, NetCore, Silverlight, NetPortable).
Public property | Version | Gets the version of the target profile.
Top
See Also

Reference

ITargetFramework Interface
PostSharp.Extensibility Namespace


ITargetFramework.FrameworkMoniker Property

ITargetFrameworkFrameworkMoniker Property
Unique string identifier of the target device.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string FrameworkMoniker { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ITargetFramework Interface
PostSharp.Extensibility Namespace


ITargetFramework.FrameworkProfile Property

ITargetFrameworkFrameworkProfile Property
Gets the target profile of the framework (e.g. WindowsPhone).

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string FrameworkProfile { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ITargetFramework Interface
PostSharp.Extensibility Namespace


ITargetFramework.TargetFrameworkFamily Property

ITargetFrameworkTargetFrameworkFamily Property
Identifier of the framework family (NetFramework, NetCore, Silverlight, NetPortable).

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
TargetFrameworkFamily TargetFrameworkFamily { get; }

Property Value

Type: TargetFrameworkFamily
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ITargetFramework Interface
PostSharp.Extensibility Namespace


ITargetFramework.Version Property

ITargetFrameworkVersion Property
Gets the version of the target profile.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Version Version { get; }

Property Value

Type: Version
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ITargetFramework Interface
PostSharp.Extensibility Namespace


IValidableAnnotation Interface

IValidableAnnotation Interface
Interface that, when implemented by a custom attribute (Attribute), causes PostSharp to invoke a validation method for every instance of that custom attribute.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IValidableAnnotation

The IValidableAnnotation type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


IValidableAnnotation Methods

IValidableAnnotation Methods

The IValidableAnnotation type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
See Also

Reference

IValidableAnnotation Interface
PostSharp.Extensibility Namespace


IValidableAnnotation.CompileTimeValidate Method

IValidableAnnotationCompileTimeValidate Method
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Target element.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.
Remarks
The implementation of this method is expected to emit an error message or an exception of type InvalidAnnotationException in case of error. Only returning false causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IValidableAnnotation Interface
PostSharp.Extensibility Namespace


Message Class

Message Class
Encapsulates a message (error, warning, info, ...).
Inheritance Hierarchy
SystemObject
PostSharp.ExtensibilityMessage

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class Message

The Message type exposes the following members.

Constructors
 | Name | Description
Public method | Message(SeverityType, String, String, String) | Obsolete. Initializes a new Message and specifies only required parameters.
Public method | Message(MessageLocation, SeverityType, String, String, String, String, Exception) | Initializes a new Message and specifies all its properties.
Public method | Message(SeverityType, String, String, String, String, String, Int32, Int32, Exception) | Initializes a new Message and specifies all its properties.
Public method | Message(SeverityType, String, String, String, String, String, Int32, Int32, Int32, Int32, Exception) | Initializes a new Message and specifies all its properties.
Top
Methods
Name | Description
GetExceptionStackMessage | Returns a string composed of the messages of all inner exceptions.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
NotAvailable | When set to the [!:LocationLine] or the [!:LocationColumn] property, means that the value of this property is unknown.
Top
Properties
 | Name | Description
Public property | HelpLink | Gets the help link.
Public property | InnerException | Gets the
Public property | Location | Location of the source code artifact causing the message.
Public property | LocationEndColumn | Gets the end column in the file that caused the message.
Public property | LocationEndLine | Gets the end line in the file that caused the message.
Public property | LocationFile | Gets the name of the file that caused the message.
Public property | LocationStartColumn | Gets the start column in the file that caused the message.
Public property | LocationStartLine | Gets the start line in the file that caused the message.
Public property | MessageId | Gets the message type identifier.
Public property | MessageText | Gets the message formatted text.
Public property | Severity | Gets the message severity.
Public property | Source | Gets or sets the name of the source component.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


Message Constructor

Message Constructor
Overload List
 | Name | Description
Public method | Message(SeverityType, String, String, String) | Obsolete. Initializes a new Message and specifies only required parameters.
Public method | Message(MessageLocation, SeverityType, String, String, String, String, Exception) | Initializes a new Message and specifies all its properties.
Public method | Message(SeverityType, String, String, String, String, String, Int32, Int32, Exception) | Initializes a new Message and specifies all its properties.
Public method | Message(SeverityType, String, String, String, String, String, Int32, Int32, Int32, Int32, Exception) | Initializes a new Message and specifies all its properties.
Top
See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message Constructor (SeverityType, String, String, String)

Message Constructor (SeverityType, String, String, String)

Note: This API is now obsolete.

Initializes a new Message and specifies only required parameters.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use an overload that accepts the target code element.")]
public Message(
    SeverityType severity,
    string messageId,
    string messageText,
    string source
)

Parameters

severity
Type: PostSharp.ExtensibilitySeverityType
Message severity (fatal error, error, info, debug).
messageId
Type: SystemString
Identifier of the message type.
messageText
Type: SystemString
Fully formatted message text.
source
Type: SystemString
Name of the component emitting the message.
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

Message Class
Message Overload
PostSharp.Extensibility Namespace


Message Constructor (MessageLocation, SeverityType, String, String, String, String, Exception)

Message Constructor (MessageLocation, SeverityType, String, String, String, String, Exception)
Initializes a new Message and specifies all its properties.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Message(
    MessageLocation location,
    SeverityType severity,
    string messageId,
    string messageText,
    string helpLink,
    string source,
    Exception innerException
)

Parameters

location
Type: PostSharpMessageLocation
Element of code (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo or ParameterInfo) to which the message applies. When called from PostSharp.Sdk, the parameter can also contain a MetadataDeclaration.
severity
Type: PostSharp.ExtensibilitySeverityType
Message severity (fatal error, error, info, debug).
messageId
Type: SystemString
Identifier of the message type.
messageText
Type: SystemString
Fully formatted message text.
helpLink
Type: SystemString
Link to the help file page associated to this message.
source
Type: SystemString
Name of the component emitting the message.
innerException
Type: SystemException
The Exception that caused this message, or null if this message was not caused by an exception.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
Message Overload
PostSharp.Extensibility Namespace


Message Constructor (SeverityType, String, String, String, String, String, Int32, Int32, Exception)

Message Constructor (SeverityType, String, String, String, String, String, Int32, Int32, Exception)
Initializes a new Message and specifies all its properties.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Message(
    SeverityType severity,
    string messageId,
    string messageText,
    string helpLink,
    string source,
    string locationFile,
    int locationLine,
    int locationColumn,
    Exception innerException
)

Parameters

severity
Type: PostSharp.ExtensibilitySeverityType
Message severity (fatal error, error, info, debug).
messageId
Type: SystemString
Identifier of the message type.
messageText
Type: SystemString
Fully formatted message text.
helpLink
Type: SystemString
Link to the help file page associated to this message.
source
Type: SystemString
Name of the component emitting the message.
locationFile
Type: SystemString
File that caused the error, or null if the file is unknown or does not apply.
locationLine
Type: SystemInt32
Position (line) in the file that caused the error, or NotAvailable if the line is unknown or does not apply.
locationColumn
Type: SystemInt32
Position (column) in the file that caused the error, or NotAvailable if the line is unknown or does not apply.
innerException
Type: SystemException
The Exception that caused this message, or null if this message was not caused by an exception.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
Message Overload
PostSharp.Extensibility Namespace


Message Constructor (SeverityType, String, String, String, String, String, Int32, Int32, Int32, Int32, Exception)

Message Constructor (SeverityType, String, String, String, String, String, Int32, Int32, Int32, Int32, Exception)
Initializes a new Message and specifies all its properties.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Message(
    SeverityType severity,
    string messageId,
    string messageText,
    string helpLink,
    string source,
    string locationFile,
    int locationStartLine,
    int locationStartColumn,
    int locationEndLine,
    int locationEndColumn,
    Exception innerException
)

Parameters

severity
Type: PostSharp.ExtensibilitySeverityType
Message severity (fatal error, error, info, debug).
messageId
Type: SystemString
Identifier of the message type.
messageText
Type: SystemString
Fully formatted message text.
helpLink
Type: SystemString
Link to the help file page associated to this message.
source
Type: SystemString
Name of the component emitting the message.
locationFile
Type: SystemString
File that caused the error, or null if the file is unknown or does not apply.
locationStartLine
Type: SystemInt32
Start position (line) in the file that caused the error, or NotAvailable if the line is unknown or does not apply.
locationStartColumn
Type: SystemInt32
Start position (column) in the file that caused the error, or NotAvailable if the line is unknown or does not apply.
locationEndLine
Type: SystemInt32
End position (line) in the file that caused the error, or NotAvailable if the line is unknown or does not apply.
locationEndColumn
Type: SystemInt32
End position (column) in the file that caused the error, or NotAvailable if the line is unknown or does not apply.
innerException
Type: SystemException
The Exception that caused this message, or null if this message was not caused by an exception.
Version Information

Supported in: 4.1

See Also

Reference

Message Class
Message Overload
PostSharp.Extensibility Namespace


Message Fields

Message Fields

The Message type exposes the following members.

Fields
Name | Description
NotAvailable | When set to the [!:LocationLine] or the [!:LocationColumn] property, means that the value of this property is unknown.
Top
See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.NotAvailable Field

MessageNotAvailable Field
When set to the [!:LocationLine] or the [!:LocationColumn] property, means that the value of this property is unknown.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const int NotAvailable

Field Value

Type: Int32
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message Methods

Message Methods

The Message type exposes the following members.

Methods
Name | Description
GetExceptionStackMessage | Returns a string composed of the messages of all inner exceptions.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.GetExceptionStackMessage Method

MessageGetExceptionStackMessage Method
Returns a string composed of the messages of all inner exceptions.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static string GetExceptionStackMessage(
    Exception outerException
)

Parameters

outerException
Type: SystemException
The outer exception.

Return Value

Type: String
A string composed of the messages of all outerException and all inner exceptions, concatenated by the string -->.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message Properties

Message Properties

The Message type exposes the following members.

Properties
 | Name | Description
Public property | HelpLink | Gets the help link.
Public property | InnerException | Gets the
Public property | Location | Location of the source code artifact causing the message.
Public property | LocationEndColumn | Gets the end column in the file that caused the message.
Public property | LocationEndLine | Gets the end line in the file that caused the message.
Public property | LocationFile | Gets the name of the file that caused the message.
Public property | LocationStartColumn | Gets the start column in the file that caused the message.
Public property | LocationStartLine | Gets the start line in the file that caused the message.
Public property | MessageId | Gets the message type identifier.
Public property | MessageText | Gets the message formatted text.
Public property | Severity | Gets the message severity.
Public property | Source | Gets or sets the name of the source component.
Top
See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.HelpLink Property

MessageHelpLink Property
Gets the help link.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string HelpLink { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.InnerException Property

MessageInnerException Property
Gets the

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Exception InnerException { get; }

Property Value

Type: Exception
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.Location Property

MessageLocation Property
Location of the source code artifact causing the message.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MessageLocation Location { get; set; }

Property Value

Type: MessageLocation
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.LocationEndColumn Property

MessageLocationEndColumn Property
Gets the end column in the file that caused the message.
An integer greater or equal to 1, or NotAvailable if the column is unknown or does not apply.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int LocationEndColumn { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.LocationEndLine Property

MessageLocationEndLine Property
Gets the end line in the file that caused the message.
An integer greater or equal to 1, or NotAvailable if the line is unknown or does not apply.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int LocationEndLine { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.LocationFile Property

MessageLocationFile Property
Gets the name of the file that caused the message.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string LocationFile { get; }

Property Value

Type: String
A full file name, or null if the file name is unknown or not applicable.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.LocationStartColumn Property

MessageLocationStartColumn Property
Gets the start column in the file that caused the message.
An integer greater or equal to 1, or NotAvailable if the column is unknown or does not apply.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int LocationStartColumn { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.LocationStartLine Property

MessageLocationStartLine Property
Gets the start line in the file that caused the message.
An integer greater or equal to 1, or NotAvailable if the line is unknown or does not apply.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int LocationStartLine { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.MessageId Property

MessageMessageId Property
Gets the message type identifier.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string MessageId { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.MessageText Property

MessageMessageText Property
Gets the message formatted text.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string MessageText { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.Severity Property

MessageSeverity Property
Gets the message severity.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SeverityType Severity { get; }

Property Value

Type: SeverityType
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


Message.Source Property

MessageSource Property
Gets or sets the name of the source component.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Source { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Message Class
PostSharp.Extensibility Namespace


MessageDispenser Class

MessageDispenser Class
Provides a base implementation of IMessageDispenser where the message key is supposed to be in format PRE0000, where PRE is a prefix and 0000 is an integer. Keys for help URLs have the format PRE0000?.
Inheritance Hierarchy
SystemObject
PostSharp.ExtensibilityMessageDispenser

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class MessageDispenser : IMessageDispenser

The MessageDispenser type exposes the following members.

Constructors
 | Name | Description
Protected method | MessageDispenser | Initializes a new MessageDispenser.
Top
Methods
 | Name | Description
Protected method | GetHelpUrl | Gets the message help URL of a given number.
Protected method | GetMessage(Int32) | Gets the message text of a given number.
Public method | GetMessage(String) | Gets a message text given a message key.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Prefix | Gets the message prefix.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


MessageDispenser Constructor

MessageDispenser Constructor
Initializes a new MessageDispenser.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected MessageDispenser(
    string prefix
)

Parameters

prefix
Type: SystemString
Prefix of all messages provided by the new dispenser.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageDispenser Class
PostSharp.Extensibility Namespace


MessageDispenser Methods

MessageDispenser Methods

The MessageDispenser type exposes the following members.

Methods
 | Name | Description
Protected method | GetHelpUrl | Gets the message help URL of a given number.
Protected method | GetMessage(Int32) | Gets the message text of a given number.
Public method | GetMessage(String) | Gets a message text given a message key.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MessageDispenser Class
PostSharp.Extensibility Namespace


MessageDispenser.GetHelpUrl Method

MessageDispenserGetHelpUrl Method
Gets the message help URL of a given number.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual string GetHelpUrl(
    int number
)

Parameters

number
Type: SystemInt32
Message number.

Return Value

Type: String
The message help URL corresponding to number.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageDispenser Class
PostSharp.Extensibility Namespace


MessageDispenser.GetMessage Method

MessageDispenserGetMessage Method
Overload List
 | Name | Description
Protected method | GetMessage(Int32) | Gets the message text of a given number.
Public method | GetMessage(String) | Gets a message text given a message key.
Top
See Also

Reference

MessageDispenser Class
PostSharp.Extensibility Namespace


MessageDispenser.GetMessage Method (Int32)

MessageDispenserGetMessage Method (Int32)
Gets the message text of a given number.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected abstract string GetMessage(
    int number
)

Parameters

number
Type: SystemInt32
Message number.

Return Value

Type: String
The message text corresponding to number.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageDispenser Class
GetMessage Overload
PostSharp.Extensibility Namespace


MessageDispenser.GetMessage Method (String)

MessageDispenserGetMessage Method (String)
Gets a message text given a message key.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string GetMessage(
    string key
)

Parameters

key
Type: SystemString
Message key.

Return Value

Type: String
The text corresponding to key.

Implements

IMessageDispenserGetMessage(String)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageDispenser Class
GetMessage Overload
PostSharp.Extensibility Namespace


MessageDispenser Properties

MessageDispenser Properties

The MessageDispenser type exposes the following members.

Properties
 | Name | Description
Public property | Prefix | Gets the message prefix.
Top
See Also

Reference

MessageDispenser Class
PostSharp.Extensibility Namespace


MessageDispenser.Prefix Property

MessageDispenserPrefix Property
Gets the message prefix.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Prefix { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageDispenser Class
PostSharp.Extensibility Namespace


MessageException Class

MessageException Class
Exception embedding a Message.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.ExtensibilityMessageException

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class MessageException : Exception

The MessageException type exposes the following members.

Constructors
 | Name | Description
Public method | MessageException | Initializes a new MessageException from an existing Message.
Top
Methods
 | Name | Description
Public method | GetObjectData | Serializes the current object. (Overrides ExceptionGetObjectData(SerializationInfo, StreamingContext).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | MessageObject | Gets the Message em
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


MessageException Constructor

MessageException Constructor
Initializes a new MessageException from an existing Message.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MessageException(
    Message message
)

Parameters

message
Type: PostSharp.ExtensibilityMessage
A Message.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageException Class
PostSharp.Extensibility Namespace


MessageException Methods

MessageException Methods

The MessageException type exposes the following members.

Methods
 | Name | Description
Public method | GetObjectData | Serializes the current object. (Overrides ExceptionGetObjectData(SerializationInfo, StreamingContext).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MessageException Class
PostSharp.Extensibility Namespace


MessageException.GetObjectData Method

MessageExceptionGetObjectData Method
Serializes the current object.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void GetObjectData(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
Serialization information.
context
Type: System.Runtime.SerializationStreamingContext
Serialization context.

Implements

ISerializableGetObjectData(SerializationInfo, StreamingContext)
_ExceptionGetObjectData(SerializationInfo, StreamingContext)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageException Class
PostSharp.Extensibility Namespace


MessageException Properties

MessageException Properties

The MessageException type exposes the following members.

Properties
 | Name | Description
Public property | MessageObject | Gets the Message em
Top
See Also

Reference

MessageException Class
PostSharp.Extensibility Namespace


MessageException.MessageObject Property

MessageExceptionMessageObject Property
Gets the Message em

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Message MessageObject { get; }

Property Value

Type: Message
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageException Class
PostSharp.Extensibility Namespace


MessageSource Class

MessageSource Class
Provides commodity methods to work with an IMessageSink.
Inheritance Hierarchy
SystemObject
SystemMarshalByRefObject
PostSharp.ExtensibilityMessageSource

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class MessageSource : MarshalByRefObject,
    IMessageSink

The MessageSource type exposes the following members.

Methods
 | Name | Description
Public method | CreateMessage(MessageLocation, SeverityType, String, Exception, Object) | Creates a Message from the current MessageSource.
Public method | CreateMessage(SeverityType, String, Object, String, Int32, Int32, Exception) | Obsolete.
Public method | Write(Message) | Writes a message to the sink.
Public method | Write(SeverityType, String, Object) | Obsolete.
Public method | Write(Assembly, SeverityType, String, Object) | Emits a Message.
Public method | Write(MemberInfo, SeverityType, String, Object) | Emits a Message.
Public method | Write(ParameterInfo, SeverityType, String, Object) | Emits a Message.
Public method | Write(MessageLocation, SeverityType, String, Object) | Emits a Message.
Public method | Write(SeverityType, String, Object, SymbolSequencePoint) | Obsolete.
Public method | Write(SeverityType, String, Object, String) | Obsolete.
Public method | Write(MessageLocation, SeverityType, String, Exception, Object) | Emits a Message and specifies an inner Exception.
Public method | Write(SeverityType, String, Object, String, Int32) | Obsolete.
Public method | Write(SeverityType, String, Object, String, Int32, Int32) | Obsolete.
Public method | Write(SeverityType, String, Object, String, Int32, Int32, Exception) | Obsolete.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
Name | Description
MessageSink | Gets the current message sink.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


MessageSource Methods

MessageSource Methods

The MessageSource type exposes the following members.

Methods
 | Name | Description
Public method | CreateMessage(MessageLocation, SeverityType, String, Exception, Object) | Creates a Message from the current MessageSource.
Public method | CreateMessage(SeverityType, String, Object, String, Int32, Int32, Exception) | Obsolete.
Public method | Write(Message) | Writes a message to the sink.
Public method | Write(SeverityType, String, Object) | Obsolete.
Public method | Write(Assembly, SeverityType, String, Object) | Emits a Message.
Public method | Write(MemberInfo, SeverityType, String, Object) | Emits a Message.
Public method | Write(ParameterInfo, SeverityType, String, Object) | Emits a Message.
Public method | Write(MessageLocation, SeverityType, String, Object) | Emits a Message.
Public method | Write(SeverityType, String, Object, SymbolSequencePoint) | Obsolete.
Public method | Write(SeverityType, String, Object, String) | Obsolete.
Public method | Write(MessageLocation, SeverityType, String, Exception, Object) | Emits a Message and specifies an inner Exception.
Public method | Write(SeverityType, String, Object, String, Int32) | Obsolete.
Public method | Write(SeverityType, String, Object, String, Int32, Int32) | Obsolete.
Public method | Write(SeverityType, String, Object, String, Int32, Int32, Exception) | Obsolete.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MessageSource Class
PostSharp.Extensibility Namespace


MessageSource.CreateMessage Method

MessageSourceCreateMessage Method
Overload List
 | Name | Description
Public method | CreateMessage(MessageLocation, SeverityType, String, Exception, Object) | Creates a Message from the current MessageSource.
Public method | CreateMessage(SeverityType, String, Object, String, Int32, Int32, Exception) | Obsolete.
Top
See Also

Reference

MessageSource Class
PostSharp.Extensibility Namespace


MessageSource.CreateMessage Method (MessageLocation, SeverityType, String, Exception, Object[])

MessageSourceCreateMessage Method (MessageLocation, SeverityType, String, Exception, Object)
Creates a Message from the current MessageSource.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Message CreateMessage(
    MessageLocation location,
    SeverityType severity,
    string messageId,
    Exception innerException,
    params Object[] arguments
)

Parameters

location
Type: PostSharpMessageLocation
Location of the source code artifact causing the message.
severity
Type: PostSharp.ExtensibilitySeverityType
Severity.
messageId
Type: SystemString
Message identifier (resolved by the current MessageSource).
innerException
Type: SystemException
Exception causing the message, or null.
arguments
Type: SystemObject
Arguments of the message text.

Return Value

Type: Message
A Message.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageSource Class
CreateMessage Overload
PostSharp.Extensibility Namespace


MessageSource.CreateMessage Method (SeverityType, String, Object[], String, Int32, Int32, Exception)

MessageSourceCreateMessage Method (SeverityType, String, Object, String, Int32, Int32, Exception)

Note: This API is now obsolete.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use an overload accepting a MessageLocation object.")]
public Message CreateMessage(
    SeverityType severity,
    string messageId,
    Object[] arguments,
    string locationFile,
    int locationLine,
    int locationColumn,
    Exception innerException
)

Parameters

severity
Type: PostSharp.ExtensibilitySeverityType
messageId
Type: SystemString
arguments
Type: SystemObject
locationFile
Type: SystemString
locationLine
Type: SystemInt32
locationColumn
Type: SystemInt32
innerException
Type: SystemException

Return Value

Type: Message
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

MessageSource Class
CreateMessage Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method

MessageSourceWrite Method
Overload List
 | Name | Description
Public method | Write(Message) | Writes a message to the sink.
Public method | Write(SeverityType, String, Object) | Obsolete.
Public method | Write(Assembly, SeverityType, String, Object) | Emits a Message.
Public method | Write(MemberInfo, SeverityType, String, Object) | Emits a Message.
Public method | Write(ParameterInfo, SeverityType, String, Object) | Emits a Message.
Public method | Write(MessageLocation, SeverityType, String, Object) | Emits a Message.
Public method | Write(SeverityType, String, Object, SymbolSequencePoint) | Obsolete.
Public method | Write(SeverityType, String, Object, String) | Obsolete.
Public method | Write(MessageLocation, SeverityType, String, Exception, Object) | Emits a Message and specifies an inner Exception.
Public method | Write(SeverityType, String, Object, String, Int32) | Obsolete.
Public method | Write(SeverityType, String, Object, String, Int32, Int32) | Obsolete.
Public method | Write(SeverityType, String, Object, String, Int32, Int32, Exception) | Obsolete.
Top
See Also

Reference

MessageSource Class
PostSharp.Extensibility Namespace


MessageSource.Write Method (Message)

MessageSourceWrite Method (Message)
Writes a message to the sink.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    Message message
)

Parameters

message
Type: PostSharp.ExtensibilityMessage
A message.

Implements

IMessageSinkWrite(Message)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (SeverityType, String, Object[])

MessageSourceWrite Method (SeverityType, String, Object)

Note: This API is now obsolete.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use an overload that specifies the error location.")]
public void Write(
    SeverityType severity,
    string messageId,
    Object[] arguments
)

Parameters

severity
Type: PostSharp.ExtensibilitySeverityType
messageId
Type: SystemString
arguments
Type: SystemObject
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (Assembly, SeverityType, String, Object[])

MessageSourceWrite Method (Assembly, SeverityType, String, Object)
Emits a Message.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    Assembly codeElement,
    SeverityType severity,
    string messageId,
    params Object[] arguments
)

Parameters

codeElement
Type: System.ReflectionAssembly
Source code artifact that caused the message.
severity
Type: PostSharp.ExtensibilitySeverityType
Message severity (fatal error, error, info, debug).
messageId
Type: SystemString
Identifier of the message type.
arguments
Type: SystemObject
Array of arguments used to format the message text, or null if this message has no argument.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (MemberInfo, SeverityType, String, Object[])

MessageSourceWrite Method (MemberInfo, SeverityType, String, Object)
Emits a Message.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    MemberInfo codeElement,
    SeverityType severity,
    string messageId,
    params Object[] arguments
)

Parameters

codeElement
Type: System.ReflectionMemberInfo
Source code artifact (Type, MethodInfo, ConstructorInfo, FieldInfo, EventInfo, PropertyInfo) that caused the message.
severity
Type: PostSharp.ExtensibilitySeverityType
Message severity (fatal error, error, info, debug).
messageId
Type: SystemString
Identifier of the message type.
arguments
Type: SystemObject
Array of arguments used to format the message text, or null if this message has no argument.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (ParameterInfo, SeverityType, String, Object[])

MessageSourceWrite Method (ParameterInfo, SeverityType, String, Object)
Emits a Message.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    ParameterInfo codeElement,
    SeverityType severity,
    string messageId,
    params Object[] arguments
)

Parameters

codeElement
Type: System.ReflectionParameterInfo
Source code artifact that caused the message.
severity
Type: PostSharp.ExtensibilitySeverityType
Message severity (fatal error, error, info, debug).
messageId
Type: SystemString
Identifier of the message type.
arguments
Type: SystemObject
Array of arguments used to format the message text, or null if this message has no argument.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (MessageLocation, SeverityType, String, Object[])

MessageSourceWrite Method (MessageLocation, SeverityType, String, Object)
Emits a Message.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    MessageLocation location,
    SeverityType severity,
    string messageId,
    params Object[] arguments
)

Parameters

location
Type: PostSharpMessageLocation
Location of the source code artifact that caused the message.
severity
Type: PostSharp.ExtensibilitySeverityType
Message severity (fatal error, error, info, debug).
messageId
Type: SystemString
Identifier of the message type.
arguments
Type: SystemObject
Array of arguments used to format the message text, or null if this message has no argument.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (SeverityType, String, Object[], SymbolSequencePoint)

MessageSourceWrite Method (SeverityType, String, Object, SymbolSequencePoint)

Note: This API is now obsolete.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use an overload accepting a MessageLocation object.")]
public void Write(
    SeverityType severity,
    string messageId,
    Object[] arguments,
    SymbolSequencePoint symbolSequencePoint
)

Parameters

severity
Type: PostSharp.ExtensibilitySeverityType
messageId
Type: SystemString
arguments
Type: SystemObject
symbolSequencePoint
Type: PostSharp.ReflectionSymbolSequencePoint
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (SeverityType, String, Object[], String)

MessageSourceWrite Method (SeverityType, String, Object, String)

Note: This API is now obsolete.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use an overload accepting a MessageLocation object.")]
public void Write(
    SeverityType severity,
    string messageId,
    Object[] arguments,
    string locationFile
)

Parameters

severity
Type: PostSharp.ExtensibilitySeverityType
messageId
Type: SystemString
arguments
Type: SystemObject
locationFile
Type: SystemString
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (MessageLocation, SeverityType, String, Exception, Object[])

MessageSourceWrite Method (MessageLocation, SeverityType, String, Exception, Object)
Emits a Message and specifies an inner Exception.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    MessageLocation location,
    SeverityType severity,
    string messageId,
    Exception innerException,
    params Object[] arguments
)

Parameters

location
Type: PostSharpMessageLocation
Location of the source code artifact that caused the message.
severity
Type: PostSharp.ExtensibilitySeverityType
Message severity (fatal error, error, info, debug).
messageId
Type: SystemString
Identifier of the message type.
innerException
Type: SystemException
The Exception that caused this message, or null if this message was not caused by an exception.
arguments
Type: SystemObject
Array of arguments used to format the message text, or null if this message has no argument.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (SeverityType, String, Object[], String, Int32)

MessageSourceWrite Method (SeverityType, String, Object, String, Int32)

Note: This API is now obsolete.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use an overload accepting a MessageLocation object.")]
public void Write(
    SeverityType severity,
    string messageId,
    Object[] arguments,
    string locationFile,
    int locationLine
)

Parameters

severity
Type: PostSharp.ExtensibilitySeverityType
messageId
Type: SystemString
arguments
Type: SystemObject
locationFile
Type: SystemString
locationLine
Type: SystemInt32
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (SeverityType, String, Object[], String, Int32, Int32)

MessageSourceWrite Method (SeverityType, String, Object, String, Int32, Int32)

Note: This API is now obsolete.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use an overload accepting a MessageLocation object.")]
public void Write(
    SeverityType severity,
    string messageId,
    Object[] arguments,
    string locationFile,
    int locationLine,
    int locationColumn
)

Parameters

severity
Type: PostSharp.ExtensibilitySeverityType
messageId
Type: SystemString
arguments
Type: SystemObject
locationFile
Type: SystemString
locationLine
Type: SystemInt32
locationColumn
Type: SystemInt32
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource.Write Method (SeverityType, String, Object[], String, Int32, Int32, Exception)

MessageSourceWrite Method (SeverityType, String, Object, String, Int32, Int32, Exception)

Note: This API is now obsolete.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use an overload accepting a MessageLocation object.")]
public void Write(
    SeverityType severity,
    string messageId,
    Object[] arguments,
    string locationFile,
    int locationLine,
    int locationColumn,
    Exception innerException
)

Parameters

severity
Type: PostSharp.ExtensibilitySeverityType
messageId
Type: SystemString
arguments
Type: SystemObject
locationFile
Type: SystemString
locationLine
Type: SystemInt32
locationColumn
Type: SystemInt32
innerException
Type: SystemException
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

MessageSource Class
Write Overload
PostSharp.Extensibility Namespace


MessageSource Properties

MessageSource Properties

The MessageSource type exposes the following members.

Properties
Name | Description
MessageSink | Gets the current message sink.
Top
See Also

Reference

MessageSource Class
PostSharp.Extensibility Namespace


MessageSource.MessageSink Property

MessageSourceMessageSink Property
Gets the current message sink.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static IMessageSink MessageSink { get; }

Property Value

Type: IMessageSink
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MessageSource Class
PostSharp.Extensibility Namespace


MetricAttribute Class

MetricAttribute Class
Custom attribute that, when applied on an aspect, causes the aspect to increment some metric at build time.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMetricAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class MetricAttribute : Attribute

The MetricAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | MetricAttribute | Initializes a new MetricAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AllowImplementationMetrics | Determines whether the usage of features used by the target aspects must be instrumented.
Public property | MetricName | Gets the name of the metric.
Public property | Operand | Gets the operand of the metric.
Top
Remarks
These metrics are used by PostSharp to collect usage information and are transferred to the makers of PostSharp only if you opted in for the Customer Experience Improvement Program.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


MetricAttribute Constructor

MetricAttribute Constructor
Initializes a new MetricAttribute.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MetricAttribute(
    string metricName,
    Object operand
)

Parameters

metricName
Type: SystemString
Metric name.
operand
Type: SystemObject
Metric operand.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MetricAttribute Class
PostSharp.Extensibility Namespace


MetricAttribute Methods

MetricAttribute Methods

The MetricAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MetricAttribute Class
PostSharp.Extensibility Namespace


MetricAttribute Properties

MetricAttribute Properties

The MetricAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AllowImplementationMetrics | Determines whether the usage of features used by the target aspects must be instrumented.
Public property | MetricName | Gets the name of the metric.
Public property | Operand | Gets the operand of the metric.
Top
See Also

Reference

MetricAttribute Class
PostSharp.Extensibility Namespace


MetricAttribute.AllowImplementationMetrics Property

MetricAttributeAllowImplementationMetrics Property
Determines whether the usage of features used by the target aspects must be instrumented.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool AllowImplementationMetrics { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MetricAttribute Class
PostSharp.Extensibility Namespace


MetricAttribute.MetricName Property

MetricAttributeMetricName Property
Gets the name of the metric.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string MetricName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MetricAttribute Class
PostSharp.Extensibility Namespace


MetricAttribute.Operand Property

MetricAttributeOperand Property
Gets the operand of the metric.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Operand { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MetricAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute Class

MulticastAttribute Class
Custom attribute that can be applied to multiple elements using wildcards.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
More...

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class MulticastAttribute : Attribute

The MulticastAttribute type exposes the following members.

Constructors
 | Name | Description
Protected method | MulticastAttribute | Initializes a new instance of the MulticastAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance.
Public property | AttributeInheritance | Determines whether this attribute is inherited
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before).
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations.
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply.
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies.
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module.
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module.
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies.
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies.
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies.
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies.
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies.
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies.
Top
Remarks

Each class derived from MulticastAttribute should be decorated with an instance of MulticastAttributeUsageAttribute.

Multicasting is performed by the MulticastAttributeTask, which should be included in the project. After multicasting, custom attribute instances are available on the CustomAttributeDictionaryTask class.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.ConstraintsConstraint
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ModelPureAttribute
PostSharp.Patterns.RecordingRecordingScopeAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingAssumeImmutableAttribute
PostSharp.Patterns.ThreadingEntryPointAttribute
PostSharp.Patterns.ThreadingExplicitlySynchronizedAttribute
PostSharp.Patterns.ThreadingReentrantAttribute
PostSharp.SerializationPSerializableAttribute


MulticastAttribute Constructor

MulticastAttribute Constructor
Initializes a new instance of the MulticastAttribute class

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected MulticastAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute Methods

MulticastAttribute Methods

The MulticastAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute Properties

MulticastAttribute Properties

The MulticastAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance.
Public property | AttributeInheritance | Determines whether this attribute is inherited
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before).
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations.
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply.
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies.
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module.
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module.
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies.
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies.
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies.
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies.
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies.
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies.
Top
See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeExclude Property

MulticastAttributeAttributeExclude Property
If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool AttributeExclude { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeInheritance Property

MulticastAttributeAttributeInheritance Property
Determines whether this attribute is inherited

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastInheritance AttributeInheritance { get; set; }

Property Value

Type: MulticastInheritance
Remarks

If this property is true, a copy of this attribute will be propagated along the lines of inheritance of the target element:

  • On classes: all classed derived from that class.
  • On interfaces: all classes implementing this interface.
  • On virtual, abstract or interface methods: all methods overriding or implementing this method.
  • On parameters or return value of virtual, abstract or interface methods: corresponding parameter or return value on all methods or overriding or implementing the parent method of the target parameter or return value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributePriority Property

MulticastAttributeAttributePriority Property
Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before).

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int AttributePriority { get; set; }

Property Value

Type: Int32
Remarks
You should use only 16-bit values in user code. Top 16 bits are reserved for the system.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeReplace Property

MulticastAttributeAttributeReplace Property
Determines whether this attribute replaces other attributes found on the target declarations.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool AttributeReplace { get; set; }

Property Value

Type: Boolean
true if the current instance will replace previous ones, or false if it will be added to previous instances.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeTargetAssemblies Property

MulticastAttributeAttributeTargetAssemblies Property
Gets or sets the assemblies to which the current attribute apply.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string AttributeTargetAssemblies { get; set; }

Property Value

Type: String
Wildcard or regular expression specifying to which assemblies this instance applies, or null if this instance applies only to elements of the current assembly. Wildcard expressions should start with the regex: prefix.
Remarks
When this property is not specified or is null, the current attribute is multicasted only in the current assembly. Otherwise, it is multicasted also to external assemblies, i.e. to declarations that are referenced by the current assembly.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeTargetElements Property

MulticastAttributeAttributeTargetElements Property
Gets or sets the kind of elements to which this custom attributes applies.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastTargets AttributeTargetElements { get; set; }

Property Value

Type: MulticastTargets
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeTargetExternalMemberAttributes Property

MulticastAttributeAttributeTargetExternalMemberAttributes Property
Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes AttributeTargetExternalMemberAttributes { get; set; }

Property Value

Type: MulticastAttributes
Remarks

Ignored if the AttributeTargetElements are only the module, the assembly, and/or types.

The MulticastAttributes enumeration is a multi-part flag: there is one part for visibility, one for scope, one for virtuality, and one for implementation. If you specify one part, it will override the values defined on the custom attribute definition. If you do not specify it, the values defined on the custom attribute definition will be inherited. Note that custom attributes may apply restrictions on these attributes. For instance, a custom attribute may not be valid on abstract methods. You are obviously not allowed to 'enlarge' the set of possible targets.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeTargetExternalTypeAttributes Property

MulticastAttributeAttributeTargetExternalTypeAttributes Property
Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes AttributeTargetExternalTypeAttributes { get; set; }

Property Value

Type: MulticastAttributes
Remarks
On type-level, the only meaningful enumeration values are related to visibility.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeTargetMemberAttributes Property

MulticastAttributeAttributeTargetMemberAttributes Property
Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes AttributeTargetMemberAttributes { get; set; }

Property Value

Type: MulticastAttributes
Remarks

Ignored if the AttributeTargetElements are only the module, the assembly, and/or types.

The MulticastAttributes enumeration is a multi-part flag: there is one part for visibility, one for scope, one for virtuality, and one for implementation. If you specify one part, it will override the values defined on the custom attribute definition. If you do not specify it, the values defined on the custom attribute definition will be inherited. Note that custom attributes may apply restrictions on these attributes. For instance, a custom attribute may not be valid on abstract methods. You are obviously not allowed to 'enlarge' the set of possible targets.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeTargetMembers Property

MulticastAttributeAttributeTargetMembers Property
Gets or sets the expression specifying to which members this instance applies.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string AttributeTargetMembers { get; set; }

Property Value

Type: String
A wildcard or regular expression specifying to which members this instance applies, or null this instance applies either to all members whose kind is given in AttributeTargetElements. Regular expressions should start with the regex: prefix.
Remarks

Ignored if the only AttributeTargetElements are only types.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeTargetParameterAttributes Property

MulticastAttributeAttributeTargetParameterAttributes Property
Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes AttributeTargetParameterAttributes { get; set; }

Property Value

Type: MulticastAttributes
Remarks

Ignored if the AttributeTargetElements do not include parameters.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeTargetParameters Property

MulticastAttributeAttributeTargetParameters Property
Gets or sets the expression specifying to which parameters this instance applies.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string AttributeTargetParameters { get; set; }

Property Value

Type: String
A wildcard or regular expression specifying to which parameters this instance applies, or null this instance applies either to all members whose kind is given in AttributeTargetElements. Wildcard expressions should start with the regex: prefix.
Remarks

Ignored if the only AttributeTargetElements are only types.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeTargetTypeAttributes Property

MulticastAttributeAttributeTargetTypeAttributes Property
Gets or sets the visibilities of types to which this attribute applies.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes AttributeTargetTypeAttributes { get; set; }

Property Value

Type: MulticastAttributes
Remarks
On type-level, the only meaningful enumeration values are related to visibility.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttribute.AttributeTargetTypes Property

MulticastAttributeAttributeTargetTypes Property
Gets or sets the expression specifying to which types this instance applies.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string AttributeTargetTypes { get; set; }

Property Value

Type: String
A wildcard or regular expression specifying to which types this instance applies, or null this instance applies either to all types. Regular expressions should start with the regex: prefix.
Remarks
Ignored if the AttributeTargetElements are only the module and/or the assembly.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributes Enumeration

MulticastAttributes Enumeration
Attributes of elements to which multicast custom attributes (MulticastAttribute) apply.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[FlagsAttribute]
public enum MulticastAttributes
Members
Member name | Value | Description
Default | 0 | Specifies that the set of target attributes is inherited from the parent custom attribute.
Private | 2 | Private (visible inside the current type).
Protected | 4 | Protected (visible inside derived types).
Internal | 8 | Internal (visible inside the current assembly).
InternalAndProtected | 16 | Internal and protected (visible inside derived types that are defined in the current assembly).
InternalOrProtected | 32 | Internal or protected (visible inside all derived types and in the current assembly).
Public | 64 | Public (visible everywhere).
AnyVisibility | 126 | Any visibility.
Static | 128 | Static scope.
Instance | 256 | Instance scope.
AnyScope | 384 | Any scope (Static | Instance).
Abstract | 512 | Abstract methods.
NonAbstract | 1024 | Concrete (non-abstract) methods.
AnyAbstraction | 1536 | Any abstraction (Abstract | NonAbstract).
Virtual | 2048 | Virtual methods.
NonVirtual | 4096 | Non-virtual methods.
AnyVirtuality | 6144 | Any virtuality (Virtual | NonVirtual).
Managed | 8192 | Managed code implementation.
NonManaged | 16384 | Non-managed code implementation (external or system).
AnyImplementation | 24576 | Any implementation (Managed | NonManaged).
Literal | 32768 | Literal fields.
NonLiteral | 65536 | Non-literal fields.
AnyLiterality | 98304 | Any field literality (Literal | NonLiteral).
InParameter | 131072 | Input parameters.
CompilerGenerated | 262144 | Compiler-generated code (for instance closure types of anonymous method, iterator type, ...).
UserGenerated | 524288 | User-generated code (anything expected CompilerGenerated).
AnyGeneration | 786432 | Any code generation (CompilerGenerated | UserGenerated)l
OutParameter | 1048576 | Output (out in C#) parameters.
RefParameter | 2097152 | Input/Output (ref in C#) parameters.
AnyParameter | 3276800 | Any kind of parameter passing (InParameter | OutParameter | RefParameter).
All | 4194302 | All members.
Remarks
When specifying attributes of target members or types, do not forget to provide all categories of flags, not only the category on which you want to put a restriction. If you want to limit, for instance, a custom attribute to be applied on public members, a good practice is to set TargetMemberAttributes = MulticastAttributes.Public | ~MulticastAttributes.AnyVisibility, unless the parent is more restrictive, in which case you should specify attributes explicitly.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute Class

MulticastAttributeUsageAttribute Class
Custom attribute that determines the usage of a MulticastAttribute.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttributeUsageAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class MulticastAttributeUsageAttribute : Attribute

The MulticastAttributeUsageAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | MulticastAttributeUsageAttribute | Initializes a new MulticastAttributeUsageAttribute.
Public method | MulticastAttributeUsageAttribute(MulticastTargets) | Initializes a new MulticastAttributeUsageAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AllowExternalAssemblies | Determines whether this attribute can be applied to declaration of external assemblies (i.e. to other assemblies than the one in which the custom attribute is instantiated).
Public property | AllowMultiple | Determines whether many instances of the custom attribute are allowed on a single declaration.
Public property | HideFromAspectBrowser | Determines whether instances of the target MulticastAttribute should be hidden from the Aspect Browser, in the Visual Studio extension.
Public property | Inheritance | Determines whether the custom attribute in inherited along the lines of inheritance of the target element.
Public property | PersistMetaData | Determines whether the custom attribute should be persisted in metadata, so that it would be available for System.Reflection.
Public property | TargetExternalMemberAttributes | Gets or sets the attributes of the members (fields or methods) to which the custom attribute can be applied, when the members are external to the current module.
Public property | TargetExternalTypeAttributes | Gets or sets the attributes of the types to which the custom attribute can be applied, when the type is external to the current module. If the custom attribute relates to fields or methods, this property specifies which attributes of the declaring type are acceptable.
Public property | TargetMemberAttributes | Gets or sets the attributes of the members (fields or methods) to which the custom attribute can be applied.
Public property | TargetParameterAttributes | Gets or sets the attributes of the parameter to which the custom attribute can be applied.
Public property | TargetTypeAttributes | Gets or sets the attributes of the types to which the custom attribute can be applied. If the custom attribute relates to fields or methods, this property specifies which attributes of the declaring type are acceptable.
Public property | ValidOn | Gets the kinds of targets that instances of the related MulticastAttribute apply to.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute Constructor

MulticastAttributeUsageAttribute Constructor
Overload List
 | Name | Description
Public method | MulticastAttributeUsageAttribute | Initializes a new MulticastAttributeUsageAttribute.
Public method | MulticastAttributeUsageAttribute(MulticastTargets) | Initializes a new MulticastAttributeUsageAttribute.
Top
See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute Constructor

MulticastAttributeUsageAttribute Constructor
Initializes a new MulticastAttributeUsageAttribute.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributeUsageAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
MulticastAttributeUsageAttribute Overload
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute Constructor (MulticastTargets)

MulticastAttributeUsageAttribute Constructor (MulticastTargets)
Initializes a new MulticastAttributeUsageAttribute.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributeUsageAttribute(
    MulticastTargets validOn
)

Parameters

validOn
Type: PostSharp.ExtensibilityMulticastTargets
Kinds of targets that instances of the related MulticastAttribute apply to.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
MulticastAttributeUsageAttribute Overload
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute Methods

MulticastAttributeUsageAttribute Methods

The MulticastAttributeUsageAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute Properties

MulticastAttributeUsageAttribute Properties

The MulticastAttributeUsageAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AllowExternalAssemblies | Determines whether this attribute can be applied to declaration of external assemblies (i.e. to other assemblies than the one in which the custom attribute is instantiated).
Public property | AllowMultiple | Determines whether many instances of the custom attribute are allowed on a single declaration.
Public property | HideFromAspectBrowser | Determines whether instances of the target MulticastAttribute should be hidden from the Aspect Browser, in the Visual Studio extension.
Public property | Inheritance | Determines whether the custom attribute in inherited along the lines of inheritance of the target element.
Public property | PersistMetaData | Determines whether the custom attribute should be persisted in metadata, so that it would be available for System.Reflection.
Public property | TargetExternalMemberAttributes | Gets or sets the attributes of the members (fields or methods) to which the custom attribute can be applied, when the members are external to the current module.
Public property | TargetExternalTypeAttributes | Gets or sets the attributes of the types to which the custom attribute can be applied, when the type is external to the current module. If the custom attribute relates to fields or methods, this property specifies which attributes of the declaring type are acceptable.
Public property | TargetMemberAttributes | Gets or sets the attributes of the members (fields or methods) to which the custom attribute can be applied.
Public property | TargetParameterAttributes | Gets or sets the attributes of the parameter to which the custom attribute can be applied.
Public property | TargetTypeAttributes | Gets or sets the attributes of the types to which the custom attribute can be applied. If the custom attribute relates to fields or methods, this property specifies which attributes of the declaring type are acceptable.
Public property | ValidOn | Gets the kinds of targets that instances of the related MulticastAttribute apply to.
Top
See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute.AllowExternalAssemblies Property

MulticastAttributeUsageAttributeAllowExternalAssemblies Property
Determines whether this attribute can be applied to declaration of external assemblies (i.e. to other assemblies than the one in which the custom attribute is instantiated).

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool AllowExternalAssemblies { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute.AllowMultiple Property

MulticastAttributeUsageAttributeAllowMultiple Property
Determines whether many instances of the custom attribute are allowed on a single declaration.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool AllowMultiple { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute.HideFromAspectBrowser Property

MulticastAttributeUsageAttributeHideFromAspectBrowser Property
Determines whether instances of the target MulticastAttribute should be hidden from the Aspect Browser, in the Visual Studio extension.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool HideFromAspectBrowser { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute.Inheritance Property

MulticastAttributeUsageAttributeInheritance Property
Determines whether the custom attribute in inherited along the lines of inheritance of the target element.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastInheritance Inheritance { get; set; }

Property Value

Type: MulticastInheritance
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace
MulticastAttributeAttributeInheritance


MulticastAttributeUsageAttribute.PersistMetaData Property

MulticastAttributeUsageAttributePersistMetaData Property
Determines whether the custom attribute should be persisted in metadata, so that it would be available for System.Reflection.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool PersistMetaData { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute.TargetExternalMemberAttributes Property

MulticastAttributeUsageAttributeTargetExternalMemberAttributes Property
Gets or sets the attributes of the members (fields or methods) to which the custom attribute can be applied, when the members are external to the current module.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes TargetExternalMemberAttributes { get; set; }

Property Value

Type: MulticastAttributes
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute.TargetExternalTypeAttributes Property

MulticastAttributeUsageAttributeTargetExternalTypeAttributes Property
Gets or sets the attributes of the types to which the custom attribute can be applied, when the type is external to the current module. If the custom attribute relates to fields or methods, this property specifies which attributes of the declaring type are acceptable.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes TargetExternalTypeAttributes { get; set; }

Property Value

Type: MulticastAttributes
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute.TargetMemberAttributes Property

MulticastAttributeUsageAttributeTargetMemberAttributes Property
Gets or sets the attributes of the members (fields or methods) to which the custom attribute can be applied.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes TargetMemberAttributes { get; set; }

Property Value

Type: MulticastAttributes
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute.TargetParameterAttributes Property

MulticastAttributeUsageAttributeTargetParameterAttributes Property
Gets or sets the attributes of the parameter to which the custom attribute can be applied.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes TargetParameterAttributes { get; set; }

Property Value

Type: MulticastAttributes
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute.TargetTypeAttributes Property

MulticastAttributeUsageAttributeTargetTypeAttributes Property
Gets or sets the attributes of the types to which the custom attribute can be applied. If the custom attribute relates to fields or methods, this property specifies which attributes of the declaring type are acceptable.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastAttributes TargetTypeAttributes { get; set; }

Property Value

Type: MulticastAttributes
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastAttributeUsageAttribute.ValidOn Property

MulticastAttributeUsageAttributeValidOn Property
Gets the kinds of targets that instances of the related MulticastAttribute apply to.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MulticastTargets ValidOn { get; }

Property Value

Type: MulticastTargets
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MulticastAttributeUsageAttribute Class
PostSharp.Extensibility Namespace


MulticastInheritance Enumeration

MulticastInheritance Enumeration
Kind of inheritance of MulticastAttribute.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum MulticastInheritance
Members
Member name | Value | Description
None | 0 | No inheritance.
Strict | 1 | The instance is inherited to children of the original element, but multicasting is not applied to members of children.
Multicast | 2 | The instance is inherited to children of the original element and multicasting is applied to members of children.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


MulticastTargets Enumeration

MulticastTargets Enumeration
Kinds of targets to which multicast custom attributes (MulticastAttribute) can apply.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[FlagsAttribute]
public enum MulticastTargets
Members
Member name | Value | Description
Default | 0 | Specifies that the set of target elements is inherited from the parent custom attribute.
Class | 1 | Class.
Struct | 2 | Structure.
Enum | 4 | Enumeration.
Delegate | 8 | Delegate.
Interface | 16 | Interface.
AnyType | 31 | Any type (Class, Struct, Enum, Delegate or Interface).
Field | 32 | Field.
Method | 64 | Method (but not constructor).
InstanceConstructor | 128 | Instance constructor.
StaticConstructor | 256 | Static constructor.
Property | 512 | Property (but not methods inside the property).
Event | 1024 | Event (but not methods inside the event).
AnyMember | 2016 | Any member (Field, Method, InstanceConstructor, StaticConstructor, Property, Event).
Assembly | 2048 | Assembly.
Parameter | 4096 | Method or property parameter.
ReturnValue | 8192 | Method or property return value.
All | 16383 | All element kinds.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


PostSharpEnvironment Class

PostSharpEnvironment Class
Provides access to the current PostSharp environment (IPostSharpEnvironment).
Inheritance Hierarchy
SystemObject
PostSharp.ExtensibilityPostSharpEnvironment

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class PostSharpEnvironment

The PostSharpEnvironment type exposes the following members.

Properties
Name | Description
Current | Gets the current PostSharp environment, or null if the PostSharp Platform is not loaded in the current context.
CurrentProject | Gets the current PostSharp project.
IsPostSharpRunning | Determines whether the PostSharp Platform is currently loaded.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


PostSharpEnvironment Properties

PostSharpEnvironment Properties

The PostSharpEnvironment type exposes the following members.

Properties
Name | Description
Current | Gets the current PostSharp environment, or null if the PostSharp Platform is not loaded in the current context.
CurrentProject | Gets the current PostSharp project.
IsPostSharpRunning | Determines whether the PostSharp Platform is currently loaded.
Top
See Also

Reference

PostSharpEnvironment Class
PostSharp.Extensibility Namespace


PostSharpEnvironment.Current Property

PostSharpEnvironmentCurrent Property
Gets the current PostSharp environment, or null if the PostSharp Platform is not loaded in the current context.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static IPostSharpEnvironment Current { get; }

Property Value

Type: IPostSharpEnvironment
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpEnvironment Class
PostSharp.Extensibility Namespace


PostSharpEnvironment.CurrentProject Property

PostSharpEnvironmentCurrentProject Property
Gets the current PostSharp project.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static IProject CurrentProject { get; }

Property Value

Type: IProject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpEnvironment Class
PostSharp.Extensibility Namespace


PostSharpEnvironment.IsPostSharpRunning Property

PostSharpEnvironmentIsPostSharpRunning Property
Determines whether the PostSharp Platform is currently loaded.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool IsPostSharpRunning { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpEnvironment Class
PostSharp.Extensibility Namespace


PostSharpTrace Class

PostSharpTrace Class
Provides tracing functionality. An instance of the PostSharpTrace type implements a trace sink.
Inheritance Hierarchy
SystemObject
PostSharp.ExtensibilityPostSharpTrace

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class PostSharpTrace

The PostSharpTrace type exposes the following members.

Constructors
 | Name | Description
Public method | PostSharpTrace | Initialize a new PostSharpTrace sink.
Top
Methods
 | Name | Description
 | EnableCategory(String) | Enables a trace category known by its name.
 | EnableCategory(PostSharpTrace) | Enables a trace category known by its object.
Public method | Write(String) | Writes a message to the current sink without formatting parameter.
Public method | Write(String, Object) | Writes a message to the current sink with a single formatting parameter.
Public method | Write(String, Object) | Writes a message to the current sink with many formatting parameters.
Public method | Write(String, Object, Object) | Writes a message to the current sink with two formatting parameters.
Public method | Write(String, Object, Object, Object) | Writes a message to the current sink with three formatting parameters.
Public method | WriteLine(String) | Writes a message to the current sink without parameter, and issues a line break.
Public method | WriteLine(String, Object) | Writes a message to the current sink with a single formatting parameter, and issues a line break.
Public method | WriteLine(String, Object) | Writes a message to the current sink with many formatting parameters, and issues a line break.
Public method | WriteLine(String, Object, Object) | Writes a message to the current sink with two formatting parameters, and issues a line break.
Public method | WriteLine(String, Object, Object, Object) | Writes a message to the current sink with three formatting parameters, and issues a line break.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Enabled | Determines whether the current trace sink is enabled.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


PostSharpTrace Constructor

PostSharpTrace Constructor
Initialize a new PostSharpTrace sink.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PostSharpTrace(
    string category
)

Parameters

category
Type: SystemString
Category of messages.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
PostSharp.Extensibility Namespace


PostSharpTrace Methods

PostSharpTrace Methods

The PostSharpTrace type exposes the following members.

Methods
 | Name | Description
 | EnableCategory(String) | Enables a trace category known by its name.
 | EnableCategory(PostSharpTrace) | Enables a trace category known by its object.
Public method | Write(String) | Writes a message to the current sink without formatting parameter.
Public method | Write(String, Object) | Writes a message to the current sink with a single formatting parameter.
Public method | Write(String, Object) | Writes a message to the current sink with many formatting parameters.
Public method | Write(String, Object, Object) | Writes a message to the current sink with two formatting parameters.
Public method | Write(String, Object, Object, Object) | Writes a message to the current sink with three formatting parameters.
Public method | WriteLine(String) | Writes a message to the current sink without parameter, and issues a line break.
Public method | WriteLine(String, Object) | Writes a message to the current sink with a single formatting parameter, and issues a line break.
Public method | WriteLine(String, Object) | Writes a message to the current sink with many formatting parameters, and issues a line break.
Public method | WriteLine(String, Object, Object) | Writes a message to the current sink with two formatting parameters, and issues a line break.
Public method | WriteLine(String, Object, Object, Object) | Writes a message to the current sink with three formatting parameters, and issues a line break.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PostSharpTrace Class
PostSharp.Extensibility Namespace


PostSharpTrace.EnableCategory Method

PostSharpTraceEnableCategory Method
Overload List
Name | Description
EnableCategory(String) | Enables a trace category known by its name.
EnableCategory(PostSharpTrace) | Enables a trace category known by its object.
Top
See Also

Reference

PostSharpTrace Class
PostSharp.Extensibility Namespace


PostSharpTrace.EnableCategory Method (String)

PostSharpTraceEnableCategory Method (String)
Enables a trace category known by its name.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void EnableCategory(
    string category
)

Parameters

category
Type: SystemString
The category name.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
EnableCategory Overload
PostSharp.Extensibility Namespace


PostSharpTrace.EnableCategory Method (PostSharpTrace)

PostSharpTraceEnableCategory Method (PostSharpTrace)
Enables a trace category known by its object.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void EnableCategory(
    PostSharpTrace category
)

Parameters

category
Type: PostSharp.ExtensibilityPostSharpTrace
A PostSharpTrace object.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
EnableCategory Overload
PostSharp.Extensibility Namespace


PostSharpTrace.Write Method

PostSharpTraceWrite Method
Overload List
 | Name | Description
Public method | Write(String) | Writes a message to the current sink without formatting parameter.
Public method | Write(String, Object) | Writes a message to the current sink with a single formatting parameter.
Public method | Write(String, Object) | Writes a message to the current sink with many formatting parameters.
Public method | Write(String, Object, Object) | Writes a message to the current sink with two formatting parameters.
Public method | Write(String, Object, Object, Object) | Writes a message to the current sink with three formatting parameters.
Top
See Also

Reference

PostSharpTrace Class
PostSharp.Extensibility Namespace


PostSharpTrace.Write Method (String)

PostSharpTraceWrite Method (String)
Writes a message to the current sink without formatting parameter.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    string message
)

Parameters

message
Type: SystemString
Message.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
Write Overload
PostSharp.Extensibility Namespace


PostSharpTrace.Write Method (String, Object)

PostSharpTraceWrite Method (String, Object)
Writes a message to the current sink with a single formatting parameter.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    string format,
    Object arg0
)

Parameters

format
Type: SystemString
Message formatting string.
arg0
Type: SystemObject
The first formatting parameter.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
Write Overload
PostSharp.Extensibility Namespace


PostSharpTrace.Write Method (String, Object[])

PostSharpTraceWrite Method (String, Object)
Writes a message to the current sink with many formatting parameters.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    string format,
    params Object[] parameters
)

Parameters

format
Type: SystemString
Message formatting string.
parameters
Type: SystemObject
Formatting parameters.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
Write Overload
PostSharp.Extensibility Namespace


PostSharpTrace.Write Method (String, Object, Object)

PostSharpTraceWrite Method (String, Object, Object)
Writes a message to the current sink with two formatting parameters.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    string format,
    Object arg0,
    Object arg1
)

Parameters

format
Type: SystemString
Message formatting string.
arg0
Type: SystemObject
The first formatting parameter.
arg1
Type: SystemObject
The second formatting parameter.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
Write Overload
PostSharp.Extensibility Namespace


PostSharpTrace.Write Method (String, Object, Object, Object)

PostSharpTraceWrite Method (String, Object, Object, Object)
Writes a message to the current sink with three formatting parameters.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Write(
    string format,
    Object arg0,
    Object arg1,
    Object arg2
)

Parameters

format
Type: SystemString
Message formatting string.
arg0
Type: SystemObject
The first formatting parameter.
arg1
Type: SystemObject
The second formatting parameter.
arg2
Type: SystemObject
The third formatting parameter.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
Write Overload
PostSharp.Extensibility Namespace


PostSharpTrace.WriteLine Method

PostSharpTraceWriteLine Method
Overload List
 | Name | Description
Public method | WriteLine(String) | Writes a message to the current sink without parameter, and issues a line break.
Public method | WriteLine(String, Object) | Writes a message to the current sink with a single formatting parameter, and issues a line break.
Public method | WriteLine(String, Object) | Writes a message to the current sink with many formatting parameters, and issues a line break.
Public method | WriteLine(String, Object, Object) | Writes a message to the current sink with two formatting parameters, and issues a line break.
Public method | WriteLine(String, Object, Object, Object) | Writes a message to the current sink with three formatting parameters, and issues a line break.
Top
See Also

Reference

PostSharpTrace Class
PostSharp.Extensibility Namespace


PostSharpTrace.WriteLine Method (String)

PostSharpTraceWriteLine Method (String)
Writes a message to the current sink without parameter, and issues a line break.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void WriteLine(
    string format
)

Parameters

format
Type: SystemString
Message formatting string.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
WriteLine Overload
PostSharp.Extensibility Namespace


PostSharpTrace.WriteLine Method (String, Object)

PostSharpTraceWriteLine Method (String, Object)
Writes a message to the current sink with a single formatting parameter, and issues a line break.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void WriteLine(
    string format,
    Object arg0
)

Parameters

format
Type: SystemString
Message formatting string.
arg0
Type: SystemObject
The first formatting parameter.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
WriteLine Overload
PostSharp.Extensibility Namespace


PostSharpTrace.WriteLine Method (String, Object[])

PostSharpTraceWriteLine Method (String, Object)
Writes a message to the current sink with many formatting parameters, and issues a line break.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void WriteLine(
    string format,
    params Object[] parameters
)

Parameters

format
Type: SystemString
Message formatting string.
parameters
Type: SystemObject
Formatting parameters.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
WriteLine Overload
PostSharp.Extensibility Namespace


PostSharpTrace.WriteLine Method (String, Object, Object)

PostSharpTraceWriteLine Method (String, Object, Object)
Writes a message to the current sink with two formatting parameters, and issues a line break.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void WriteLine(
    string format,
    Object arg0,
    Object arg1
)

Parameters

format
Type: SystemString
Message formatting string.
arg0
Type: SystemObject
The first formatting parameter.
arg1
Type: SystemObject
The second formatting parameter.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
WriteLine Overload
PostSharp.Extensibility Namespace


PostSharpTrace.WriteLine Method (String, Object, Object, Object)

PostSharpTraceWriteLine Method (String, Object, Object, Object)
Writes a message to the current sink with three formatting parameters, and issues a line break.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void WriteLine(
    string format,
    Object arg0,
    Object arg1,
    Object arg2
)

Parameters

format
Type: SystemString
Message formatting string.
arg0
Type: SystemObject
The first formatting parameter.
arg1
Type: SystemObject
The second formatting parameter.
arg2
Type: SystemObject
The third formatting parameter.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
WriteLine Overload
PostSharp.Extensibility Namespace


PostSharpTrace Properties

PostSharpTrace Properties

The PostSharpTrace type exposes the following members.

Properties
 | Name | Description
Public property | Enabled | Determines whether the current trace sink is enabled.
Top
See Also

Reference

PostSharpTrace Class
PostSharp.Extensibility Namespace


PostSharpTrace.Enabled Property

PostSharpTraceEnabled Property
Determines whether the current trace sink is enabled.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Enabled { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharpTrace Class
PostSharp.Extensibility Namespace


ProjectExtensionElement Class

ProjectExtensionElement Class
Represents a custom element (or section) in the XML project type.
Inheritance Hierarchy
SystemObject
PostSharp.ExtensibilityProjectExtensionElement

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ProjectExtensionElement

The ProjectExtensionElement type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | FileName | Gets the full path of the file in which the element is defined.
Public property | Xml | Gets the text representation of the XmlElement materializing the project extension.
Public property | XmlElement | Gets the XmlElement materializing the project extension.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


ProjectExtensionElement Methods

ProjectExtensionElement Methods

The ProjectExtensionElement type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ProjectExtensionElement Class
PostSharp.Extensibility Namespace


ProjectExtensionElement Properties

ProjectExtensionElement Properties

The ProjectExtensionElement type exposes the following members.

Properties
 | Name | Description
Public property | FileName | Gets the full path of the file in which the element is defined.
Public property | Xml | Gets the text representation of the XmlElement materializing the project extension.
Public property | XmlElement | Gets the XmlElement materializing the project extension.
Top
See Also

Reference

ProjectExtensionElement Class
PostSharp.Extensibility Namespace


ProjectExtensionElement.FileName Property

ProjectExtensionElementFileName Property
Gets the full path of the file in which the element is defined.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string FileName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProjectExtensionElement Class
PostSharp.Extensibility Namespace


ProjectExtensionElement.Xml Property

ProjectExtensionElementXml Property
Gets the text representation of the XmlElement materializing the project extension.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Xml { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProjectExtensionElement Class
PostSharp.Extensibility Namespace


ProjectExtensionElement.XmlElement Property

ProjectExtensionElementXmlElement Property
Gets the XmlElement materializing the project extension.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public XmlElement XmlElement { get; }

Property Value

Type: XmlElement
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProjectExtensionElement Class
PostSharp.Extensibility Namespace


ProjectResource Class

ProjectResource Class
Represents an element of a resource section, i.e. a named object deserialized from XML.
Inheritance Hierarchy
SystemObject
PostSharp.ExtensibilityProjectResource

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ProjectResource

The ProjectResource type exposes the following members.

Constructors
 | Name | Description
Public method | ProjectResource | Initializes a new ProjectResource.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Name | Gets the name of the resource section, i.e. the name of the XML element containing the resource.
Public property | Value | Gets the resource value, i.e. the object that has been constructed by deserializing the XML element.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


ProjectResource Constructor

ProjectResource Constructor
Initializes a new ProjectResource.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ProjectResource(
    string name,
    Object value
)

Parameters

name
Type: SystemString
Resource name.
value
Type: SystemObject
Resource value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProjectResource Class
PostSharp.Extensibility Namespace


ProjectResource Methods

ProjectResource Methods

The ProjectResource type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ProjectResource Class
PostSharp.Extensibility Namespace


ProjectResource Properties

ProjectResource Properties

The ProjectResource type exposes the following members.

Properties
 | Name | Description
Public property | Name | Gets the name of the resource section, i.e. the name of the XML element containing the resource.
Public property | Value | Gets the resource value, i.e. the object that has been constructed by deserializing the XML element.
Top
See Also

Reference

ProjectResource Class
PostSharp.Extensibility Namespace


ProjectResource.Name Property

ProjectResourceName Property
Gets the name of the resource section, i.e. the name of the XML element containing the resource.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Name { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProjectResource Class
PostSharp.Extensibility Namespace


ProjectResource.Value Property

ProjectResourceValue Property
Gets the resource value, i.e. the object that has been constructed by deserializing the XML element.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Value { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ProjectResource Class
PostSharp.Extensibility Namespace


RequirePostSharpAttribute Class

RequirePostSharpAttribute Class
Custom attribute that, when applied on another custom attribute (a class derived from Attribute), means that assemblies with elements annotated with that custom attribute should be processed by PostSharp.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityRequirePostSharpAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class RequirePostSharpAttribute : Attribute

The RequirePostSharpAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | RequirePostSharpAttribute | Initializes a new RequirePostSharpAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AssemblyReferenceOnly | Determines whether the requirement should apply only to assemblies referencing the declaration to which the custom attribute is applied. If true, the requirement will not apply to the assembly where the custom attribute is used.
Public property | PlugIn | Gets the name of the required plug-in (file name without the extension).
Public property | Task | Gets the name of the required task (should be defined in PlugIn).
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


RequirePostSharpAttribute Constructor

RequirePostSharpAttribute Constructor
Initializes a new RequirePostSharpAttribute.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RequirePostSharpAttribute(
    string plugIn,
    string task
)

Parameters

plugIn
Type: SystemString
Name of the required plug-in (file name without extension).
task
Type: SystemString
Name of the required task (should be defined in plugIn).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RequirePostSharpAttribute Class
PostSharp.Extensibility Namespace


RequirePostSharpAttribute Methods

RequirePostSharpAttribute Methods

The RequirePostSharpAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RequirePostSharpAttribute Class
PostSharp.Extensibility Namespace


RequirePostSharpAttribute Properties

RequirePostSharpAttribute Properties

The RequirePostSharpAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AssemblyReferenceOnly | Determines whether the requirement should apply only to assemblies referencing the declaration to which the custom attribute is applied. If true, the requirement will not apply to the assembly where the custom attribute is used.
Public property | PlugIn | Gets the name of the required plug-in (file name without the extension).
Public property | Task | Gets the name of the required task (should be defined in PlugIn).
Top
See Also

Reference

RequirePostSharpAttribute Class
PostSharp.Extensibility Namespace


RequirePostSharpAttribute.AssemblyReferenceOnly Property

RequirePostSharpAttributeAssemblyReferenceOnly Property
Determines whether the requirement should apply only to assemblies referencing the declaration to which the custom attribute is applied. If true, the requirement will not apply to the assembly where the custom attribute is used.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool AssemblyReferenceOnly { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RequirePostSharpAttribute Class
PostSharp.Extensibility Namespace


RequirePostSharpAttribute.PlugIn Property

RequirePostSharpAttributePlugIn Property
Gets the name of the required plug-in (file name without the extension).

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string PlugIn { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RequirePostSharpAttribute Class
PostSharp.Extensibility Namespace


RequirePostSharpAttribute.Task Property

RequirePostSharpAttributeTask Property
Gets the name of the required task (should be defined in PlugIn).

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Task { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RequirePostSharpAttribute Class
PostSharp.Extensibility Namespace


RequireReflectionWrapperAttribute Class

RequireReflectionWrapperAttribute Class

Note: This API is now obsolete.

Custom attribute that, when applied on a type, specifies that all build-time semantics of this type require reflection wrappers to be passed instead of real reflection objects.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityRequireReflectionWrapperAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Reflection wrappers are now returned automatically when a real reflection type cannot be returned.",
    true)]
public sealed class RequireReflectionWrapperAttribute : Attribute

The RequireReflectionWrapperAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | RequireReflectionWrapperAttribute | Initializes a new instance of the RequireReflectionWrapperAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Obsolete (does not compile) in 3.1 and later

See Also

Reference

PostSharp.Extensibility Namespace


RequireReflectionWrapperAttribute Constructor

RequireReflectionWrapperAttribute Constructor
Initializes a new instance of the RequireReflectionWrapperAttribute class

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RequireReflectionWrapperAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RequireReflectionWrapperAttribute Class
PostSharp.Extensibility Namespace


RequireReflectionWrapperAttribute Methods

RequireReflectionWrapperAttribute Methods

The RequireReflectionWrapperAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RequireReflectionWrapperAttribute Class
PostSharp.Extensibility Namespace


SeverityType Enumeration

SeverityType Enumeration
Types of message severities.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum SeverityType
Members
Member name | Value | Description
Debug | 0 | Debugging information (typically trace).
Verbose | 1 | Verbose (lowly important information).
Info | 2 | Information.
ImportantInfo | 3 | Important information.
CommandLine | 4 | Command line.
Warning | 5 | Warning.
Error | 6 | Error.
Fatal | 7 | Fatal error.
None | -1 | No message.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


SuppressAnnotationValidationAttribute Class

SuppressAnnotationValidationAttribute Class
Instructs PostSharp that the validation of IValidableAnnotation is done by another component, and should not be processed by the default component.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilitySuppressAnnotationValidationAttribute

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class SuppressAnnotationValidationAttribute : Attribute

The SuppressAnnotationValidationAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | SuppressAnnotationValidationAttribute | Initializes a new instance of the SuppressAnnotationValidationAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


SuppressAnnotationValidationAttribute Constructor

SuppressAnnotationValidationAttribute Constructor
Initializes a new instance of the SuppressAnnotationValidationAttribute class

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SuppressAnnotationValidationAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SuppressAnnotationValidationAttribute Class
PostSharp.Extensibility Namespace


SuppressAnnotationValidationAttribute Methods

SuppressAnnotationValidationAttribute Methods

The SuppressAnnotationValidationAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SuppressAnnotationValidationAttribute Class
PostSharp.Extensibility Namespace


TargetFrameworkFamily Structure

TargetFrameworkFamily Structure
Represents a variant of family (variant) of the .NET Framework, e.g. NetCore, NetFramework, Silverlight or NetPortable.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public struct TargetFrameworkFamily : IEquatable<TargetFrameworkFamily>

The TargetFrameworkFamily type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(TargetFrameworkFamily) | Indicates whether the current object is equal to another object of the same type.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Top
Operators
Name | Description
Equality | Determines whether two TargetFrameworkFamily instances are equal.
Inequality | Determines whether two TargetFrameworkFamily instances are different.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
MonoAndroid | Instance of TargetFrameworkFamily representing MonoAndroid.
MonoTouch | Instance of TargetFrameworkFamily representing MonoTouch.
NetCore | Instance of TargetFrameworkFamily representing .NET Framework for Windows Store.
NetFramework | Instance of TargetFrameworkFamily representing the full .NET Framework.
NetPortable | Instance of TargetFrameworkFamily representing .NET Portable Class Library.
Silverlight | Instance of TargetFrameworkFamily representing Silverlight.
Xamarin_iOS | Instance of TargetFrameworkFamily representing Xamarin.iOS.
Top
Properties
 | Name | Description
Public property | IsNull | Determines whether the current object represents a null instance.
Public property | Value | Gets the string identity of the current object.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Extensibility Namespace


TargetFrameworkFamily Fields

TargetFrameworkFamily Fields

The TargetFrameworkFamily type exposes the following members.

Fields
Name | Description
MonoAndroid | Instance of TargetFrameworkFamily representing MonoAndroid.
MonoTouch | Instance of TargetFrameworkFamily representing MonoTouch.
NetCore | Instance of TargetFrameworkFamily representing .NET Framework for Windows Store.
NetFramework | Instance of TargetFrameworkFamily representing the full .NET Framework.
NetPortable | Instance of TargetFrameworkFamily representing .NET Portable Class Library.
Silverlight | Instance of TargetFrameworkFamily representing Silverlight.
Xamarin_iOS | Instance of TargetFrameworkFamily representing Xamarin.iOS.
Top
See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.MonoAndroid Field

TargetFrameworkFamilyMonoAndroid Field
Instance of TargetFrameworkFamily representing MonoAndroid.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly TargetFrameworkFamily MonoAndroid

Field Value

Type: TargetFrameworkFamily
Version Information

Supported in: 4.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.MonoTouch Field

TargetFrameworkFamilyMonoTouch Field
Instance of TargetFrameworkFamily representing MonoTouch.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly TargetFrameworkFamily MonoTouch

Field Value

Type: TargetFrameworkFamily
Version Information

Supported in: 4.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.NetCore Field

TargetFrameworkFamilyNetCore Field
Instance of TargetFrameworkFamily representing .NET Framework for Windows Store.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly TargetFrameworkFamily NetCore

Field Value

Type: TargetFrameworkFamily
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.NetFramework Field

TargetFrameworkFamilyNetFramework Field
Instance of TargetFrameworkFamily representing the full .NET Framework.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly TargetFrameworkFamily NetFramework

Field Value

Type: TargetFrameworkFamily
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.NetPortable Field

TargetFrameworkFamilyNetPortable Field
Instance of TargetFrameworkFamily representing .NET Portable Class Library.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly TargetFrameworkFamily NetPortable

Field Value

Type: TargetFrameworkFamily
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.Silverlight Field

TargetFrameworkFamilySilverlight Field
Instance of TargetFrameworkFamily representing Silverlight.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly TargetFrameworkFamily Silverlight

Field Value

Type: TargetFrameworkFamily
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.Xamarin_iOS Field

TargetFrameworkFamilyXamarin_iOS Field
Instance of TargetFrameworkFamily representing Xamarin.iOS.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly TargetFrameworkFamily Xamarin_iOS

Field Value

Type: TargetFrameworkFamily
Version Information

Supported in: 4.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily Methods

TargetFrameworkFamily Methods

The TargetFrameworkFamily type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(TargetFrameworkFamily) | Indicates whether the current object is equal to another object of the same type.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.Equals Method

TargetFrameworkFamilyEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(TargetFrameworkFamily) | Indicates whether the current object is equal to another object of the same type.
Top
See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.Equals Method (Object)

TargetFrameworkFamilyEquals Method (Object)
Indicates whether this instance and a specified object are equal.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool Equals(
    Object obj
)

Parameters

obj
Type: SystemObject
Another object to compare to.

Return Value

Type: Boolean
true if obj and this instance are the same type and represent the same value; otherwise, false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
Equals Overload
PostSharp.Extensibility Namespace


TargetFrameworkFamily.Equals Method (TargetFrameworkFamily)

TargetFrameworkFamilyEquals Method (TargetFrameworkFamily)
Indicates whether the current object is equal to another object of the same type.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Equals(
    TargetFrameworkFamily other
)

Parameters

other
Type: PostSharp.ExtensibilityTargetFrameworkFamily
An object to compare with this object.

Return Value

Type: Boolean
true if the current object is equal to the other parameter; otherwise, false.

Implements

IEquatableTEquals(T)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
Equals Overload
PostSharp.Extensibility Namespace


TargetFrameworkFamily.GetHashCode Method

TargetFrameworkFamilyGetHashCode Method
Returns the hash code for this instance.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int GetHashCode()

Return Value

Type: Int32
A 32-bit signed integer that is the hash code for this instance.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily Operators

TargetFrameworkFamily Operators

The TargetFrameworkFamily type exposes the following members.

Operators
Name | Description
Equality | Determines whether two TargetFrameworkFamily instances are equal.
Inequality | Determines whether two TargetFrameworkFamily instances are different.
Top
See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.Equality Operator

TargetFrameworkFamilyEquality Operator
Determines whether two TargetFrameworkFamily instances are equal.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator ==(
    TargetFrameworkFamily x,
    TargetFrameworkFamily y
)

Parameters

x
Type: PostSharp.ExtensibilityTargetFrameworkFamily
A TargetFrameworkFamily.
y
Type: PostSharp.ExtensibilityTargetFrameworkFamily
A TargetFrameworkFamily.

Return Value

Type: Boolean
true if x and y are equal, otherwise false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.Inequality Operator

TargetFrameworkFamilyInequality Operator
Determines whether two TargetFrameworkFamily instances are different.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator !=(
    TargetFrameworkFamily x,
    TargetFrameworkFamily y
)

Parameters

x
Type: PostSharp.ExtensibilityTargetFrameworkFamily
A TargetFrameworkFamily.
y
Type: PostSharp.ExtensibilityTargetFrameworkFamily
A TargetFrameworkFamily.

Return Value

Type: Boolean
true if x and y are different, otherwise false
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily Properties

TargetFrameworkFamily Properties

The TargetFrameworkFamily type exposes the following members.

Properties
 | Name | Description
Public property | IsNull | Determines whether the current object represents a null instance.
Public property | Value | Gets the string identity of the current object.
Top
See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.IsNull Property

TargetFrameworkFamilyIsNull Property
Determines whether the current object represents a null instance.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsNull { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


TargetFrameworkFamily.Value Property

TargetFrameworkFamilyValue Property
Gets the string identity of the current object.

Namespace: PostSharp.Extensibility
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Value { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TargetFrameworkFamily Structure
PostSharp.Extensibility Namespace


PostSharp.Patterns Namespace

PostSharp.Patterns Namespace
Classes
 | Class | Description
Public class | AssertionFailedException | Exception thrown upon internal assertion failures in PostSharp Pattern Libraries.


AssertionFailedException Class

AssertionFailedException Class
Exception thrown upon internal assertion failures in PostSharp Pattern Libraries.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.PatternsAssertionFailedException

Namespace: PostSharp.Patterns
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class AssertionFailedException : Exception
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns Namespace


PostSharp.Patterns.Collections Namespace

PostSharp.Patterns.Collections Namespace
The PostSharp.Patterns.Collections namespace defines collection classes that work with the Aggregatable pattern.
Classes
 | Class | Description
Public class | AdvisableCollectionT | A collection type similar to CollectionT into which advices can be injected dynamically.
Public class | AdvisableDictionaryTKey, TValue | An implementation of a DictionaryTKey, TValue into which advices can be injected dynamically. The class also allows derived classes to add new behaviors by overriding methods, like the CollectionT class does.
Public class | AdvisableDictionaryTKey, TValueKeyCollection | Represents the collection of keys in an AdvisableDictionaryTKey, TValue.
Public class | AdvisableDictionaryTKey, TValueValueCollection | Represents the collection of values in an AdvisableDictionaryTKey, TValue.
Public class | AdvisableKeyedCollectionTKey, TItem | Provides the abstract base class for a keyed collection, similar to KeyedCollectionTKey, TItem, into which advices can be injected dynamically.
Structures
 | Structure | Description
Public structure | AdvisableCollectionTEnumerator | Enumerates the elements of an AdvisableCollectionT.
Public structure | AdvisableDictionaryTKey, TValueEnumerator | Enumerates the elements of an AdvisableDictionaryTKey, TValue.
Public structure | AdvisableDictionaryTKey, TValueKeyCollectionEnumerator | Enumerates the elements of a AdvisableDictionaryTKey, TValueKeyCollection.
Public structure | AdvisableDictionaryTKey, TValueValueCollectionEnumerator | Enumerates the elements of a AdvisableDictionaryTKey, TValueValueCollection.
Public structure | ReadOnlyArrayT | Read-only array wrapper.


AdvisableCollection(T) Class

AdvisableCollectionT Class
A collection type similar to CollectionT into which advices can be injected dynamically.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelDynamicallyAdvisableObject
PostSharp.Patterns.CollectionsAdvisableCollectionT
PostSharp.Patterns.CollectionsAdvisableKeyedCollectionTKey, TItem

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public class AdvisableCollection<T> : DynamicallyAdvisableObject,
    IList<T>, ICollection<T>, IEnumerable<T>, IList, IDynamicallyAdvisableCollection,
    IDynamicallyAdvisable, IQueryInterface, ICollection, IEnumerable, INotifyPropertyChanged,
    INotifyCollectionChanged

Type Parameters

T
The type of elements in the collection

The AdvisableCollectionT type exposes the following members.

Methods
 | Name | Description
Public method | Add | Adds an item to the ICollectionT.
Public method | Clear | Removes all items from the ICollectionT.
Protected method | ClearItems | Removes all elements from the underlying collection.
Public method | Contains | Determines whether the ICollectionT contains a specific value.
Public method | CopyTo | Copies the elements of the ICollectionT to an Array, starting at a particular Array index.
Protected method | GetCount | Gets the number of elements in the underlying collection.
Public method | GetEnumerator | Returns an enumerator that iterates through the AdvisableCollectionT.
Protected method | GetItem | Gets the element at the specified index of the underlying collection.
Public method | GetObjectData | Populates a SerializationInfo with the data needed to serialize the target object. (Overrides DynamicallyAdvisableObjectGetObjectData(SerializationInfo, StreamingContext).)
Public method | IndexOf | Determines the index of a specific item in the IListT.
Protected method | IndexOfItem | Searches for the specified object and returns the zero-based index of the first occurrence within the entire underlying collection.
Public method | Insert | Inserts an item to the IListT at the specified index.
Protected method | InsertItem | Inserts an element into the underlying collection at the specified index.
Public method | Move | Moved the element at the specified index to another index.
Protected method | MoveItem | Moves the element at the specified index to another index in the underlying collection.
Public method | OnDeserialization | Runs when the entire object graph has been deserialized. (Overrides DynamicallyAdvisableObjectOnDeserialization(Object).)
Protected method | RaiseEvents | Raised the events that have been buffered.
Public method | Remove | Removes the first occurrence of a specific object from the ICollectionT.
Public method | RemoveAt | Removes the IListT item at the specified index.
Protected method | RemoveItem | Removes the element at the specified index of the underlying collection.
Protected method | SetItem | Replaces the element at the specified index of the underlying collection.
Public method | ToArray | Creates an array from the current AdvisableCollectionT.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Count | Gets the number of elements contained in the ICollectionT.
Public property | IsReadOnly | Gets a value indicating whether the ICollectionT is read-only.
Public property | Item | Gets or sets the element at the specified index.
Top
Events
 | Name | Description
Public event | CollectionChanged | Occurs when the collection changes.
Public event | PropertyChanged | Occurs when a property value changes.
Top
Remarks

The API of this class is compatible with the CollectionT class. It provides some additions but preserves the same design and naming conventions.

Classes that derive from AdvisableCollectionT can add functionalities by overriding protected methods or by defining new public methods. New public methods wrap their logic in a call of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method, which applies boundary aspects. Public methods can access the data structure thanks to protected methods, which have a name ending in Item, for instance SetItem(Int32, T). Public methods should not use other public methods of the class, as it may cause inconsistent invocation of advises and performance issues. Events (PropertyChanged and CollectionChanged( are buffered. Public methods must invoke RaiseEvents to raise buffered events.

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Collections Namespace


AdvisableCollection(T) Methods

AdvisableCollectionT Methods

The AdvisableCollectionT generic type exposes the following members.

Methods
 | Name | Description
Public method | Add | Adds an item to the ICollectionT.
Public method | Clear | Removes all items from the ICollectionT.
Protected method | ClearItems | Removes all elements from the underlying collection.
Public method | Contains | Determines whether the ICollectionT contains a specific value.
Public method | CopyTo | Copies the elements of the ICollectionT to an Array, starting at a particular Array index.
Protected method | GetCount | Gets the number of elements in the underlying collection.
Public method | GetEnumerator | Returns an enumerator that iterates through the AdvisableCollectionT.
Protected method | GetItem | Gets the element at the specified index of the underlying collection.
Public method | GetObjectData | Populates a SerializationInfo with the data needed to serialize the target object. (Overrides DynamicallyAdvisableObjectGetObjectData(SerializationInfo, StreamingContext).)
Public method | IndexOf | Determines the index of a specific item in the IListT.
Protected method | IndexOfItem | Searches for the specified object and returns the zero-based index of the first occurrence within the entire underlying collection.
Public method | Insert | Inserts an item to the IListT at the specified index.
Protected method | InsertItem | Inserts an element into the underlying collection at the specified index.
Public method | Move | Moved the element at the specified index to another index.
Protected method | MoveItem | Moves the element at the specified index to another index in the underlying collection.
Public method | OnDeserialization | Runs when the entire object graph has been deserialized. (Overrides DynamicallyAdvisableObjectOnDeserialization(Object).)
Protected method | RaiseEvents | Raised the events that have been buffered.
Public method | Remove | Removes the first occurrence of a specific object from the ICollectionT.
Public method | RemoveAt | Removes the IListT item at the specified index.
Protected method | RemoveItem | Removes the element at the specified index of the underlying collection.
Protected method | SetItem | Replaces the element at the specified index of the underlying collection.
Public method | ToArray | Creates an array from the current AdvisableCollectionT.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Add Method

AdvisableCollectionTAdd Method
Adds an item to the ICollectionT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Add(
    T item
)

Parameters

item
Type: T
The object to add to the ICollectionT.

Implements

ICollectionTAdd(T)
Exceptions
Exception | Condition
NotSupportedException | The ICollectionT is read-only.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Clear Method

AdvisableCollectionTClear Method
Removes all items from the ICollectionT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Clear()

Implements

ICollectionTClear
IListClear
Exceptions
Exception | Condition
NotSupportedException | The ICollectionT is read-only.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).ClearItems Method

AdvisableCollectionTClearItems Method
Removes all elements from the underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void ClearItems()
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Contains Method

AdvisableCollectionTContains Method
Determines whether the ICollectionT contains a specific value.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Contains(
    T item
)

Parameters

item
Type: T
The object to locate in the ICollectionT.

Return Value

Type: Boolean
true if item is found in the ICollectionT; otherwise, false.

Implements

ICollectionTContains(T)
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).CopyTo Method

AdvisableCollectionTCopyTo Method
Copies the elements of the ICollectionT to an Array, starting at a particular Array index.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void CopyTo(
    T[] array,
    int arrayIndex
)

Parameters

array
Type: T
The one-dimensional Array that is the destination of the elements copied from ICollectionT. The Array must have zero-based indexing.
arrayIndex
Type: SystemInt32
The zero-based index in array at which copying begins.

Implements

ICollectionTCopyTo(T, Int32)
Exceptions
Exception | Condition
ArgumentNullException | array is null.
ArgumentOutOfRangeException | arrayIndex is less than 0.
ArgumentException | The number of elements in the source ICollectionT is greater than the available space from arrayIndex to the end of the destination array.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).GetCount Method

AdvisableCollectionTGetCount Method
Gets the number of elements in the underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected int GetCount()

Return Value

Type: Int32
The number of elements in the collection.
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).GetEnumerator Method

AdvisableCollectionTGetEnumerator Method
Returns an enumerator that iterates through the AdvisableCollectionT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableCollectionTEnumerator GetEnumerator()

Return Value

Type: AdvisableCollectionTEnumerator
An AdvisableCollectionTEnumerator for the AdvisableCollectionT.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).GetItem Method

AdvisableCollectionTGetItem Method
Gets the element at the specified index of the underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected T GetItem(
    int index
)

Parameters

index
Type: SystemInt32
The zero-based index of the element.

Return Value

Type: T
The element value.
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).GetObjectData Method

AdvisableCollectionTGetObjectData Method
Populates a SerializationInfo with the data needed to serialize the target object.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void GetObjectData(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
The SerializationInfo to populate with data.
context
Type: System.Runtime.SerializationStreamingContext
The destination (see StreamingContext) for this serialization.

Implements

ISerializableGetObjectData(SerializationInfo, StreamingContext)
Exceptions
Exception | Condition
SecurityException | The caller does not have the required permission.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).IndexOf Method

AdvisableCollectionTIndexOf Method
Determines the index of a specific item in the IListT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int IndexOf(
    T item
)

Parameters

item
Type: T
The object to locate in the IListT.

Return Value

Type: Int32
The index of item if found in the list; otherwise, -1.

Implements

IListTIndexOf(T)
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).IndexOfItem Method

AdvisableCollectionTIndexOfItem Method
Searches for the specified object and returns the zero-based index of the first occurrence within the entire underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual int IndexOfItem(
    T item
)

Parameters

item
Type: T
The object to locate in the AdvisableCollectionT. The value can be null for reference types.

Return Value

Type: Int32
The zero-based index of the first occurrence of item within the entire AdvisableCollectionT, if found; otherwise, -1.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Insert Method

AdvisableCollectionTInsert Method
Inserts an item to the IListT at the specified index.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Insert(
    int index,
    T item
)

Parameters

index
Type: SystemInt32
The zero-based index at which item should be inserted.
item
Type: T
The object to insert into the IListT.

Implements

IListTInsert(Int32, T)
Exceptions
Exception | Condition
ArgumentOutOfRangeException | index is not a valid index in the IListT.
NotSupportedException | The IListT is read-only.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).InsertItem Method

AdvisableCollectionTInsertItem Method
Inserts an element into the underlying collection at the specified index.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void InsertItem(
    int index,
    T item
)

Parameters

index
Type: SystemInt32
The zero-based index at which index should be inserted.
item
Type: T
The object to insert. The value can be null for reference types.
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Move Method

AdvisableCollectionTMove Method
Moved the element at the specified index to another index.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Move(
    int oldIndex,
    int newIndex
)

Parameters

oldIndex
Type: SystemInt32
The old zero-based index of the item to be moved.
newIndex
Type: SystemInt32
The new zero-based index of the item to be moved.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).MoveItem Method

AdvisableCollectionTMoveItem Method
Moves the element at the specified index to another index in the underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void MoveItem(
    T item,
    int oldIndex,
    int newIndex
)

Parameters

item
Type: T
The element to be moved.
oldIndex
Type: SystemInt32
The old zero-based index of item in the collection.
newIndex
Type: SystemInt32
The new zero-based index of item in the collection.
Remarks

Some redundancy is created by requiring both item and oldIndex: this is intentional, for performance reasons.

Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).OnDeserialization Method

AdvisableCollectionTOnDeserialization Method
Runs when the entire object graph has been deserialized.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void OnDeserialization(
    Object sender
)

Parameters

sender
Type: SystemObject
The object that initiated the callback. The functionality for this parameter is not currently implemented.

Implements

IDeserializationCallbackOnDeserialization(Object)
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).RaiseEvents Method

AdvisableCollectionTRaiseEvents Method
Raised the events that have been buffered.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected void RaiseEvents()
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Remove Method

AdvisableCollectionTRemove Method
Removes the first occurrence of a specific object from the ICollectionT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Remove(
    T item
)

Parameters

item
Type: T
The object to remove from the ICollectionT.

Return Value

Type: Boolean
true if item was successfully removed from the ICollectionT; otherwise, false. This method also returns false if item is not found in the original ICollectionT.

Implements

ICollectionTRemove(T)
Exceptions
Exception | Condition
NotSupportedException | The ICollectionT is read-only.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).RemoveAt Method

AdvisableCollectionTRemoveAt Method
Removes the IListT item at the specified index.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void RemoveAt(
    int index
)

Parameters

index
Type: SystemInt32
The zero-based index of the item to remove.

Implements

IListTRemoveAt(Int32)
Exceptions
Exception | Condition
ArgumentOutOfRangeException | index is not a valid index in the IListT.
NotSupportedException | The IListT is read-only.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).RemoveItem Method

AdvisableCollectionTRemoveItem Method
Removes the element at the specified index of the underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void RemoveItem(
    int index
)

Parameters

index
Type: SystemInt32
The zero-based index of the element to remove.
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).SetItem Method

AdvisableCollectionTSetItem Method
Replaces the element at the specified index of the underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void SetItem(
    int index,
    T item
)

Parameters

index
Type: SystemInt32
The zero-based index of the element to replace.
item
Type: T
The new value for the element at the specified index. The value can be null for reference types.
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).ToArray Method

AdvisableCollectionTToArray Method
Creates an array from the current AdvisableCollectionT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public T[] ToArray()

Return Value

Type: T
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T) Properties

AdvisableCollectionT Properties

The AdvisableCollectionT generic type exposes the following members.

Properties
 | Name | Description
Public property | Count | Gets the number of elements contained in the ICollectionT.
Public property | IsReadOnly | Gets a value indicating whether the ICollectionT is read-only.
Public property | Item | Gets or sets the element at the specified index.
Top
See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Count Property

AdvisableCollectionTCount Property
Gets the number of elements contained in the ICollectionT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int Count { get; }

Return Value

Type: Int32
The number of elements contained in the ICollectionT.

Implements

ICollectionTCount
ICollectionCount
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).IsReadOnly Property

AdvisableCollectionTIsReadOnly Property
Gets a value indicating whether the ICollectionT is read-only.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsReadOnly { get; }

Return Value

Type: Boolean
true if the ICollectionT is read-only; otherwise, false.

Implements

ICollectionTIsReadOnly
IListIsReadOnly
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Item Property

AdvisableCollectionTItem Property
Gets or sets the element at the specified index.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public T this[
    int index
] { get; set; }

Parameters

index
Type: SystemInt32
The zero-based index of the element to get or set.

Return Value

Type: T
The element at the specified index.

Implements

IListTItemInt32
Exceptions
Exception | Condition
ArgumentOutOfRangeException | index is not a valid index in the IListT.
NotSupportedException | The property is set and the IListT is read-only.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T) Events

AdvisableCollectionT Events

The AdvisableCollectionT generic type exposes the following members.

Events
 | Name | Description
Public event | CollectionChanged | Occurs when the collection changes.
Public event | PropertyChanged | Occurs when a property value changes.
Top
See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).CollectionChanged Event

AdvisableCollectionTCollectionChanged Event
Occurs when the collection changes.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual event NotifyCollectionChangedEventHandler CollectionChanged

Value

Type: System.Collections.SpecializedNotifyCollectionChangedEventHandler

Implements

INotifyCollectionChangedCollectionChanged
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).PropertyChanged Event

AdvisableCollectionTPropertyChanged Event
Occurs when a property value changes.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual event PropertyChangedEventHandler PropertyChanged

Value

Type: System.ComponentModelPropertyChangedEventHandler

Implements

INotifyPropertyChangedPropertyChanged
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionT Class
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Enumerator Structure

AdvisableCollectionTEnumerator Structure
Enumerates the elements of an AdvisableCollectionT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public struct Enumerator : IEnumerator<T>,
    IDisposable, IEnumerator

The AdvisableCollectionTEnumerator generic type exposes the following members.

Methods
 | Name | Description
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | MoveNext | Advances the enumerator to the next element of the collection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Current | Gets the element in the collection at the current position of the enumerator.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Collections Namespace


Enumerator Methods

Enumerator Methods

The AdvisableCollectionTEnumerator type exposes the following members.

Methods
 | Name | Description
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | MoveNext | Advances the enumerator to the next element of the collection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdvisableCollectionTEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Enumerator.Dispose Method

AdvisableCollectionTEnumeratorDispose Method
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Dispose()

Implements

IDisposableDispose
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionTEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Enumerator.MoveNext Method

AdvisableCollectionTEnumeratorMoveNext Method
Advances the enumerator to the next element of the collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool MoveNext()

Return Value

Type: Boolean
true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.

Implements

IEnumeratorMoveNext
Exceptions
Exception | Condition
InvalidOperationException | The collection was modified after the enumerator was created.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionTEnumerator Structure
PostSharp.Patterns.Collections Namespace


Enumerator Properties

Enumerator Properties

The AdvisableCollectionTEnumerator type exposes the following members.

Properties
 | Name | Description
Public property | Current | Gets the element in the collection at the current position of the enumerator.
Top
See Also

Reference

AdvisableCollectionTEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableCollection(T).Enumerator.Current Property

AdvisableCollectionTEnumeratorCurrent Property
Gets the element in the collection at the current position of the enumerator.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public T Current { get; }

Return Value

Type: T
The element in the collection at the current position of the enumerator.

Implements

IEnumeratorTCurrent
Version Information

Supported in: 4.1

See Also

Reference

AdvisableCollectionTEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Class

AdvisableDictionaryTKey, TValue Class
An implementation of a DictionaryTKey, TValue into which advices can be injected dynamically. The class also allows derived classes to add new behaviors by overriding methods, like the CollectionT class does.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelDynamicallyAdvisableObject
PostSharp.Patterns.CollectionsAdvisableDictionaryTKey, TValue

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public class AdvisableDictionary<TKey, TValue> : DynamicallyAdvisableObject,
    IDynamicallyAdvisableDictionary, IDynamicallyAdvisable, IQueryInterface, IDictionary, ICollection,
    IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>,
    IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable

Type Parameters

TKey
The type of keys in the dictionary.
TValue
The type of values in the dictionary.

The AdvisableDictionaryTKey, TValue type exposes the following members.

Constructors
 | Name | Description
Public method | AdvisableDictionaryTKey, TValue | Initializes a new instance of the AdvisableDictionaryTKey, TValue class that is empty, has the default initial capacity, and uses the default equality comparer for the key type.
Public method | AdvisableDictionaryTKey, TValue(IDictionaryTKey, TValue) | Initializes a new instance of the AdvisableDictionaryTKey, TValue class that contains elements copied from the specified IDictionaryTKey, TValue and uses the default equality comparer for the key type.
Public method | AdvisableDictionaryTKey, TValue(IEqualityComparerTKey) | Initializes a new instance of the AdvisableDictionaryTKey, TValue that is empty, has the default initial capacity, and uses the specified equality comparer for the key type.
Public method | AdvisableDictionaryTKey, TValue(Int32) | Initializes a new instance of the AdvisableDictionaryTKey, TValue class that is empty, has the specified initial capacity, and uses the default equality comparer for the key type.
Public method | AdvisableDictionaryTKey, TValue(IDictionaryTKey, TValue, IEqualityComparerTKey) | Initializes a new instance of the AdvisableDictionaryTKey, TValue class that contains elements copied from the specified IDictionaryTKey, TValue and uses the specified IEqualityComparerT.
Public method | AdvisableDictionaryTKey, TValue(Int32, IEqualityComparerTKey) | Initializes a new instance of the AdvisableDictionaryTKey, TValue that is empty, has a specified initial capacity, and uses the specified equality comparer for the key type.
Protected method | AdvisableDictionaryTKey, TValue(SerializationInfo, StreamingContext) | Deserialization constructor.
Top
Methods
 | Name | Description
Public method | Add | Adds an element with the provided key and value to the IDictionaryTKey, TValue.
Protected method | AddItem | Adds an element into the underlying dictionary.
Public method | Clear | Removes all elements from the IDictionary object.
Protected method | ClearItems | Removes all keys and items from the underlying dictionary.
Public method | ContainsKey | Determines whether the IDictionaryTKey, TValue contains an element with the specified key.
Public method | ContainsValue | Determines whether the AdvisableDictionaryTKey, TValue contains a specific value.
Public method | GetEnumerator | Returns an enumerator that iterates through the AdvisableDictionaryTKey, TValue.
Public method | GetObjectData | Populates a SerializationInfo with the data needed to serialize the target object. (Overrides DynamicallyAdvisableObjectGetObjectData(SerializationInfo, StreamingContext).)
Public method | OnDeserialization | Runs when the entire object graph has been deserialized. (Overrides DynamicallyAdvisableObjectOnDeserialization(Object).)
Public method | Remove | Removes the element with the specified key from the IDictionaryTKey, TValue.
Protected method | RemoveItem | Removes the value with the specific key from the underlying dictionary.
Protected method | SetItem | Sets the value with the specified key in the underlying dictionary.
Public method | TryGetValue | Gets the value associated with the specified key.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Count | Gets the number of elements contained in the ICollection.
Public property | IsReadOnly | Gets a value indicating whether the IDictionary object is read-only.
Public property | Item | Gets or sets the element with the specified key.
Public property | Keys | Gets a collection containing the keys in the AdvisableDictionaryTKey, TValue.
Public property | Values | Gets a collection containing the values in the AdvisableDictionaryTKey, TValue.
Top
Remarks

To learn how to extend this class, see the AdvisableCollectionT class documentation,

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Constructor

AdvisableDictionaryTKey, TValue Constructor
Overload List
 | Name | Description
Public method | AdvisableDictionaryTKey, TValue | Initializes a new instance of the AdvisableDictionaryTKey, TValue class that is empty, has the default initial capacity, and uses the default equality comparer for the key type.
Public method | AdvisableDictionaryTKey, TValue(IDictionaryTKey, TValue) | Initializes a new instance of the AdvisableDictionaryTKey, TValue class that contains elements copied from the specified IDictionaryTKey, TValue and uses the default equality comparer for the key type.
Public method | AdvisableDictionaryTKey, TValue(IEqualityComparerTKey) | Initializes a new instance of the AdvisableDictionaryTKey, TValue that is empty, has the default initial capacity, and uses the specified equality comparer for the key type.
Public method | AdvisableDictionaryTKey, TValue(Int32) | Initializes a new instance of the AdvisableDictionaryTKey, TValue class that is empty, has the specified initial capacity, and uses the default equality comparer for the key type.
Public method | AdvisableDictionaryTKey, TValue(IDictionaryTKey, TValue, IEqualityComparerTKey) | Initializes a new instance of the AdvisableDictionaryTKey, TValue class that contains elements copied from the specified IDictionaryTKey, TValue and uses the specified IEqualityComparerT.
Public method | AdvisableDictionaryTKey, TValue(Int32, IEqualityComparerTKey) | Initializes a new instance of the AdvisableDictionaryTKey, TValue that is empty, has a specified initial capacity, and uses the specified equality comparer for the key type.
Protected method | AdvisableDictionaryTKey, TValue(SerializationInfo, StreamingContext) | Deserialization constructor.
Top
See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Constructor

AdvisableDictionaryTKey, TValue Constructor
Initializes a new instance of the AdvisableDictionaryTKey, TValue class that is empty, has the default initial capacity, and uses the default equality comparer for the key type.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionary()
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
AdvisableDictionaryTKey, TValue Overload
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Constructor (IDictionary(TKey, TValue))

AdvisableDictionaryTKey, TValue Constructor (IDictionaryTKey, TValue)
Initializes a new instance of the AdvisableDictionaryTKey, TValue class that contains elements copied from the specified IDictionaryTKey, TValue and uses the default equality comparer for the key type.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionary(
    IDictionary<TKey, TValue> dictionary
)

Parameters

dictionary
Type: System.Collections.GenericIDictionary TKey, TValue
The IDictionaryTKey, TValue whose elements are copied to the new AdvisableDictionaryTKey, TValue.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
AdvisableDictionaryTKey, TValue Overload
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Constructor (IEqualityComparer(TKey))

AdvisableDictionaryTKey, TValue Constructor (IEqualityComparerTKey)
Initializes a new instance of the AdvisableDictionaryTKey, TValue that is empty, has the default initial capacity, and uses the specified equality comparer for the key type.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionary(
    IEqualityComparer<TKey> comparer
)

Parameters

comparer
Type: System.Collections.GenericIEqualityComparer TKey
The IEqualityComparerT implementation to use when comparing keys, or null to use the default EqualityComparerT for the type of the key.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
AdvisableDictionaryTKey, TValue Overload
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Constructor (Int32)

AdvisableDictionaryTKey, TValue Constructor (Int32)
Initializes a new instance of the AdvisableDictionaryTKey, TValue class that is empty, has the specified initial capacity, and uses the default equality comparer for the key type.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionary(
    int capacity
)

Parameters

capacity
Type: SystemInt32
The initial number of elements that the AdvisableDictionaryTKey, TValue can contain.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
AdvisableDictionaryTKey, TValue Overload
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Constructor (IDictionary(TKey, TValue), IEqualityComparer(TKey))

AdvisableDictionaryTKey, TValue Constructor (IDictionaryTKey, TValue, IEqualityComparerTKey)
Initializes a new instance of the AdvisableDictionaryTKey, TValue class that contains elements copied from the specified IDictionaryTKey, TValue and uses the specified IEqualityComparerT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionary(
    IDictionary<TKey, TValue> dictionary,
    IEqualityComparer<TKey> comparer
)

Parameters

dictionary
Type: System.Collections.GenericIDictionary TKey, TValue
The IDictionaryTKey, TValue whose elements are copied to the new AdvisableDictionaryTKey, TValue.
comparer
Type: System.Collections.GenericIEqualityComparer TKey
The IEqualityComparerT implementation to use when comparing keys, or null to use the default EqualityComparerT for the type of the key.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
AdvisableDictionaryTKey, TValue Overload
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Constructor (Int32, IEqualityComparer(TKey))

AdvisableDictionaryTKey, TValue Constructor (Int32, IEqualityComparerTKey)
Initializes a new instance of the AdvisableDictionaryTKey, TValue that is empty, has a specified initial capacity, and uses the specified equality comparer for the key type.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionary(
    int capacity,
    IEqualityComparer<TKey> comparer
)

Parameters

capacity
Type: SystemInt32
The initial number of elements that the AdvisableDictionaryTKey, TValue can contain.
comparer
Type: System.Collections.GenericIEqualityComparer TKey
The IEqualityComparerT implementation to use when comparing keys, or null to use the default EqualityComparerT for the type of the key.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
AdvisableDictionaryTKey, TValue Overload
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Constructor (SerializationInfo, StreamingContext)

AdvisableDictionaryTKey, TValue Constructor (SerializationInfo, StreamingContext)
Deserialization constructor.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AdvisableDictionary(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
context
Type: System.Runtime.SerializationStreamingContext
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
AdvisableDictionaryTKey, TValue Overload
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Methods

AdvisableDictionaryTKey, TValue Methods

The AdvisableDictionaryTKey, TValue generic type exposes the following members.

Methods
 | Name | Description
Public method | Add | Adds an element with the provided key and value to the IDictionaryTKey, TValue.
Protected method | AddItem | Adds an element into the underlying dictionary.
Public method | Clear | Removes all elements from the IDictionary object.
Protected method | ClearItems | Removes all keys and items from the underlying dictionary.
Public method | ContainsKey | Determines whether the IDictionaryTKey, TValue contains an element with the specified key.
Public method | ContainsValue | Determines whether the AdvisableDictionaryTKey, TValue contains a specific value.
Public method | GetEnumerator | Returns an enumerator that iterates through the AdvisableDictionaryTKey, TValue.
Public method | GetObjectData | Populates a SerializationInfo with the data needed to serialize the target object. (Overrides DynamicallyAdvisableObjectGetObjectData(SerializationInfo, StreamingContext).)
Public method | OnDeserialization | Runs when the entire object graph has been deserialized. (Overrides DynamicallyAdvisableObjectOnDeserialization(Object).)
Public method | Remove | Removes the element with the specified key from the IDictionaryTKey, TValue.
Protected method | RemoveItem | Removes the value with the specific key from the underlying dictionary.
Protected method | SetItem | Sets the value with the specified key in the underlying dictionary.
Public method | TryGetValue | Gets the value associated with the specified key.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Add Method

AdvisableDictionaryTKey, TValueAdd Method
Adds an element with the provided key and value to the IDictionaryTKey, TValue.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Add(
    TKey key,
    TValue value
)

Parameters

key
Type: TKey
The object to use as the key of the element to add.
value
Type: TValue
The object to use as the value of the element to add.

Implements

IDictionaryTKey, TValueAdd(TKey, TValue)
Exceptions
Exception | Condition
ArgumentNullException | key is null.
ArgumentException | An element with the same key already exists in the IDictionaryTKey, TValue.
NotSupportedException | The IDictionaryTKey, TValue is read-only.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).AddItem Method

AdvisableDictionaryTKey, TValueAddItem Method
Adds an element into the underlying dictionary.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void AddItem(
    TKey key,
    TValue value
)

Parameters

key
Type: TKey
The key of the element to add.
value
Type: TValue
The value of the element to add. The value can be null for reference types..
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Clear Method

AdvisableDictionaryTKey, TValueClear Method
Removes all elements from the IDictionary object.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Clear()

Implements

IDictionaryClear
ICollectionTClear
Exceptions
Exception | Condition
NotSupportedException | The IDictionary object is read-only.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ClearItems Method

AdvisableDictionaryTKey, TValueClearItems Method
Removes all keys and items from the underlying dictionary.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void ClearItems()
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ContainsKey Method

AdvisableDictionaryTKey, TValueContainsKey Method
Determines whether the IDictionaryTKey, TValue contains an element with the specified key.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool ContainsKey(
    TKey key
)

Parameters

key
Type: TKey
The key to locate in the IDictionaryTKey, TValue.

Return Value

Type: Boolean
true if the IDictionaryTKey, TValue contains an element with the key; otherwise, false.

Implements

IDictionaryTKey, TValueContainsKey(TKey)
Exceptions
Exception | Condition
ArgumentNullException | key is null.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ContainsValue Method

AdvisableDictionaryTKey, TValueContainsValue Method
Determines whether the AdvisableDictionaryTKey, TValue contains a specific value.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool ContainsValue(
    TValue value
)

Parameters

value
Type: TValue
The value to locate in the AdvisableDictionaryTKey, TValue. The value can be null for reference types.

Return Value

Type: Boolean
true if the AdvisableDictionaryTKey, TValue contains an element with the specified value; otherwise, false.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).GetEnumerator Method

AdvisableDictionaryTKey, TValueGetEnumerator Method
Returns an enumerator that iterates through the AdvisableDictionaryTKey, TValue.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionaryTKey, TValueEnumerator GetEnumerator()

Return Value

Type: AdvisableDictionaryTKey, TValueEnumerator
An AdvisableDictionaryTKey, TValueEnumerator structure for the current AdvisableDictionaryTKey, TValue.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).GetObjectData Method

AdvisableDictionaryTKey, TValueGetObjectData Method
Populates a SerializationInfo with the data needed to serialize the target object.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void GetObjectData(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
The SerializationInfo to populate with data.
context
Type: System.Runtime.SerializationStreamingContext
The destination (see StreamingContext) for this serialization.

Implements

ISerializableGetObjectData(SerializationInfo, StreamingContext)
Exceptions
Exception | Condition
SecurityException | The caller does not have the required permission.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).OnDeserialization Method

AdvisableDictionaryTKey, TValueOnDeserialization Method
Runs when the entire object graph has been deserialized.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void OnDeserialization(
    Object sender
)

Parameters

sender
Type: SystemObject
The object that initiated the callback. The functionality for this parameter is not currently implemented.

Implements

IDeserializationCallbackOnDeserialization(Object)
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Remove Method

AdvisableDictionaryTKey, TValueRemove Method
Removes the element with the specified key from the IDictionaryTKey, TValue.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Remove(
    TKey key
)

Parameters

key
Type: TKey
The key of the element to remove.

Return Value

Type: Boolean
true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionaryTKey, TValue.

Implements

IDictionaryTKey, TValueRemove(TKey)
Exceptions
Exception | Condition
ArgumentNullException | key is null.
NotSupportedException | The IDictionaryTKey, TValue is read-only.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).RemoveItem Method

AdvisableDictionaryTKey, TValueRemoveItem Method
Removes the value with the specific key from the underlying dictionary.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual bool RemoveItem(
    TKey key
)

Parameters

key
Type: TKey
The key of the element to remove.

Return Value

Type: Boolean
true if the element was successfully found and removed, otherwise false. This method returns false if key if not found in the underlying dictionary.
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).SetItem Method

AdvisableDictionaryTKey, TValueSetItem Method
Sets the value with the specified key in the underlying dictionary.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void SetItem(
    TKey key,
    TValue value,
    TValue oldValue
)

Parameters

key
Type: TKey
The key of the element to add or replace.
value
Type: TValue
The new value to assign to the key.
oldValue
Type: TValue
The old value assigned to key, or null if there is currently no value assigned to key.
Remarks

There is redundancy in requiring both key and oldValue, but this redundancy is required for performance reason.

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).TryGetValue Method

AdvisableDictionaryTKey, TValueTryGetValue Method
Gets the value associated with the specified key.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool TryGetValue(
    TKey key,
    out TValue value
)

Parameters

key
Type: TKey
The key whose value to get.
value
Type: TValue
When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Return Value

Type: Boolean
true if the object that implements IDictionaryTKey, TValue contains an element with the specified key; otherwise, false.

Implements

IDictionaryTKey, TValueTryGetValue(TKey, TValue)
Exceptions
Exception | Condition
ArgumentNullException | key is null.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue) Properties

AdvisableDictionaryTKey, TValue Properties

The AdvisableDictionaryTKey, TValue generic type exposes the following members.

Properties
 | Name | Description
Public property | Count | Gets the number of elements contained in the ICollection.
Public property | IsReadOnly | Gets a value indicating whether the IDictionary object is read-only.
Public property | Item | Gets or sets the element with the specified key.
Public property | Keys | Gets a collection containing the keys in the AdvisableDictionaryTKey, TValue.
Public property | Values | Gets a collection containing the values in the AdvisableDictionaryTKey, TValue.
Top
See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Count Property

AdvisableDictionaryTKey, TValueCount Property
Gets the number of elements contained in the ICollection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int Count { get; }

Return Value

Type: Int32
The number of elements contained in the ICollection.

Implements

ICollectionCount
ICollectionTCount
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).IsReadOnly Property

AdvisableDictionaryTKey, TValueIsReadOnly Property
Gets a value indicating whether the IDictionary object is read-only.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsReadOnly { get; }

Return Value

Type: Boolean
true if the IDictionary object is read-only; otherwise, false.

Implements

IDictionaryIsReadOnly
ICollectionTIsReadOnly
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Item Property

AdvisableDictionaryTKey, TValueItem Property
Gets or sets the element with the specified key.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public TValue this[
    TKey key
] { get; set; }

Parameters

key
Type: TKey
The key of the element to get or set.

Return Value

Type: TValue
The element with the specified key.

Implements

IDictionaryTKey, TValueItemTKey
Exceptions
Exception | Condition
ArgumentNullException | key is null.
KeyNotFoundException | The property is retrieved and key is not found.
NotSupportedException | The property is set and the IDictionaryTKey, TValue is read-only.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Keys Property

AdvisableDictionaryTKey, TValueKeys Property
Gets a collection containing the keys in the AdvisableDictionaryTKey, TValue.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionaryTKey, TValueKeyCollection Keys { get; }

Property Value

Type: AdvisableDictionaryTKey, TValueKeyCollection
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Values Property

AdvisableDictionaryTKey, TValueValues Property
Gets a collection containing the values in the AdvisableDictionaryTKey, TValue.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionaryTKey, TValueValueCollection Values { get; }

Property Value

Type: AdvisableDictionaryTKey, TValueValueCollection
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValue Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Enumerator Structure

AdvisableDictionaryTKey, TValueEnumerator Structure
Enumerates the elements of an AdvisableDictionaryTKey, TValue.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public struct Enumerator : IEnumerator<KeyValuePair<TKey, TValue>>,
    IDisposable, IDictionaryEnumerator, IEnumerator

The AdvisableDictionaryTKey, TValueEnumerator generic type exposes the following members.

Methods
 | Name | Description
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | MoveNext | Advances the enumerator to the next element of the collection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Current | Gets the element in the collection at the current position of the enumerator.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Collections Namespace


Enumerator Methods

Enumerator Methods

The AdvisableDictionaryTKey, TValueEnumerator type exposes the following members.

Methods
 | Name | Description
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | MoveNext | Advances the enumerator to the next element of the collection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdvisableDictionaryTKey, TValueEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Enumerator.Dispose Method

AdvisableDictionaryTKey, TValueEnumeratorDispose Method
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Dispose()

Implements

IDisposableDispose
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Enumerator.MoveNext Method

AdvisableDictionaryTKey, TValueEnumeratorMoveNext Method
Advances the enumerator to the next element of the collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool MoveNext()

Return Value

Type: Boolean
true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.

Implements

IEnumeratorMoveNext
Exceptions
Exception | Condition
InvalidOperationException | The collection was modified after the enumerator was created.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueEnumerator Structure
PostSharp.Patterns.Collections Namespace


Enumerator Properties

Enumerator Properties

The AdvisableDictionaryTKey, TValueEnumerator type exposes the following members.

Properties
 | Name | Description
Public property | Current | Gets the element in the collection at the current position of the enumerator.
Top
See Also

Reference

AdvisableDictionaryTKey, TValueEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).Enumerator.Current Property

AdvisableDictionaryTKey, TValueEnumeratorCurrent Property
Gets the element in the collection at the current position of the enumerator.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public KeyValuePair<TKey, TValue> Current { get; }

Return Value

Type: KeyValuePair TKey, TValue
The element in the collection at the current position of the enumerator.

Implements

IEnumeratorTCurrent
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).KeyCollection Class

AdvisableDictionaryTKey, TValueKeyCollection Class
Represents the collection of keys in an AdvisableDictionaryTKey, TValue.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.CollectionsAdvisableDictionaryTKey, TValueKeyCollection

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class KeyCollection : ICollection<TKey>,
    IEnumerable<TKey>, ICollection, IEnumerable

The AdvisableDictionaryTKey, TValueKeyCollection generic type exposes the following members.

Methods
 | Name | Description
Public method | CopyTo | Copies the elements of the ICollectionT to an Array, starting at a particular Array index.
Public method | GetEnumerator | Returns an enumerator that iterates through the AdvisableDictionaryTKey, TValueKeyCollection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Count | Gets the number of elements contained in the ICollectionT.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Collections Namespace


KeyCollection Methods

KeyCollection Methods

The AdvisableDictionaryTKey, TValueKeyCollection type exposes the following members.

Methods
 | Name | Description
Public method | CopyTo | Copies the elements of the ICollectionT to an Array, starting at a particular Array index.
Public method | GetEnumerator | Returns an enumerator that iterates through the AdvisableDictionaryTKey, TValueKeyCollection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdvisableDictionaryTKey, TValueKeyCollection Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).KeyCollection.CopyTo Method

AdvisableDictionaryTKey, TValueKeyCollectionCopyTo Method
Copies the elements of the ICollectionT to an Array, starting at a particular Array index.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void CopyTo(
    TKey[] array,
    int arrayIndex
)

Parameters

array
Type: TKey
The one-dimensional Array that is the destination of the elements copied from ICollectionT. The Array must have zero-based indexing.
arrayIndex
Type: SystemInt32
The zero-based index in array at which copying begins.

Implements

ICollectionTCopyTo(T, Int32)
Exceptions
Exception | Condition
ArgumentNullException | array is null.
ArgumentOutOfRangeException | arrayIndex is less than 0.
ArgumentException | The number of elements in the source ICollectionT is greater than the available space from arrayIndex to the end of the destination array.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueKeyCollection Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).KeyCollection.GetEnumerator Method

AdvisableDictionaryTKey, TValueKeyCollectionGetEnumerator Method
Returns an enumerator that iterates through the AdvisableDictionaryTKey, TValueKeyCollection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionaryTKey, TValueKeyCollectionEnumerator GetEnumerator()

Return Value

Type: AdvisableDictionaryTKey, TValueKeyCollectionEnumerator
An AdvisableDictionaryTKey, TValueKeyCollectionEnumerator structure for the current AdvisableDictionaryTKey, TValueKeyCollection.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueKeyCollection Class
PostSharp.Patterns.Collections Namespace


KeyCollection Properties

KeyCollection Properties

The AdvisableDictionaryTKey, TValueKeyCollection type exposes the following members.

Properties
 | Name | Description
Public property | Count | Gets the number of elements contained in the ICollectionT.
Top
See Also

Reference

AdvisableDictionaryTKey, TValueKeyCollection Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).KeyCollection.Count Property

AdvisableDictionaryTKey, TValueKeyCollectionCount Property
Gets the number of elements contained in the ICollectionT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int Count { get; }

Return Value

Type: Int32
The number of elements contained in the ICollectionT.

Implements

ICollectionTCount
ICollectionCount
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueKeyCollection Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).KeyCollection.Enumerator Structure

AdvisableDictionaryTKey, TValueKeyCollectionEnumerator Structure
Enumerates the elements of a AdvisableDictionaryTKey, TValueKeyCollection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public struct Enumerator : IEnumerator<TKey>,
    IDisposable, IEnumerator

The AdvisableDictionaryTKey, TValueKeyCollectionEnumerator type exposes the following members.

Methods
 | Name | Description
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | MoveNext | Advances the enumerator to the next element of the collection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Current | Gets the element in the collection at the current position of the enumerator.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Collections Namespace


Enumerator Methods

Enumerator Methods

The AdvisableDictionaryTKey, TValueKeyCollectionEnumerator type exposes the following members.

Methods
 | Name | Description
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | MoveNext | Advances the enumerator to the next element of the collection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdvisableDictionaryTKey, TValueKeyCollectionEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).KeyCollection.Enumerator.Dispose Method

AdvisableDictionaryTKey, TValueKeyCollectionEnumeratorDispose Method
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Dispose()

Implements

IDisposableDispose
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueKeyCollectionEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).KeyCollection.Enumerator.MoveNext Method

AdvisableDictionaryTKey, TValueKeyCollectionEnumeratorMoveNext Method
Advances the enumerator to the next element of the collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool MoveNext()

Return Value

Type: Boolean
true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.

Implements

IEnumeratorMoveNext
Exceptions
Exception | Condition
InvalidOperationException | The collection was modified after the enumerator was created.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueKeyCollectionEnumerator Structure
PostSharp.Patterns.Collections Namespace


Enumerator Properties

Enumerator Properties

The AdvisableDictionaryTKey, TValueKeyCollectionEnumerator type exposes the following members.

Properties
 | Name | Description
Public property | Current | Gets the element in the collection at the current position of the enumerator.
Top
See Also

Reference

AdvisableDictionaryTKey, TValueKeyCollectionEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).KeyCollection.Enumerator.Current Property

AdvisableDictionaryTKey, TValueKeyCollectionEnumeratorCurrent Property
Gets the element in the collection at the current position of the enumerator.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public TKey Current { get; }

Return Value

Type: TKey
The element in the collection at the current position of the enumerator.

Implements

IEnumeratorTCurrent
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueKeyCollectionEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ValueCollection Class

AdvisableDictionaryTKey, TValueValueCollection Class
Represents the collection of values in an AdvisableDictionaryTKey, TValue.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.CollectionsAdvisableDictionaryTKey, TValueValueCollection

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ValueCollection : ICollection<TValue>,
    IEnumerable<TValue>, ICollection, IEnumerable

The AdvisableDictionaryTKey, TValueValueCollection generic type exposes the following members.

Methods
 | Name | Description
Public method | CopyTo | Copies the elements of the ICollectionT to an Array, starting at a particular Array index.
Public method | GetEnumerator | Returns an enumerator that iterates through the AdvisableDictionaryTKey, TValueValueCollection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Count | Gets the number of elements contained in the ICollectionT.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Collections Namespace


ValueCollection Methods

ValueCollection Methods

The AdvisableDictionaryTKey, TValueValueCollection type exposes the following members.

Methods
 | Name | Description
Public method | CopyTo | Copies the elements of the ICollectionT to an Array, starting at a particular Array index.
Public method | GetEnumerator | Returns an enumerator that iterates through the AdvisableDictionaryTKey, TValueValueCollection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdvisableDictionaryTKey, TValueValueCollection Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ValueCollection.CopyTo Method

AdvisableDictionaryTKey, TValueValueCollectionCopyTo Method
Copies the elements of the ICollectionT to an Array, starting at a particular Array index.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void CopyTo(
    TValue[] array,
    int arrayIndex
)

Parameters

array
Type: TValue
The one-dimensional Array that is the destination of the elements copied from ICollectionT. The Array must have zero-based indexing.
arrayIndex
Type: SystemInt32
The zero-based index in array at which copying begins.

Implements

ICollectionTCopyTo(T, Int32)
Exceptions
Exception | Condition
ArgumentNullException | array is null.
ArgumentOutOfRangeException | arrayIndex is less than 0.
ArgumentException | The number of elements in the source ICollectionT is greater than the available space from arrayIndex to the end of the destination array.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueValueCollection Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ValueCollection.GetEnumerator Method

AdvisableDictionaryTKey, TValueValueCollectionGetEnumerator Method
Returns an enumerator that iterates through the AdvisableDictionaryTKey, TValueValueCollection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionaryTKey, TValueValueCollectionEnumerator GetEnumerator()

Return Value

Type: AdvisableDictionaryTKey, TValueValueCollectionEnumerator
An AdvisableDictionaryTKey, TValueValueCollectionEnumerator structure for the current AdvisableDictionaryTKey, TValueValueCollection.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueValueCollection Class
PostSharp.Patterns.Collections Namespace


ValueCollection Properties

ValueCollection Properties

The AdvisableDictionaryTKey, TValueValueCollection type exposes the following members.

Properties
 | Name | Description
Public property | Count | Gets the number of elements contained in the ICollectionT.
Top
See Also

Reference

AdvisableDictionaryTKey, TValueValueCollection Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ValueCollection.Count Property

AdvisableDictionaryTKey, TValueValueCollectionCount Property
Gets the number of elements contained in the ICollectionT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int Count { get; }

Return Value

Type: Int32
The number of elements contained in the ICollectionT.

Implements

ICollectionTCount
ICollectionCount
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueValueCollection Class
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ValueCollection.Enumerator Structure

AdvisableDictionaryTKey, TValueValueCollectionEnumerator Structure
Enumerates the elements of a AdvisableDictionaryTKey, TValueValueCollection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public struct Enumerator : IEnumerator<TValue>,
    IDisposable, IEnumerator

The AdvisableDictionaryTKey, TValueValueCollectionEnumerator type exposes the following members.

Methods
 | Name | Description
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | MoveNext | Advances the enumerator to the next element of the collection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Current | Gets the element in the collection at the current position of the enumerator.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Collections Namespace


Enumerator Methods

Enumerator Methods

The AdvisableDictionaryTKey, TValueValueCollectionEnumerator type exposes the following members.

Methods
 | Name | Description
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | MoveNext | Advances the enumerator to the next element of the collection.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdvisableDictionaryTKey, TValueValueCollectionEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ValueCollection.Enumerator.Dispose Method

AdvisableDictionaryTKey, TValueValueCollectionEnumeratorDispose Method
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Dispose()

Implements

IDisposableDispose
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueValueCollectionEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ValueCollection.Enumerator.MoveNext Method

AdvisableDictionaryTKey, TValueValueCollectionEnumeratorMoveNext Method
Advances the enumerator to the next element of the collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool MoveNext()

Return Value

Type: Boolean
true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.

Implements

IEnumeratorMoveNext
Exceptions
Exception | Condition
InvalidOperationException | The collection was modified after the enumerator was created.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueValueCollectionEnumerator Structure
PostSharp.Patterns.Collections Namespace


Enumerator Properties

Enumerator Properties

The AdvisableDictionaryTKey, TValueValueCollectionEnumerator type exposes the following members.

Properties
 | Name | Description
Public property | Current | Gets the element in the collection at the current position of the enumerator.
Top
See Also

Reference

AdvisableDictionaryTKey, TValueValueCollectionEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableDictionary(TKey, TValue).ValueCollection.Enumerator.Current Property

AdvisableDictionaryTKey, TValueValueCollectionEnumeratorCurrent Property
Gets the element in the collection at the current position of the enumerator.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public TValue Current { get; }

Return Value

Type: TValue
The element in the collection at the current position of the enumerator.

Implements

IEnumeratorTCurrent
Version Information

Supported in: 4.1

See Also

Reference

AdvisableDictionaryTKey, TValueValueCollectionEnumerator Structure
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem) Class

AdvisableKeyedCollectionTKey, TItem Class
Provides the abstract base class for a keyed collection, similar to KeyedCollectionTKey, TItem, into which advices can be injected dynamically.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelDynamicallyAdvisableObject
PostSharp.Patterns.CollectionsAdvisableCollection TItem
PostSharp.Patterns.CollectionsAdvisableKeyedCollectionTKey, TItem

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class AdvisableKeyedCollection<TKey, TItem> : AdvisableCollection<TItem>

Type Parameters

TKey
The type of keys in the collection.
TItem
The type of values in the collection.

The AdvisableKeyedCollectionTKey, TItem type exposes the following members.

Constructors
 | Name | Description
Protected method | AdvisableKeyedCollectionTKey, TItem | Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class that is empty and has the default initial capacity.
Protected method | AdvisableKeyedCollectionTKey, TItem(Int32) | Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class that is empty and has a specified initial capacity.
Protected method | AdvisableKeyedCollectionTKey, TItem(Int32, IEqualityComparerTKey) | Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class that has a specified initial capacity and a given equality comparer and uses the specified equality comparer.
Protected method | AdvisableKeyedCollectionTKey, TItem(SerializationInfo, StreamingContext) | Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class
Top
Methods
 | Name | Description
Public method | Add | Adds an item to the ICollectionT. (Inherited from AdvisableCollectionT.)
Public method | Clear | Removes all items from the ICollectionT. (Inherited from AdvisableCollectionT.)
Protected method | ClearItems | Removes all elements from the underlying collection. (Overrides AdvisableCollectionTClearItems.)
Public method | Contains(T) | Determines whether the ICollectionT contains a specific value. (Inherited from AdvisableCollectionT.)
Public method | Contains(TKey) | Determines whether the collection contains an element with the specified key.
Public method | CopyTo | Copies the elements of the ICollectionT to an Array, starting at a particular Array index. (Inherited from AdvisableCollectionT.)
Protected method | GetCount | Gets the number of elements in the underlying collection. (Inherited from AdvisableCollectionT.)
Public method | GetEnumerator | Returns an enumerator that iterates through the AdvisableCollectionT. (Inherited from AdvisableCollectionT.)
Protected method | GetItem | Gets the element at the specified index of the underlying collection. (Inherited from AdvisableCollectionT.)
Protected method | GetKeyForItem | Extracts the key from the specified element.
Public method | GetObjectData | Populates a SerializationInfo with the data needed to serialize the target object. (Overrides AdvisableCollectionTGetObjectData(SerializationInfo, StreamingContext).)
Public method | IndexOf | Determines the index of a specific item in the IListT. (Inherited from AdvisableCollectionT.)
Protected method | IndexOfItem | Searches for the specified object and returns the zero-based index of the first occurrence within the entire underlying collection. (Overrides AdvisableCollectionTIndexOfItem(T).)
Public method | Insert | Inserts an item to the IListT at the specified index. (Inherited from AdvisableCollectionT.)
Protected method | InsertItem | Inserts an element into the underlying collection at the specified index. (Overrides AdvisableCollectionTInsertItem(Int32, T).)
Public method | Move | Moved the element at the specified index to another index. (Inherited from AdvisableCollectionT.)
Protected method | MoveItem | Moves the element at the specified index to another index in the underlying collection. (Overrides AdvisableCollectionTMoveItem(T, Int32, Int32).)
Public method | OnDeserialization | Runs when the entire object graph has been deserialized. (Inherited from AdvisableCollectionT.)
Protected method | RaiseEvents | Raised the events that have been buffered. (Inherited from AdvisableCollectionT.)
Public method | Remove | Removes the first occurrence of a specific object from the ICollectionT. (Inherited from AdvisableCollectionT.)
Public method | RemoveAt | Removes the IListT item at the specified index. (Inherited from AdvisableCollectionT.)
Protected method | RemoveItem | Removes the element at the specified index of the underlying collection. (Overrides AdvisableCollectionTRemoveItem(Int32).)
Protected method | SetItem | Replaces the element at the specified index of the underlying collection. (Overrides AdvisableCollectionTSetItem(Int32, T).)
Public method | ToArray | Creates an array from the current AdvisableCollectionT. (Inherited from AdvisableCollectionT.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Protected property | Comparer | Gets the generic equality comparer that is used to determine equality of keys in the collection.
Public property | Count | Gets the number of elements contained in the ICollectionT. (Inherited from AdvisableCollectionT.)
Public property | IsReadOnly | Gets a value indicating whether the ICollectionT is read-only. (Inherited from AdvisableCollectionT.)
Public property | ItemInt32 | Gets or sets the element at the specified index. (Inherited from AdvisableCollectionT.)
Public property | ItemTKey | Gets or sets the element with the specified key.
Top
Events
 | Name | Description
Public event | CollectionChanged | Occurs when the collection changes. (Inherited from AdvisableCollectionT.)
Public event | PropertyChanged | Occurs when a property value changes. (Inherited from AdvisableCollectionT.)
Top
Remarks

The API of this class is compatible with the KeyedCollectionTKey, TItem class.

To learn how to extend this class, see the AdvisableCollectionT class documentation.

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem) Constructor

AdvisableKeyedCollectionTKey, TItem Constructor
Overload List
 | Name | Description
Protected method | AdvisableKeyedCollectionTKey, TItem | Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class that is empty and has the default initial capacity.
Protected method | AdvisableKeyedCollectionTKey, TItem(Int32) | Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class that is empty and has a specified initial capacity.
Protected method | AdvisableKeyedCollectionTKey, TItem(Int32, IEqualityComparerTKey) | Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class that has a specified initial capacity and a given equality comparer and uses the specified equality comparer.
Protected method | AdvisableKeyedCollectionTKey, TItem(SerializationInfo, StreamingContext) | Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class
Top
See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem) Constructor

AdvisableKeyedCollectionTKey, TItem Constructor
Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class that is empty and has the default initial capacity.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AdvisableKeyedCollection()
Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
AdvisableKeyedCollectionTKey, TItem Overload
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem) Constructor (Int32)

AdvisableKeyedCollectionTKey, TItem Constructor (Int32)
Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class that is empty and has a specified initial capacity.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AdvisableKeyedCollection(
    int capacity
)

Parameters

capacity
Type: SystemInt32
The number of elements the collection can contain before it must be resized.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
AdvisableKeyedCollectionTKey, TItem Overload
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem) Constructor (Int32, IEqualityComparer(TKey))

AdvisableKeyedCollectionTKey, TItem Constructor (Int32, IEqualityComparerTKey)
Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class that has a specified initial capacity and a given equality comparer and uses the specified equality comparer.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AdvisableKeyedCollection(
    int capacity,
    IEqualityComparer<TKey> comparer
)

Parameters

capacity
Type: SystemInt32
The number of elements the collection can contain before it must be resized.
comparer
Type: System.Collections.GenericIEqualityComparer TKey
The implementation of the IEqualityComparerT generic interface to use when comparing keys, or null to use the default equality comparer for the type of the key.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
AdvisableKeyedCollectionTKey, TItem Overload
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem) Constructor (SerializationInfo, StreamingContext)

AdvisableKeyedCollectionTKey, TItem Constructor (SerializationInfo, StreamingContext)
Initializes a new instance of the AdvisableKeyedCollectionTKey, TItem class

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AdvisableKeyedCollection(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
context
Type: System.Runtime.SerializationStreamingContext
Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
AdvisableKeyedCollectionTKey, TItem Overload
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem) Methods

AdvisableKeyedCollectionTKey, TItem Methods

The AdvisableKeyedCollectionTKey, TItem generic type exposes the following members.

Methods
 | Name | Description
Public method | Add | Adds an item to the ICollectionT. (Inherited from AdvisableCollectionT.)
Public method | Clear | Removes all items from the ICollectionT. (Inherited from AdvisableCollectionT.)
Protected method | ClearItems | Removes all elements from the underlying collection. (Overrides AdvisableCollectionTClearItems.)
Public method | Contains(T) | Determines whether the ICollectionT contains a specific value. (Inherited from AdvisableCollectionT.)
Public method | Contains(TKey) | Determines whether the collection contains an element with the specified key.
Public method | CopyTo | Copies the elements of the ICollectionT to an Array, starting at a particular Array index. (Inherited from AdvisableCollectionT.)
Protected method | GetCount | Gets the number of elements in the underlying collection. (Inherited from AdvisableCollectionT.)
Public method | GetEnumerator | Returns an enumerator that iterates through the AdvisableCollectionT. (Inherited from AdvisableCollectionT.)
Protected method | GetItem | Gets the element at the specified index of the underlying collection. (Inherited from AdvisableCollectionT.)
Protected method | GetKeyForItem | Extracts the key from the specified element.
Public method | GetObjectData | Populates a SerializationInfo with the data needed to serialize the target object. (Overrides AdvisableCollectionTGetObjectData(SerializationInfo, StreamingContext).)
Public method | IndexOf | Determines the index of a specific item in the IListT. (Inherited from AdvisableCollectionT.)
Protected method | IndexOfItem | Searches for the specified object and returns the zero-based index of the first occurrence within the entire underlying collection. (Overrides AdvisableCollectionTIndexOfItem(T).)
Public method | Insert | Inserts an item to the IListT at the specified index. (Inherited from AdvisableCollectionT.)
Protected method | InsertItem | Inserts an element into the underlying collection at the specified index. (Overrides AdvisableCollectionTInsertItem(Int32, T).)
Public method | Move | Moved the element at the specified index to another index. (Inherited from AdvisableCollectionT.)
Protected method | MoveItem | Moves the element at the specified index to another index in the underlying collection. (Overrides AdvisableCollectionTMoveItem(T, Int32, Int32).)
Public method | OnDeserialization | Runs when the entire object graph has been deserialized. (Inherited from AdvisableCollectionT.)
Protected method | RaiseEvents | Raised the events that have been buffered. (Inherited from AdvisableCollectionT.)
Public method | Remove | Removes the first occurrence of a specific object from the ICollectionT. (Inherited from AdvisableCollectionT.)
Public method | RemoveAt | Removes the IListT item at the specified index. (Inherited from AdvisableCollectionT.)
Protected method | RemoveItem | Removes the element at the specified index of the underlying collection. (Overrides AdvisableCollectionTRemoveItem(Int32).)
Protected method | SetItem | Replaces the element at the specified index of the underlying collection. (Overrides AdvisableCollectionTSetItem(Int32, T).)
Public method | ToArray | Creates an array from the current AdvisableCollectionT. (Inherited from AdvisableCollectionT.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).ClearItems Method

AdvisableKeyedCollectionTKey, TItemClearItems Method
Removes all elements from the underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override void ClearItems()
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).Contains Method

AdvisableKeyedCollectionTKey, TItemContains Method
Overload List
 | Name | Description
Public method | Contains(T) | Determines whether the ICollectionT contains a specific value. (Inherited from AdvisableCollectionT.)
Public method | Contains(TKey) | Determines whether the collection contains an element with the specified key.
Top
See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).Contains Method (TKey)

AdvisableKeyedCollectionTKey, TItemContains Method (TKey)
Determines whether the collection contains an element with the specified key.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Contains(
    TKey item
)

Parameters

item
Type: TKey
The key to locate in the collection.

Return Value

Type: Boolean
true if the collection contains an element with the specified key; otherwise, false.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
Contains Overload
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).GetKeyForItem Method

AdvisableKeyedCollectionTKey, TItemGetKeyForItem Method
Extracts the key from the specified element.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected abstract TKey GetKeyForItem(
    TItem item
)

Parameters

item
Type: TItem
The element from which to extract the key.

Return Value

Type: TKey
The key for the specified element.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).GetObjectData Method

AdvisableKeyedCollectionTKey, TItemGetObjectData Method
Populates a SerializationInfo with the data needed to serialize the target object.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void GetObjectData(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
The SerializationInfo to populate with data.
context
Type: System.Runtime.SerializationStreamingContext
The destination (see StreamingContext) for this serialization.

Implements

ISerializableGetObjectData(SerializationInfo, StreamingContext)
Exceptions
Exception | Condition
SecurityException | The caller does not have the required permission.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).IndexOfItem Method

AdvisableKeyedCollectionTKey, TItemIndexOfItem Method
Searches for the specified object and returns the zero-based index of the first occurrence within the entire underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override int IndexOfItem(
    TItem item
)

Parameters

item
Type: TItem
The object to locate in the AdvisableCollectionT. The value can be null for reference types.

Return Value

Type: Int32
The zero-based index of the first occurrence of item within the entire AdvisableCollectionT, if found; otherwise, -1.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).InsertItem Method

AdvisableKeyedCollectionTKey, TItemInsertItem Method
Inserts an element into the underlying collection at the specified index.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override void InsertItem(
    int index,
    TItem item
)

Parameters

index
Type: SystemInt32
The zero-based index at which index should be inserted.
item
Type: TItem
The object to insert. The value can be null for reference types.
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).MoveItem Method

AdvisableKeyedCollectionTKey, TItemMoveItem Method
Moves the element at the specified index to another index in the underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override void MoveItem(
    TItem item,
    int oldIndex,
    int newIndex
)

Parameters

item
Type: TItem
The element to be moved.
oldIndex
Type: SystemInt32
The old zero-based index of item in the collection.
newIndex
Type: SystemInt32
The new zero-based index of item in the collection.
Remarks

Some redundancy is created by requiring both item and oldIndex: this is intentional, for performance reasons.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).RemoveItem Method

AdvisableKeyedCollectionTKey, TItemRemoveItem Method
Removes the element at the specified index of the underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override void RemoveItem(
    int index
)

Parameters

index
Type: SystemInt32
The zero-based index of the element to remove.
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).SetItem Method

AdvisableKeyedCollectionTKey, TItemSetItem Method
Replaces the element at the specified index of the underlying collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override void SetItem(
    int index,
    TItem item
)

Parameters

index
Type: SystemInt32
The zero-based index of the element to replace.
item
Type: TItem
The new value for the element at the specified index. The value can be null for reference types.
Remarks

Note Note
This method does not cause the advices to be executed. It should be invoked only from inside the scope of the ExecuteWithAdvices``1(ObjectAccessLevel, FuncUMP) method.

Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem) Properties

AdvisableKeyedCollectionTKey, TItem Properties

The AdvisableKeyedCollectionTKey, TItem generic type exposes the following members.

Properties
 | Name | Description
Protected property | Comparer | Gets the generic equality comparer that is used to determine equality of keys in the collection.
Public property | Count | Gets the number of elements contained in the ICollectionT. (Inherited from AdvisableCollectionT.)
Public property | IsReadOnly | Gets a value indicating whether the ICollectionT is read-only. (Inherited from AdvisableCollectionT.)
Public property | ItemInt32 | Gets or sets the element at the specified index. (Inherited from AdvisableCollectionT.)
Public property | ItemTKey | Gets or sets the element with the specified key.
Top
See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).Comparer Property

AdvisableKeyedCollectionTKey, TItemComparer Property
Gets the generic equality comparer that is used to determine equality of keys in the collection.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected IEqualityComparer<TKey> Comparer { get; }

Property Value

Type: IEqualityComparer TKey
Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).Item Property

AdvisableKeyedCollectionTKey, TItemItem Property
Overload List
 | Name | Description
Public property | ItemInt32 | Gets or sets the element at the specified index. (Inherited from AdvisableCollectionT.)
Public property | ItemTKey | Gets or sets the element with the specified key.
Top
See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem).Item Property (TKey)

AdvisableKeyedCollectionTKey, TItemItem Property (TKey)
Gets or sets the element with the specified key.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public TItem this[
    TKey key
] { get; set; }

Parameters

key
Type: TKey
The key of the element.

Return Value

Type: TItem
The element whose key is key.
Remarks
When setting this property, the key of the new value should be identical to the value of the key parameter.
Version Information

Supported in: 4.1

See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
Item Overload
PostSharp.Patterns.Collections Namespace


AdvisableKeyedCollection(TKey, TItem) Events

AdvisableKeyedCollectionTKey, TItem Events

The AdvisableKeyedCollectionTKey, TItem generic type exposes the following members.

Events
 | Name | Description
Public event | CollectionChanged | Occurs when the collection changes. (Inherited from AdvisableCollectionT.)
Public event | PropertyChanged | Occurs when a property value changes. (Inherited from AdvisableCollectionT.)
Top
See Also

Reference

AdvisableKeyedCollectionTKey, TItem Class
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T) Structure

ReadOnlyArrayT Structure
Read-only array wrapper.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public struct ReadOnlyArray<T> : IEquatable<ReadOnlyArray<T>>

Type Parameters

T
Type of array items.

The ReadOnlyArrayT type exposes the following members.

Constructors
 | Name | Description
Public method | ReadOnlyArrayT | Initializes a new ReadOnlyArrayT.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(ReadOnlyArrayT) | Indicates whether the current object is equal to another object of the same type.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Top
Operators
Name | Description
Equality | Determines whether two instances of the ReadOnlyArrayT type are equal.
Inequality | Determines whether two instances of the ReadOnlyArrayT type are different.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsNull | Determines whether the array is null.
Public property | Item | Gets a specified element of the array.
Public property | Length | Gets the array length.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T) Constructor

ReadOnlyArrayT Constructor
Initializes a new ReadOnlyArrayT.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ReadOnlyArray(
    T[] array
)

Parameters

array
Type: T
An array, or null.
Version Information

Supported in: 4.1

See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T) Methods

ReadOnlyArrayT Methods

The ReadOnlyArrayT generic type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(ReadOnlyArrayT) | Indicates whether the current object is equal to another object of the same type.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T).Equals Method

ReadOnlyArrayTEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(ReadOnlyArrayT) | Indicates whether the current object is equal to another object of the same type.
Top
See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T).Equals Method (Object)

ReadOnlyArrayTEquals Method (Object)
Indicates whether this instance and a specified object are equal.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool Equals(
    Object obj
)

Parameters

obj
Type: SystemObject
Another object to compare to.

Return Value

Type: Boolean
true if obj and this instance are the same type and represent the same value; otherwise, false.
Version Information

Supported in: 4.1

See Also

Reference

ReadOnlyArrayT Structure
Equals Overload
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T).Equals Method (ReadOnlyArray(T))

ReadOnlyArrayTEquals Method (ReadOnlyArrayT)
Indicates whether the current object is equal to another object of the same type.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Equals(
    ReadOnlyArray<T> other
)

Parameters

other
Type: PostSharp.Patterns.CollectionsReadOnlyArray T
An object to compare with this object.

Return Value

Type: Boolean
true if the current object is equal to the other parameter; otherwise, false.

Implements

IEquatableTEquals(T)
Version Information

Supported in: 4.1

See Also

Reference

ReadOnlyArrayT Structure
Equals Overload
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T).GetHashCode Method

ReadOnlyArrayTGetHashCode Method
Returns the hash code for this instance.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int GetHashCode()

Return Value

Type: Int32
A 32-bit signed integer that is the hash code for this instance.
Version Information

Supported in: 4.1

See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T) Operators

ReadOnlyArrayT Operators

The ReadOnlyArrayT generic type exposes the following members.

Operators
Name | Description
Equality | Determines whether two instances of the ReadOnlyArrayT type are equal.
Inequality | Determines whether two instances of the ReadOnlyArrayT type are different.
Top
See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T).Equality Operator

ReadOnlyArrayTEquality Operator
Determines whether two instances of the ReadOnlyArrayT type are equal.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator ==(
    ReadOnlyArray<T> left,
    ReadOnlyArray<T> right
)

Parameters

left
Type: PostSharp.Patterns.CollectionsReadOnlyArray T
right
Type: PostSharp.Patterns.CollectionsReadOnlyArray T

Return Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T).Inequality Operator

ReadOnlyArrayTInequality Operator
Determines whether two instances of the ReadOnlyArrayT type are different.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator !=(
    ReadOnlyArray<T> left,
    ReadOnlyArray<T> right
)

Parameters

left
Type: PostSharp.Patterns.CollectionsReadOnlyArray T
right
Type: PostSharp.Patterns.CollectionsReadOnlyArray T

Return Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T) Properties

ReadOnlyArrayT Properties

The ReadOnlyArrayT generic type exposes the following members.

Properties
 | Name | Description
Public property | IsNull | Determines whether the array is null.
Public property | Item | Gets a specified element of the array.
Public property | Length | Gets the array length.
Top
See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T).IsNull Property

ReadOnlyArrayTIsNull Property
Determines whether the array is null.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsNull { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T).Item Property

ReadOnlyArrayTItem Property
Gets a specified element of the array.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public T this[
    int index
] { get; }

Parameters

index
Type: SystemInt32
The element position.

Return Value

Type: T
The element at position index.
Version Information

Supported in: 4.1

See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


ReadOnlyArray(T).Length Property

ReadOnlyArrayTLength Property
Gets the array length.

Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int Length { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1

See Also

Reference

ReadOnlyArrayT Structure
PostSharp.Patterns.Collections Namespace


PostSharp.Patterns.Contracts Namespace

PostSharp.Patterns.Contracts Namespace
The PostSharp.Patterns.Contracts namespace contains ready-made contracts that validate fields, properties and parameters at runtime.
Classes
 | Class | Description
Public class | ContractLocalizedTextProvider | Base class for contract error messages providers.
Public class | 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.
Public class | 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.
Public class | 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.
Public class | 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 or equal to a given value.
Public class | 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 or equal to a given value.
Public class | LocationContractAttribute | Base class for other custom attributes in this namespace.
Public class | 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 character) or ICollection (where empty means zero item).
Public class | NotNullAttribute | Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null value.
Public class | 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.
Public class | PositiveAttribute | Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that smaller than zero.
Public class | 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.
Public class | 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.
Public class | RequiredAttribute | Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null value or an empty or white-space string.
Public class | StrictlyGreaterThanAttribute | Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is strictly smaller than a given value.
Public class | StrictlyPositiveAttribute | Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that smaller than zero.
Public class | 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.
Public class | 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.


ContractLocalizedTextProvider Class

ContractLocalizedTextProvider Class
Base class for contract error messages providers.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.UtilitiesLocalizedTextProvider
PostSharp.Patterns.ContractsContractLocalizedTextProvider

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ContractLocalizedTextProvider : LocalizedTextProvider

The ContractLocalizedTextProvider type exposes the following members.

Methods
 | Name | Description
Public method | FormatString | Formats a string. An implementation would typically invoke Format(String, Object). (Inherited from LocalizedTextProvider.)
Public method | GetMessage | (Overrides LocalizedTextProviderGetMessage(String).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
CreditCardErrorMessage | Identifier of the error message shown when CreditCardAttribute constraint is violated.
EmailAddressErrorMessage | Identifier of the error message shown when EmailAddressAttribute constraint is violated.
EnumDataTypeErrorMessage | Identifier of the error message shown when EnumDataTypeAttribute constraint is violated.
GreaterThanErrorMessage | Identifier of the error message shown when GreaterThanAttribute constraint is violated.
LessThanErrorMessage | Identifier of the error message shown when LessThanAttribute constraint is violated.
LocationContractErrorMessage | Identifier of the error message shown when LocationContractAttribute constraint is violated.
NotEmptyErrorMessage | Identifier of the error message shown when NotEmptyAttribute constraint is violated.
NotNullErrorMessage | Identifier of the error message shown when NotNullAttribute constraint is violated.
PhoneErrorMessage | Identifier of the error message shown when PhoneAttribute constraint is violated.
RangeErrorMessage | Identifier of the error message shown when RangeAttribute constraint is violated.
RegularExpressionErrorMessage | Identifier of the error message shown when RegularExpressionAttribute constraint is violated.
RequiredErrorMessage | Identifier of the error message shown when RequiredAttribute constraint is violated.
StrictlyGreaterThanErrorMessage | Identifier of the error message shown when StrictlyGreaterThanAttribute constraint is violated.
StringLengthMaxErrorMessage | Identifier of the error message shown when StringLengthAttribute constraint is violated (only maximum length was specified).
StringLengthMinErrorMessage | Identifier of the error message shown when StringLengthAttribute constraint is violated (only minimum length was specified).
StringLengthRangeErrorMessage | Identifier of the error message shown when StringLengthAttribute constraint is violated (both minimum and maximum was specified).
UrlErrorMessage | Identifier of the error message shown when UrlAttribute constraint is violated.
Top
Properties
Name | Description
Current | Current instance of ContractLocalizedTextProvider.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider Fields

ContractLocalizedTextProvider Fields

The ContractLocalizedTextProvider type exposes the following members.

Fields
Name | Description
CreditCardErrorMessage | Identifier of the error message shown when CreditCardAttribute constraint is violated.
EmailAddressErrorMessage | Identifier of the error message shown when EmailAddressAttribute constraint is violated.
EnumDataTypeErrorMessage | Identifier of the error message shown when EnumDataTypeAttribute constraint is violated.
GreaterThanErrorMessage | Identifier of the error message shown when GreaterThanAttribute constraint is violated.
LessThanErrorMessage | Identifier of the error message shown when LessThanAttribute constraint is violated.
LocationContractErrorMessage | Identifier of the error message shown when LocationContractAttribute constraint is violated.
NotEmptyErrorMessage | Identifier of the error message shown when NotEmptyAttribute constraint is violated.
NotNullErrorMessage | Identifier of the error message shown when NotNullAttribute constraint is violated.
PhoneErrorMessage | Identifier of the error message shown when PhoneAttribute constraint is violated.
RangeErrorMessage | Identifier of the error message shown when RangeAttribute constraint is violated.
RegularExpressionErrorMessage | Identifier of the error message shown when RegularExpressionAttribute constraint is violated.
RequiredErrorMessage | Identifier of the error message shown when RequiredAttribute constraint is violated.
StrictlyGreaterThanErrorMessage | Identifier of the error message shown when StrictlyGreaterThanAttribute constraint is violated.
StringLengthMaxErrorMessage | Identifier of the error message shown when StringLengthAttribute constraint is violated (only maximum length was specified).
StringLengthMinErrorMessage | Identifier of the error message shown when StringLengthAttribute constraint is violated (only minimum length was specified).
StringLengthRangeErrorMessage | Identifier of the error message shown when StringLengthAttribute constraint is violated (both minimum and maximum was specified).
UrlErrorMessage | Identifier of the error message shown when UrlAttribute constraint is violated.
Top
See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.CreditCardErrorMessage Field

ContractLocalizedTextProviderCreditCardErrorMessage Field
Identifier of the error message shown when CreditCardAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string CreditCardErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.EmailAddressErrorMessage Field

ContractLocalizedTextProviderEmailAddressErrorMessage Field
Identifier of the error message shown when EmailAddressAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string EmailAddressErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.EnumDataTypeErrorMessage Field

ContractLocalizedTextProviderEnumDataTypeErrorMessage Field
Identifier of the error message shown when EnumDataTypeAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string EnumDataTypeErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.GreaterThanErrorMessage Field

ContractLocalizedTextProviderGreaterThanErrorMessage Field
Identifier of the error message shown when GreaterThanAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string GreaterThanErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.LessThanErrorMessage Field

ContractLocalizedTextProviderLessThanErrorMessage Field
Identifier of the error message shown when LessThanAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string LessThanErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.LocationContractErrorMessage Field

ContractLocalizedTextProviderLocationContractErrorMessage Field
Identifier of the error message shown when LocationContractAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string LocationContractErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.NotEmptyErrorMessage Field

ContractLocalizedTextProviderNotEmptyErrorMessage Field
Identifier of the error message shown when NotEmptyAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string NotEmptyErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.NotNullErrorMessage Field

ContractLocalizedTextProviderNotNullErrorMessage Field
Identifier of the error message shown when NotNullAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string NotNullErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.PhoneErrorMessage Field

ContractLocalizedTextProviderPhoneErrorMessage Field
Identifier of the error message shown when PhoneAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string PhoneErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.RangeErrorMessage Field

ContractLocalizedTextProviderRangeErrorMessage Field
Identifier of the error message shown when RangeAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string RangeErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.RegularExpressionErrorMessage Field

ContractLocalizedTextProviderRegularExpressionErrorMessage Field
Identifier of the error message shown when RegularExpressionAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string RegularExpressionErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.RequiredErrorMessage Field

ContractLocalizedTextProviderRequiredErrorMessage Field
Identifier of the error message shown when RequiredAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string RequiredErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.StrictlyGreaterThanErrorMessage Field

ContractLocalizedTextProviderStrictlyGreaterThanErrorMessage Field
Identifier of the error message shown when StrictlyGreaterThanAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string StrictlyGreaterThanErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.StringLengthMaxErrorMessage Field

ContractLocalizedTextProviderStringLengthMaxErrorMessage Field
Identifier of the error message shown when StringLengthAttribute constraint is violated (only maximum length was specified).

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string StringLengthMaxErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.StringLengthMinErrorMessage Field

ContractLocalizedTextProviderStringLengthMinErrorMessage Field
Identifier of the error message shown when StringLengthAttribute constraint is violated (only minimum length was specified).

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string StringLengthMinErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.StringLengthRangeErrorMessage Field

ContractLocalizedTextProviderStringLengthRangeErrorMessage Field
Identifier of the error message shown when StringLengthAttribute constraint is violated (both minimum and maximum was specified).

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string StringLengthRangeErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.UrlErrorMessage Field

ContractLocalizedTextProviderUrlErrorMessage Field
Identifier of the error message shown when UrlAttribute constraint is violated.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string UrlErrorMessage

Field Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider Methods

ContractLocalizedTextProvider Methods

The ContractLocalizedTextProvider type exposes the following members.

Methods
 | Name | Description
Public method | FormatString | Formats a string. An implementation would typically invoke Format(String, Object). (Inherited from LocalizedTextProvider.)
Public method | GetMessage | (Overrides LocalizedTextProviderGetMessage(String).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.GetMessage Method

ContractLocalizedTextProviderGetMessage Method

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override string GetMessage(
    string messageId
)

Parameters

messageId
Type: SystemString

Return Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider Properties

ContractLocalizedTextProvider Properties

The ContractLocalizedTextProvider type exposes the following members.

Properties
Name | Description
Current | Current instance of ContractLocalizedTextProvider.
Top
See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


ContractLocalizedTextProvider.Current Property

ContractLocalizedTextProviderCurrent Property
Current instance of ContractLocalizedTextProvider.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static ContractLocalizedTextProvider Current { get; set; }

Property Value

Type: ContractLocalizedTextProvider
Version Information

Supported in: 4.1

See Also

Reference

ContractLocalizedTextProvider Class
PostSharp.Patterns.Contracts Namespace


CreditCardAttribute Class

CreditCardAttribute Class
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.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsCreditCardAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class CreditCardAttribute : LocationContractAttribute,
    ILocationValidationAspect<string>, ILocationValidationAspect, IAspect

The CreditCardAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | CreditCardAttribute | Initializes a new CreditCardAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Error message is identified by CreditCardErrorMessage.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


CreditCardAttribute Constructor

CreditCardAttribute Constructor
Initializes a new CreditCardAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public CreditCardAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CreditCardAttribute Class
PostSharp.Patterns.Contracts Namespace


CreditCardAttribute Methods

CreditCardAttribute Methods

The CreditCardAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CreditCardAttribute Class
PostSharp.Patterns.Contracts Namespace


CreditCardAttribute Properties

CreditCardAttribute Properties

The CreditCardAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

CreditCardAttribute Class
PostSharp.Patterns.Contracts Namespace


EmailAddressAttribute Class

EmailAddressAttribute Class
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.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRegularExpressionAttribute
PostSharp.Patterns.ContractsEmailAddressAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class EmailAddressAttribute : RegularExpressionAttribute

The EmailAddressAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | EmailAddressAttribute | Initializes a new EmailAddressAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Error message is identified by EmailAddressErrorMessage.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


EmailAddressAttribute Constructor

EmailAddressAttribute Constructor
Initializes a new EmailAddressAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EmailAddressAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EmailAddressAttribute Class
PostSharp.Patterns.Contracts Namespace


EmailAddressAttribute Methods

EmailAddressAttribute Methods

The EmailAddressAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EmailAddressAttribute Class
PostSharp.Patterns.Contracts Namespace


EmailAddressAttribute Properties

EmailAddressAttribute Properties

The EmailAddressAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

EmailAddressAttribute Class
PostSharp.Patterns.Contracts Namespace


EnumDataTypeAttribute Class

EnumDataTypeAttribute Class
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.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsEnumDataTypeAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class EnumDataTypeAttribute : LocationContractAttribute,
    ILocationValidationAspect<string>, ILocationValidationAspect<Object>, ILocationValidationAspect<Nullable<long>>,
    ILocationValidationAspect<Nullable<ulong>>, ILocationValidationAspect<Nullable<int>>,
    ILocationValidationAspect<Nullable<uint>>, ILocationValidationAspect<Nullable<short>>,
    ILocationValidationAspect<Nullable<byte>>, ILocationValidationAspect<Nullable<sbyte>>,
    ILocationValidationAspect<Nullable<ushort>>, ILocationValidationAspect<long>,
    ILocationValidationAspect<ulong>, ILocationValidationAspect<int>, ILocationValidationAspect<uint>,
    ILocationValidationAspect<short>, ILocationValidationAspect<byte>, ILocationValidationAspect<sbyte>,
    ILocationValidationAspect<ushort>, ILocationValidationAspect, IAspect

The EnumDataTypeAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | EnumDataTypeAttribute | Initializes a new EnumDataTypeAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | EnumType | Gets the enumeration type.
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Strings are matched against enumeration member names. Integers are matched against enumeration member values. Null values are accepted and do not throw exception.

Error message is identified by EnumDataTypeErrorMessage.

Error message can use additional argument

Field Value

Type:
{4} to refer to EnumType name.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


EnumDataTypeAttribute Constructor

EnumDataTypeAttribute Constructor
Initializes a new EnumDataTypeAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EnumDataTypeAttribute(
    Type enumType
)

Parameters

enumType
Type: SystemType
Enumeration type.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EnumDataTypeAttribute Class
PostSharp.Patterns.Contracts Namespace


EnumDataTypeAttribute Methods

EnumDataTypeAttribute Methods

The EnumDataTypeAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EnumDataTypeAttribute Class
PostSharp.Patterns.Contracts Namespace


EnumDataTypeAttribute Properties

EnumDataTypeAttribute Properties

The EnumDataTypeAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | EnumType | Gets the enumeration type.
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

EnumDataTypeAttribute Class
PostSharp.Patterns.Contracts Namespace


EnumDataTypeAttribute.EnumType Property

EnumDataTypeAttributeEnumType Property
Gets the enumeration type.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type EnumType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

EnumDataTypeAttribute Class
PostSharp.Patterns.Contracts Namespace


GreaterThanAttribute Class

GreaterThanAttribute Class
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is smaller or equal to a given value.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRangeAttribute
PostSharp.Patterns.ContractsGreaterThanAttribute
PostSharp.Patterns.ContractsPositiveAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class GreaterThanAttribute : RangeAttribute

The GreaterThanAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | GreaterThanAttribute(Double) | Initializes a new GreaterThanAttribute and specify a floating-point bound.
Public method | GreaterThanAttribute(Int64) | Initializes a new GreaterThanAttribute and specify an integer bound.
Public method | GreaterThanAttribute(UInt64) | Initializes a new GreaterThanAttribute and specify a UInt64 bound.
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from RangeAttribute.)
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Overrides RangeAttributeGetErrorMessage.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Overrides RangeAttributeGetErrorMessageArguments.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
 | Name | Description
Protected field | displayMax | (Inherited from RangeAttribute.)
Protected field | displayMin | (Inherited from RangeAttribute.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Null values are accepted and do not throw an exception.

Error message is identified by GreaterThanErrorMessage.

Error message can use additional argument

Field Value

Type:
{4} to refer to the minimum value used.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


GreaterThanAttribute Constructor

GreaterThanAttribute Constructor
Overload List
 | Name | Description
Public method | GreaterThanAttribute(Double) | Initializes a new GreaterThanAttribute and specify a floating-point bound.
Public method | GreaterThanAttribute(Int64) | Initializes a new GreaterThanAttribute and specify an integer bound.
Public method | GreaterThanAttribute(UInt64) | Initializes a new GreaterThanAttribute and specify a UInt64 bound.
Top
See Also

Reference

GreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


GreaterThanAttribute Constructor (Double)

GreaterThanAttribute Constructor (Double)
Initializes a new GreaterThanAttribute and specify a floating-point bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public GreaterThanAttribute(
    double min
)

Parameters

min
Type: SystemDouble
The lower bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

GreaterThanAttribute Class
GreaterThanAttribute Overload
PostSharp.Patterns.Contracts Namespace


GreaterThanAttribute Constructor (Int64)

GreaterThanAttribute Constructor (Int64)
Initializes a new GreaterThanAttribute and specify an integer bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public GreaterThanAttribute(
    long min
)

Parameters

min
Type: SystemInt64
The lower bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

GreaterThanAttribute Class
GreaterThanAttribute Overload
PostSharp.Patterns.Contracts Namespace


GreaterThanAttribute Constructor (UInt64)

GreaterThanAttribute Constructor (UInt64)
Initializes a new GreaterThanAttribute and specify a UInt64 bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public GreaterThanAttribute(
    ulong min
)

Parameters

min
Type: SystemUInt64
The lower bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

GreaterThanAttribute Class
GreaterThanAttribute Overload
PostSharp.Patterns.Contracts Namespace


GreaterThanAttribute Fields

GreaterThanAttribute Fields

The GreaterThanAttribute type exposes the following members.

Fields
 | Name | Description
Protected field | displayMax | (Inherited from RangeAttribute.)
Protected field | displayMin | (Inherited from RangeAttribute.)
Top
See Also

Reference

GreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


GreaterThanAttribute Methods

GreaterThanAttribute Methods

The GreaterThanAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from RangeAttribute.)
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Overrides RangeAttributeGetErrorMessage.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Overrides RangeAttributeGetErrorMessageArguments.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

GreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


GreaterThanAttribute.GetErrorMessage Method

GreaterThanAttributeGetErrorMessage Method
Gets unformatted error message as defined by the instance.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override string GetErrorMessage()

Return Value

Type: String
Remarks

See remarks on LocationContractAttribute for information about message parameters.

Use of this method can be overridden by setting ErrorMessage property to non-null value.

Version Information

Supported in: 4.1

See Also

Reference

GreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


GreaterThanAttribute.GetErrorMessageArguments Method

GreaterThanAttributeGetErrorMessageArguments Method
Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override Object[] GetErrorMessageArguments()

Return Value

Type: Object
object of additional argument values.
Remarks
This method is expected to be pure, i.e. it's result can be cached and so the implementer should not return information that may change after constructor of the class has finished.
Version Information

Supported in: 4.1

See Also

Reference

GreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


GreaterThanAttribute Properties

GreaterThanAttribute Properties

The GreaterThanAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

GreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


LessThanAttribute Class

LessThanAttribute Class
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is greater or equal to a given value.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRangeAttribute
PostSharp.Patterns.ContractsLessThanAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class LessThanAttribute : RangeAttribute

The LessThanAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | LessThanAttribute(Double) | Initializes a new GreaterThanAttribute and specify a floating-point bound.
Public method | LessThanAttribute(Int64) | Initializes a new GreaterThanAttribute and specify an integer bound.
Public method | LessThanAttribute(UInt64) | Initializes a new GreaterThanAttribute and specify a UInt64 bound.
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from RangeAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Null values are accepted and do not throw an exception.

Error message is identified by LessThanErrorMessage.

Error message can use additional argument

Field Value

Type:
{4} to refer to the minimum value used.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


LessThanAttribute Constructor

LessThanAttribute Constructor
Overload List
 | Name | Description
Public method | LessThanAttribute(Double) | Initializes a new GreaterThanAttribute and specify a floating-point bound.
Public method | LessThanAttribute(Int64) | Initializes a new GreaterThanAttribute and specify an integer bound.
Public method | LessThanAttribute(UInt64) | Initializes a new GreaterThanAttribute and specify a UInt64 bound.
Top
See Also

Reference

LessThanAttribute Class
PostSharp.Patterns.Contracts Namespace


LessThanAttribute Constructor (Double)

LessThanAttribute Constructor (Double)
Initializes a new GreaterThanAttribute and specify a floating-point bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LessThanAttribute(
    double max
)

Parameters

max
Type: SystemDouble
The upper bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LessThanAttribute Class
LessThanAttribute Overload
PostSharp.Patterns.Contracts Namespace


LessThanAttribute Constructor (Int64)

LessThanAttribute Constructor (Int64)
Initializes a new GreaterThanAttribute and specify an integer bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LessThanAttribute(
    long max
)

Parameters

max
Type: SystemInt64
The upper bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LessThanAttribute Class
LessThanAttribute Overload
PostSharp.Patterns.Contracts Namespace


LessThanAttribute Constructor (UInt64)

LessThanAttribute Constructor (UInt64)
Initializes a new GreaterThanAttribute and specify a UInt64 bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LessThanAttribute(
    ulong max
)

Parameters

max
Type: SystemUInt64
The upper bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LessThanAttribute Class
LessThanAttribute Overload
PostSharp.Patterns.Contracts Namespace


LessThanAttribute Methods

LessThanAttribute Methods

The LessThanAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from RangeAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LessThanAttribute Class
PostSharp.Patterns.Contracts Namespace


LessThanAttribute Properties

LessThanAttribute Properties

The LessThanAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

LessThanAttribute Class
PostSharp.Patterns.Contracts Namespace


LocationContractAttribute Class

LocationContractAttribute Class
Base class for other custom attributes in this namespace.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
More...

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class LocationContractAttribute : MulticastAttribute

The LocationContractAttribute type exposes the following members.

Constructors
 | Name | Description
Protected method | LocationContractAttribute | Initializes a new LocationContractAttribute.
Top
Methods
 | Name | Description
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values.
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values.
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values.
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values.
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance.
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string.
Top
Remarks

Basic error message is identified by LocationContractErrorMessage and obtained from the provider set in Current.

All formatting string are have following parameters replaced:

  • Field Value

    Type:
    {0} represents location name.

  • Field Value

    Type:
    {1} represents location kind.

  • Field Value

    Type:
    {2} represents string containing both location kind and name.

  • Field Value

    Type:
    {3} represents value which caused the error when being assigned to the location.
  • Further parameters are described in remarks sections of appropriate contracts which override the GetErrorMessageArguments method.

Note that an array of error message arguments are cached for each location.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsCreditCardAttribute
PostSharp.Patterns.ContractsEnumDataTypeAttribute
PostSharp.Patterns.ContractsNotEmptyAttribute
PostSharp.Patterns.ContractsNotNullAttribute
PostSharp.Patterns.ContractsRangeAttribute
PostSharp.Patterns.ContractsRegularExpressionAttribute
PostSharp.Patterns.ContractsRequiredAttribute
PostSharp.Patterns.ContractsStringLengthAttribute


LocationContractAttribute Constructor

LocationContractAttribute Constructor
Initializes a new LocationContractAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected LocationContractAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationContractAttribute Class
PostSharp.Patterns.Contracts Namespace


LocationContractAttribute Methods

LocationContractAttribute Methods

The LocationContractAttribute type exposes the following members.

Methods
 | Name | Description
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values.
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values.
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values.
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values.
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance.
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LocationContractAttribute Class
PostSharp.Patterns.Contracts Namespace


LocationContractAttribute.CreateArgumentException Method

LocationContractAttributeCreateArgumentException Method
Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected ArgumentException CreateArgumentException(
    Object value,
    string locationName,
    LocationKind locationKind
)

Parameters

value
Type: SystemObject
Value assigned to the property.
locationName
Type: SystemString
Name of the location.
locationKind
Type: PostSharp.ReflectionLocationKind
Location kind.

Return Value

Type: ArgumentException
A new ArgumentException where the message, has been derived from ErrorMessage, with placeholders replaced by their concrete value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationContractAttribute Class
PostSharp.Patterns.Contracts Namespace


LocationContractAttribute.CreateArgumentNullException Method

LocationContractAttributeCreateArgumentNullException Method
Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected ArgumentNullException CreateArgumentNullException(
    Object value,
    string locationName,
    LocationKind locationKind
)

Parameters

value
Type: SystemObject
Value assigned to the property.
locationName
Type: SystemString
Name of the location.
locationKind
Type: PostSharp.ReflectionLocationKind
Location kind.

Return Value

Type: ArgumentNullException
A new ArgumentNullException where the message, has been derived from ErrorMessage, with placeholders replaced by their concrete value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationContractAttribute Class
PostSharp.Patterns.Contracts Namespace


LocationContractAttribute.CreateArgumentOutOfRangeException Method

LocationContractAttributeCreateArgumentOutOfRangeException Method
Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected ArgumentOutOfRangeException CreateArgumentOutOfRangeException(
    Object value,
    string locationName,
    LocationKind locationKind
)

Parameters

value
Type: SystemObject
Value assigned to the property.
locationName
Type: SystemString
Name of the location.
locationKind
Type: PostSharp.ReflectionLocationKind
Location kind.

Return Value

Type: ArgumentOutOfRangeException
A new ArgumentOutOfRangeException where the message, has been derived from ErrorMessage, with placeholders replaced by their concrete value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationContractAttribute Class
PostSharp.Patterns.Contracts Namespace


LocationContractAttribute.FormatErrorMessage Method

LocationContractAttributeFormatErrorMessage Method
Formats the ErrorMessage with concrete values.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected string FormatErrorMessage(
    Object value,
    string locationName,
    LocationKind locationKind
)

Parameters

value
Type: SystemObject
Value assigned to the property.
locationName
Type: SystemString
Name of the location.
locationKind
Type: PostSharp.ReflectionLocationKind
Location kind.

Return Value

Type: String
A string derived from ErrorMessage, where placeholders have been replaced by their concrete value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationContractAttribute Class
PostSharp.Patterns.Contracts Namespace


LocationContractAttribute.GetErrorMessage Method

LocationContractAttributeGetErrorMessage Method
Gets unformatted error message as defined by the instance.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual string GetErrorMessage()

Return Value

Type: String
Remarks

See remarks on LocationContractAttribute for information about message parameters.

Use of this method can be overridden by setting ErrorMessage property to non-null value.

Version Information

Supported in: 4.1

See Also

Reference

LocationContractAttribute Class
PostSharp.Patterns.Contracts Namespace


LocationContractAttribute.GetErrorMessageArguments Method

LocationContractAttributeGetErrorMessageArguments Method
Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual Object[] GetErrorMessageArguments()

Return Value

Type: Object
object of additional argument values.
Remarks
This method is expected to be pure, i.e. it's result can be cached and so the implementer should not return information that may change after constructor of the class has finished.
Version Information

Supported in: 4.1

See Also

Reference

LocationContractAttribute Class
PostSharp.Patterns.Contracts Namespace


LocationContractAttribute Properties

LocationContractAttribute Properties

The LocationContractAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string.
Top
See Also

Reference

LocationContractAttribute Class
PostSharp.Patterns.Contracts Namespace


LocationContractAttribute.ErrorMessage Property

LocationContractAttributeErrorMessage Property
Gets or sets the error message formatting string.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string ErrorMessage { get; set; }

Property Value

Type: String
Remarks

See remarks on LocationContractAttribute for information about message parameters.

If the value of this property is set to

Property Value

Type: String
null, GetErrorMessage will be used to obtain the error message.

Set this property only for legacy purposes. Otherwise, use GetErrorMessage method.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationContractAttribute Class
PostSharp.Patterns.Contracts Namespace


NotEmptyAttribute Class

NotEmptyAttribute Class
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 character) or ICollection (where empty means zero item).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsNotEmptyAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class NotEmptyAttribute : LocationContractAttribute,
    ILocationValidationAspect<string>, ILocationValidationAspect<ICollection>, ILocationValidationAspect,
    IAspect

The NotEmptyAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | NotEmptyAttribute | Initializes a new NotEmptyAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Error message is identified by NotEmptyErrorMessage.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


NotEmptyAttribute Constructor

NotEmptyAttribute Constructor
Initializes a new NotEmptyAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public NotEmptyAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotEmptyAttribute Class
PostSharp.Patterns.Contracts Namespace


NotEmptyAttribute Methods

NotEmptyAttribute Methods

The NotEmptyAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

NotEmptyAttribute Class
PostSharp.Patterns.Contracts Namespace


NotEmptyAttribute Properties

NotEmptyAttribute Properties

The NotEmptyAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

NotEmptyAttribute Class
PostSharp.Patterns.Contracts Namespace


NotNullAttribute Class

NotNullAttribute Class
Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null value.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsNotNullAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class NotNullAttribute : LocationContractAttribute,
    ILocationValidationAspect<Object>, ILocationValidationAspect, IAspect

The NotNullAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | NotNullAttribute | Initializes a new ArgumentNullException.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Error message is identified by NotNullErrorMessage.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


NotNullAttribute Constructor

NotNullAttribute Constructor
Initializes a new ArgumentNullException.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public NotNullAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotNullAttribute Class
PostSharp.Patterns.Contracts Namespace


NotNullAttribute Methods

NotNullAttribute Methods

The NotNullAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

NotNullAttribute Class
PostSharp.Patterns.Contracts Namespace


NotNullAttribute Properties

NotNullAttribute Properties

The NotNullAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

NotNullAttribute Class
PostSharp.Patterns.Contracts Namespace


PhoneAttribute Class

PhoneAttribute Class
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.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRegularExpressionAttribute
PostSharp.Patterns.ContractsPhoneAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class PhoneAttribute : RegularExpressionAttribute

The PhoneAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | PhoneAttribute | Initializes a new PhoneAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Error message is identified by [!:ContractLocalizedTextProvider.PhoneAttribute].

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


PhoneAttribute Constructor

PhoneAttribute Constructor
Initializes a new PhoneAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PhoneAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PhoneAttribute Class
PostSharp.Patterns.Contracts Namespace


PhoneAttribute Methods

PhoneAttribute Methods

The PhoneAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PhoneAttribute Class
PostSharp.Patterns.Contracts Namespace


PhoneAttribute Properties

PhoneAttribute Properties

The PhoneAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

PhoneAttribute Class
PostSharp.Patterns.Contracts Namespace


PositiveAttribute Class

PositiveAttribute Class
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that smaller than zero.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRangeAttribute
PostSharp.Patterns.ContractsGreaterThanAttribute
PostSharp.Patterns.ContractsPositiveAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class PositiveAttribute : GreaterThanAttribute

The PositiveAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | PositiveAttribute | Initializes a new PositiveAttribute.
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from RangeAttribute.)
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Inherited from GreaterThanAttribute.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Inherited from GreaterThanAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
 | Name | Description
Protected field | displayMax | (Inherited from RangeAttribute.)
Protected field | displayMin | (Inherited from RangeAttribute.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Null values are accepted and do not throw an exception.

Error message is identified by GreaterThanErrorMessage.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


PositiveAttribute Constructor

PositiveAttribute Constructor
Initializes a new PositiveAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PositiveAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PositiveAttribute Class
PostSharp.Patterns.Contracts Namespace


PositiveAttribute Fields

PositiveAttribute Fields

The PositiveAttribute type exposes the following members.

Fields
 | Name | Description
Protected field | displayMax | (Inherited from RangeAttribute.)
Protected field | displayMin | (Inherited from RangeAttribute.)
Top
See Also

Reference

PositiveAttribute Class
PostSharp.Patterns.Contracts Namespace


PositiveAttribute Methods

PositiveAttribute Methods

The PositiveAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from RangeAttribute.)
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Inherited from GreaterThanAttribute.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Inherited from GreaterThanAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PositiveAttribute Class
PostSharp.Patterns.Contracts Namespace


PositiveAttribute Properties

PositiveAttribute Properties

The PositiveAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

PositiveAttribute Class
PostSharp.Patterns.Contracts Namespace


RangeAttribute Class

RangeAttribute Class
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.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRangeAttribute
PostSharp.Patterns.ContractsGreaterThanAttribute
PostSharp.Patterns.ContractsLessThanAttribute
PostSharp.Patterns.ContractsStrictlyGreaterThanAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class RangeAttribute : LocationContractAttribute,
    IValidableAnnotation, ILocationValidationAspect<Nullable<long>>, ILocationValidationAspect<Nullable<ulong>>,
    ILocationValidationAspect<Nullable<int>>, ILocationValidationAspect<Nullable<uint>>,
    ILocationValidationAspect<Nullable<short>>, ILocationValidationAspect<Nullable<byte>>,
    ILocationValidationAspect<Nullable<sbyte>>, ILocationValidationAspect<Nullable<ushort>>,
    ILocationValidationAspect<Nullable<double>>, ILocationValidationAspect<Nullable<decimal>>,
    ILocationValidationAspect<long>, ILocationValidationAspect<ulong>, ILocationValidationAspect<double>,
    ILocationValidationAspect<decimal>, ILocationValidationAspect<int>, ILocationValidationAspect<uint>,
    ILocationValidationAspect<short>, ILocationValidationAspect<byte>, ILocationValidationAspect<sbyte>,
    ILocationValidationAspect<ushort>, ILocationValidationAspect, IAspect

The RangeAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | RangeAttribute(Decimal, Decimal) | Initializes a new GreaterThanAttribute and specify a Decimal bound.
Public method | RangeAttribute(Double, Double) | Initializes a new GreaterThanAttribute and specify a floating-point bound.
Public method | RangeAttribute(Int64, Int64) | Initializes a new GreaterThanAttribute and specify an integer bound.
Public method | RangeAttribute(UInt64, UInt64) | Initializes a new GreaterThanAttribute and specify a UInt64 bound.
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Overrides LocationContractAttributeGetErrorMessage.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Overrides LocationContractAttributeGetErrorMessageArguments.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
 | Name | Description
Protected field | displayMax |
Protected field | displayMin |
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Null values are accepted and do not throw an exception.

Error message is identified by RangeErrorMessage.

Error message can use additional argument

Field Value

Type:
{4} to refer to the minimum value used and

Field Value

Type:
{5} to refer to the maximum value used.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


RangeAttribute Constructor

RangeAttribute Constructor
Overload List
 | Name | Description
Public method | RangeAttribute(Decimal, Decimal) | Initializes a new GreaterThanAttribute and specify a Decimal bound.
Public method | RangeAttribute(Double, Double) | Initializes a new GreaterThanAttribute and specify a floating-point bound.
Public method | RangeAttribute(Int64, Int64) | Initializes a new GreaterThanAttribute and specify an integer bound.
Public method | RangeAttribute(UInt64, UInt64) | Initializes a new GreaterThanAttribute and specify a UInt64 bound.
Top
See Also

Reference

RangeAttribute Class
PostSharp.Patterns.Contracts Namespace


RangeAttribute Constructor (Decimal, Decimal)

RangeAttribute Constructor (Decimal, Decimal)
Initializes a new GreaterThanAttribute and specify a Decimal bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RangeAttribute(
    decimal min,
    decimal max
)

Parameters

min
Type: SystemDecimal
The lower bound.
max
Type: SystemDecimal
The upper bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RangeAttribute Class
RangeAttribute Overload
PostSharp.Patterns.Contracts Namespace


RangeAttribute Constructor (Double, Double)

RangeAttribute Constructor (Double, Double)
Initializes a new GreaterThanAttribute and specify a floating-point bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RangeAttribute(
    double min,
    double max
)

Parameters

min
Type: SystemDouble
The lower bound.
max
Type: SystemDouble
The upper bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RangeAttribute Class
RangeAttribute Overload
PostSharp.Patterns.Contracts Namespace


RangeAttribute Constructor (Int64, Int64)

RangeAttribute Constructor (Int64, Int64)
Initializes a new GreaterThanAttribute and specify an integer bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RangeAttribute(
    long min,
    long max
)

Parameters

min
Type: SystemInt64
The lower bound.
max
Type: SystemInt64
The upper bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RangeAttribute Class
RangeAttribute Overload
PostSharp.Patterns.Contracts Namespace


RangeAttribute Constructor (UInt64, UInt64)

RangeAttribute Constructor (UInt64, UInt64)
Initializes a new GreaterThanAttribute and specify a UInt64 bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RangeAttribute(
    ulong min,
    ulong max
)

Parameters

min
Type: SystemUInt64
The lower bound.
max
Type: SystemUInt64
The upper bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RangeAttribute Class
RangeAttribute Overload
PostSharp.Patterns.Contracts Namespace


RangeAttribute Fields

RangeAttribute Fields

The RangeAttribute type exposes the following members.

Fields
 | Name | Description
Protected field | displayMax |
Protected field | displayMin |
Top
See Also

Reference

RangeAttribute Class
PostSharp.Patterns.Contracts Namespace


RangeAttribute.displayMax Field

RangeAttributedisplayMax Field

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected readonly Object displayMax

Field Value

Type: Object
Version Information

Supported in: 4.1

See Also

Reference

RangeAttribute Class
PostSharp.Patterns.Contracts Namespace


RangeAttribute.displayMin Field

RangeAttributedisplayMin Field

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected readonly Object displayMin

Field Value

Type: Object
Version Information

Supported in: 4.1

See Also

Reference

RangeAttribute Class
PostSharp.Patterns.Contracts Namespace


RangeAttribute Methods

RangeAttribute Methods

The RangeAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Overrides LocationContractAttributeGetErrorMessage.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Overrides LocationContractAttributeGetErrorMessageArguments.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RangeAttribute Class
PostSharp.Patterns.Contracts Namespace


RangeAttribute.CompileTimeValidate Method

RangeAttributeCompileTimeValidate Method
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Target element.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.

Implements

IValidableAnnotationCompileTimeValidate(Object)
Remarks
The implementation of this method is expected to emit an error message or an exception of type InvalidAnnotationException in case of error. Only returning false causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RangeAttribute Class
PostSharp.Patterns.Contracts Namespace


RangeAttribute.GetErrorMessage Method

RangeAttributeGetErrorMessage Method
Gets unformatted error message as defined by the instance.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override string GetErrorMessage()

Return Value

Type: String
Remarks

See remarks on LocationContractAttribute for information about message parameters.

Use of this method can be overridden by setting ErrorMessage property to non-null value.

Version Information

Supported in: 4.1

See Also

Reference

RangeAttribute Class
PostSharp.Patterns.Contracts Namespace


RangeAttribute.GetErrorMessageArguments Method

RangeAttributeGetErrorMessageArguments Method
Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override Object[] GetErrorMessageArguments()

Return Value

Type: Object
object of additional argument values.
Remarks
This method is expected to be pure, i.e. it's result can be cached and so the implementer should not return information that may change after constructor of the class has finished.
Version Information

Supported in: 4.1

See Also

Reference

RangeAttribute Class
PostSharp.Patterns.Contracts Namespace


RangeAttribute Properties

RangeAttribute Properties

The RangeAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

RangeAttribute Class
PostSharp.Patterns.Contracts Namespace


RegularExpressionAttribute Class

RegularExpressionAttribute Class
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.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRegularExpressionAttribute
PostSharp.Patterns.ContractsEmailAddressAttribute
PostSharp.Patterns.ContractsPhoneAttribute
PostSharp.Patterns.ContractsUrlAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class RegularExpressionAttribute : LocationContractAttribute,
    ILocationValidationAspect<string>, ILocationValidationAspect, IAspect

The RegularExpressionAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | RegularExpressionAttribute(String) | Initializes a new RegularExpressionAttribute.
Public method | RegularExpressionAttribute(String, RegexOptions) | Initializes a new RegularExpressionAttribute and specify options.
Top
Methods
 | Name | Description
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Overrides LocationContractAttributeGetErrorMessage.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Overrides LocationContractAttributeGetErrorMessageArguments.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Error message is identified by RegularExpressionErrorMessage.

Error message can use additional argument

Field Value

Type:
{4} to refer to the regular expression used.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


RegularExpressionAttribute Constructor

RegularExpressionAttribute Constructor
Overload List
 | Name | Description
Public method | RegularExpressionAttribute(String) | Initializes a new RegularExpressionAttribute.
Public method | RegularExpressionAttribute(String, RegexOptions) | Initializes a new RegularExpressionAttribute and specify options.
Top
See Also

Reference

RegularExpressionAttribute Class
PostSharp.Patterns.Contracts Namespace


RegularExpressionAttribute Constructor (String)

RegularExpressionAttribute Constructor (String)
Initializes a new RegularExpressionAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RegularExpressionAttribute(
    string pattern
)

Parameters

pattern
Type: SystemString
The regular expression.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RegularExpressionAttribute Class
RegularExpressionAttribute Overload
PostSharp.Patterns.Contracts Namespace


RegularExpressionAttribute Constructor (String, RegexOptions)

RegularExpressionAttribute Constructor (String, RegexOptions)
Initializes a new RegularExpressionAttribute and specify options.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RegularExpressionAttribute(
    string pattern,
    RegexOptions options
)

Parameters

pattern
Type: SystemString
The regular expression.
options
Type: System.Text.RegularExpressionsRegexOptions
Options.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RegularExpressionAttribute Class
RegularExpressionAttribute Overload
PostSharp.Patterns.Contracts Namespace


RegularExpressionAttribute Methods

RegularExpressionAttribute Methods

The RegularExpressionAttribute type exposes the following members.

Methods
 | Name | Description
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Overrides LocationContractAttributeGetErrorMessage.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Overrides LocationContractAttributeGetErrorMessageArguments.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RegularExpressionAttribute Class
PostSharp.Patterns.Contracts Namespace


RegularExpressionAttribute.GetErrorMessage Method

RegularExpressionAttributeGetErrorMessage Method
Gets unformatted error message as defined by the instance.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override string GetErrorMessage()

Return Value

Type: String
Remarks

See remarks on LocationContractAttribute for information about message parameters.

Use of this method can be overridden by setting ErrorMessage property to non-null value.

Version Information

Supported in: 4.1

See Also

Reference

RegularExpressionAttribute Class
PostSharp.Patterns.Contracts Namespace


RegularExpressionAttribute.GetErrorMessageArguments Method

RegularExpressionAttributeGetErrorMessageArguments Method
Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override Object[] GetErrorMessageArguments()

Return Value

Type: Object
object of additional argument values.
Remarks
This method is expected to be pure, i.e. it's result can be cached and so the implementer should not return information that may change after constructor of the class has finished.
Version Information

Supported in: 4.1

See Also

Reference

RegularExpressionAttribute Class
PostSharp.Patterns.Contracts Namespace


RegularExpressionAttribute Properties

RegularExpressionAttribute Properties

The RegularExpressionAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

RegularExpressionAttribute Class
PostSharp.Patterns.Contracts Namespace


RequiredAttribute Class

RequiredAttribute Class
Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null value or an empty or white-space string.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRequiredAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class RequiredAttribute : LocationContractAttribute,
    ILocationValidationAspect<Object>, ILocationValidationAspect<string>, ILocationValidationAspect,
    IAspect

The RequiredAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | RequiredAttribute | Initializes a new RequiredAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Error message is identified by RequiredErrorMessage.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


RequiredAttribute Constructor

RequiredAttribute Constructor
Initializes a new RequiredAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RequiredAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

RequiredAttribute Class
PostSharp.Patterns.Contracts Namespace


RequiredAttribute Methods

RequiredAttribute Methods

The RequiredAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RequiredAttribute Class
PostSharp.Patterns.Contracts Namespace


RequiredAttribute Properties

RequiredAttribute Properties

The RequiredAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

RequiredAttribute Class
PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute Class

StrictlyGreaterThanAttribute Class
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is strictly smaller than a given value.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRangeAttribute
PostSharp.Patterns.ContractsStrictlyGreaterThanAttribute
PostSharp.Patterns.ContractsStrictlyPositiveAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class StrictlyGreaterThanAttribute : RangeAttribute

The StrictlyGreaterThanAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | StrictlyGreaterThanAttribute(Decimal) | Initializes a new StrictlyGreaterThanAttribute and specifies a floating-point bound.
Public method | StrictlyGreaterThanAttribute(Double) | Initializes a new StrictlyGreaterThanAttribute and specifies a floating-point bound.
Public method | StrictlyGreaterThanAttribute(Int64) | Initializes a new StrictlyGreaterThanAttribute and specify an integer bound.
Public method | StrictlyGreaterThanAttribute(UInt64) | Initializes a new StrictlyGreaterThanAttribute and specifies a UInt64 bound.
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from RangeAttribute.)
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Overrides RangeAttributeGetErrorMessage.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Overrides RangeAttributeGetErrorMessageArguments.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
 | Name | Description
Protected field | displayMax | (Inherited from RangeAttribute.)
Protected field | displayMin | (Inherited from RangeAttribute.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Null values are accepted and do not throw an exception.

Floating-point values are tested to be greater or equal than the minimum value plus a tolerance value. The tolerance value is set to Epsilon if the minimum value is 0, or one millionth (1E-6) of the minimum value otherwise.

Error message is identified by StrictlyGreaterThanErrorMessage.

Error message can use additional argument

Field Value

Type:
{4} to refer to the minimum value used.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute Constructor

StrictlyGreaterThanAttribute Constructor
Overload List
 | Name | Description
Public method | StrictlyGreaterThanAttribute(Decimal) | Initializes a new StrictlyGreaterThanAttribute and specifies a floating-point bound.
Public method | StrictlyGreaterThanAttribute(Double) | Initializes a new StrictlyGreaterThanAttribute and specifies a floating-point bound.
Public method | StrictlyGreaterThanAttribute(Int64) | Initializes a new StrictlyGreaterThanAttribute and specify an integer bound.
Public method | StrictlyGreaterThanAttribute(UInt64) | Initializes a new StrictlyGreaterThanAttribute and specifies a UInt64 bound.
Top
See Also

Reference

StrictlyGreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute Constructor (Decimal)

StrictlyGreaterThanAttribute Constructor (Decimal)
Initializes a new StrictlyGreaterThanAttribute and specifies a floating-point bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public StrictlyGreaterThanAttribute(
    decimal min
)

Parameters

min
Type: SystemDecimal
The lower bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StrictlyGreaterThanAttribute Class
StrictlyGreaterThanAttribute Overload
PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute Constructor (Double)

StrictlyGreaterThanAttribute Constructor (Double)
Initializes a new StrictlyGreaterThanAttribute and specifies a floating-point bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public StrictlyGreaterThanAttribute(
    double min
)

Parameters

min
Type: SystemDouble
The lower bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StrictlyGreaterThanAttribute Class
StrictlyGreaterThanAttribute Overload
PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute Constructor (Int64)

StrictlyGreaterThanAttribute Constructor (Int64)
Initializes a new StrictlyGreaterThanAttribute and specify an integer bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public StrictlyGreaterThanAttribute(
    long min
)

Parameters

min
Type: SystemInt64
The lower bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StrictlyGreaterThanAttribute Class
StrictlyGreaterThanAttribute Overload
PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute Constructor (UInt64)

StrictlyGreaterThanAttribute Constructor (UInt64)
Initializes a new StrictlyGreaterThanAttribute and specifies a UInt64 bound.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public StrictlyGreaterThanAttribute(
    ulong min
)

Parameters

min
Type: SystemUInt64
The lower bound.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StrictlyGreaterThanAttribute Class
StrictlyGreaterThanAttribute Overload
PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute Fields

StrictlyGreaterThanAttribute Fields

The StrictlyGreaterThanAttribute type exposes the following members.

Fields
 | Name | Description
Protected field | displayMax | (Inherited from RangeAttribute.)
Protected field | displayMin | (Inherited from RangeAttribute.)
Top
See Also

Reference

StrictlyGreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute Methods

StrictlyGreaterThanAttribute Methods

The StrictlyGreaterThanAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from RangeAttribute.)
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Overrides RangeAttributeGetErrorMessage.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Overrides RangeAttributeGetErrorMessageArguments.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

StrictlyGreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute.GetErrorMessage Method

StrictlyGreaterThanAttributeGetErrorMessage Method
Gets unformatted error message as defined by the instance.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override string GetErrorMessage()

Return Value

Type: String
Remarks

See remarks on LocationContractAttribute for information about message parameters.

Use of this method can be overridden by setting ErrorMessage property to non-null value.

Version Information

Supported in: 4.1

See Also

Reference

StrictlyGreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute.GetErrorMessageArguments Method

StrictlyGreaterThanAttributeGetErrorMessageArguments Method
Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override Object[] GetErrorMessageArguments()

Return Value

Type: Object
object of additional argument values.
Remarks
This method is expected to be pure, i.e. it's result can be cached and so the implementer should not return information that may change after constructor of the class has finished.
Version Information

Supported in: 4.1

See Also

Reference

StrictlyGreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


StrictlyGreaterThanAttribute Properties

StrictlyGreaterThanAttribute Properties

The StrictlyGreaterThanAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

StrictlyGreaterThanAttribute Class
PostSharp.Patterns.Contracts Namespace


StrictlyPositiveAttribute Class

StrictlyPositiveAttribute Class
Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that smaller than zero.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRangeAttribute
PostSharp.Patterns.ContractsStrictlyGreaterThanAttribute
PostSharp.Patterns.ContractsStrictlyPositiveAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class StrictlyPositiveAttribute : StrictlyGreaterThanAttribute

The StrictlyPositiveAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | StrictlyPositiveAttribute | Initializes a new StrictlyPositiveAttribute.
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from RangeAttribute.)
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Inherited from StrictlyGreaterThanAttribute.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Inherited from StrictlyGreaterThanAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
 | Name | Description
Protected field | displayMax | (Inherited from RangeAttribute.)
Protected field | displayMin | (Inherited from RangeAttribute.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Null values are accepted and do not throw an exception.

Error message is identified by GreaterThanErrorMessage.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


StrictlyPositiveAttribute Constructor

StrictlyPositiveAttribute Constructor
Initializes a new StrictlyPositiveAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public StrictlyPositiveAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StrictlyPositiveAttribute Class
PostSharp.Patterns.Contracts Namespace


StrictlyPositiveAttribute Fields

StrictlyPositiveAttribute Fields

The StrictlyPositiveAttribute type exposes the following members.

Fields
 | Name | Description
Protected field | displayMax | (Inherited from RangeAttribute.)
Protected field | displayMin | (Inherited from RangeAttribute.)
Top
See Also

Reference

StrictlyPositiveAttribute Class
PostSharp.Patterns.Contracts Namespace


StrictlyPositiveAttribute Methods

StrictlyPositiveAttribute Methods

The StrictlyPositiveAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from RangeAttribute.)
Protected method | CreateArgumentException | Creates an ArgumentException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentNullException | Creates an ArgumentNullException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | CreateArgumentOutOfRangeException | Creates an ArgumentOutOfRangeException with an error message formatted from ErrorMessage and given concrete values. (Inherited from LocationContractAttribute.)
Protected method | FormatErrorMessage | Formats the ErrorMessage with concrete values. (Inherited from LocationContractAttribute.)
Protected method | GetErrorMessage | Gets unformatted error message as defined by the instance. (Inherited from StrictlyGreaterThanAttribute.)
Protected method | GetErrorMessageArguments | Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on. (Inherited from StrictlyGreaterThanAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

StrictlyPositiveAttribute Class
PostSharp.Patterns.Contracts Namespace


StrictlyPositiveAttribute Properties

StrictlyPositiveAttribute Properties

The StrictlyPositiveAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

StrictlyPositiveAttribute Class
PostSharp.Patterns.Contracts Namespace


StringLengthAttribute Class

StringLengthAttribute Class
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.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsStringLengthAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class StringLengthAttribute : LocationContractAttribute,
    ILocationValidationAspect<string>, ILocationValidationAspect, IAspect

The StringLengthAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | StringLengthAttribute(Int32) | Initializes a new StringLengthAttribute and specifies the maximum length.
Public method | StringLengthAttribute(Int32, Int32) | Initializes a new StringLengthAttribute and specifies the maximum length and the minimum length.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Public property | MaximumLength | Gets the maximum length.
Public property | MinimumLength | Gets the minimum length.
Top
Remarks

Depending on supplied constructor arguments, one of the following holds:

  • if there is no minimum specified, then the error message is identified by StringLengthMaxErrorMessage and can use additional argument

    Field Value

    Type:
    {4} to refer to the maximum value specified,
  • or if there is maximum is equal to MaxValue, then the error message is identified by StringLengthMinErrorMessage and can use additional argument

    Field Value

    Type:
    {4} to refer to the minimum value specified,
  • otherwise, the error message is identified by StringLengthRangeErrorMessage and can use additional arguments

    Field Value

    Type:
    {4} to refer to the minimum value specified and

    Field Value

    Type:
    {5} to refer to the maximum value specified.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


StringLengthAttribute Constructor

StringLengthAttribute Constructor
Overload List
 | Name | Description
Public method | StringLengthAttribute(Int32) | Initializes a new StringLengthAttribute and specifies the maximum length.
Public method | StringLengthAttribute(Int32, Int32) | Initializes a new StringLengthAttribute and specifies the maximum length and the minimum length.
Top
See Also

Reference

StringLengthAttribute Class
PostSharp.Patterns.Contracts Namespace


StringLengthAttribute Constructor (Int32)

StringLengthAttribute Constructor (Int32)
Initializes a new StringLengthAttribute and specifies the maximum length.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public StringLengthAttribute(
    int maximumLength
)

Parameters

maximumLength
Type: SystemInt32
Maximum length.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StringLengthAttribute Class
StringLengthAttribute Overload
PostSharp.Patterns.Contracts Namespace


StringLengthAttribute Constructor (Int32, Int32)

StringLengthAttribute Constructor (Int32, Int32)
Initializes a new StringLengthAttribute and specifies the maximum length and the minimum length.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public StringLengthAttribute(
    int minimumLength,
    int maximumLength
)

Parameters

minimumLength
Type: SystemInt32
Minimum length.
maximumLength
Type: SystemInt32
Maximum length.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StringLengthAttribute Class
StringLengthAttribute Overload
PostSharp.Patterns.Contracts Namespace


StringLengthAttribute Methods

StringLengthAttribute Methods

The StringLengthAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

StringLengthAttribute Class
PostSharp.Patterns.Contracts Namespace


StringLengthAttribute Properties

StringLengthAttribute Properties

The StringLengthAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Public property | MaximumLength | Gets the maximum length.
Public property | MinimumLength | Gets the minimum length.
Top
See Also

Reference

StringLengthAttribute Class
PostSharp.Patterns.Contracts Namespace


StringLengthAttribute.MaximumLength Property

StringLengthAttributeMaximumLength Property
Gets the maximum length.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int MaximumLength { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StringLengthAttribute Class
PostSharp.Patterns.Contracts Namespace


StringLengthAttribute.MinimumLength Property

StringLengthAttributeMinimumLength Property
Gets the minimum length.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int MinimumLength { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

StringLengthAttribute Class
PostSharp.Patterns.Contracts Namespace


UrlAttribute Class

UrlAttribute Class
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.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ContractsLocationContractAttribute
PostSharp.Patterns.ContractsRegularExpressionAttribute
PostSharp.Patterns.ContractsUrlAttribute

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class UrlAttribute : RegularExpressionAttribute

The UrlAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | UrlAttribute | Initializes a new UrlAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
Remarks

Error message is identified by UrlErrorMessage.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Contracts Namespace


UrlAttribute Constructor

UrlAttribute Constructor
Initializes a new UrlAttribute.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public UrlAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

UrlAttribute Class
PostSharp.Patterns.Contracts Namespace


UrlAttribute Methods

UrlAttribute Methods

The UrlAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

UrlAttribute Class
PostSharp.Patterns.Contracts Namespace


UrlAttribute Properties

UrlAttribute Properties

The UrlAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | ErrorMessage | Gets or sets the error message formatting string. (Inherited from LocationContractAttribute.)
Top
See Also

Reference

UrlAttribute Class
PostSharp.Patterns.Contracts Namespace


PostSharp.Patterns.Diagnostics Namespace

PostSharp.Patterns.Diagnostics Namespace
The PostSharp.Patterns.Diagnostics namespace contains a logging aspect.
Classes
 | Class | Description
Public class | LogAspectConfiguration | Configuration of an ILogAspect.
Public class | LogAspectConfigurationAttribute | Configures an aspect of type ILogAspect.
Public class | LogAttribute | Custom attribute that, when applied on a method, causes PostSharp to implement tracing before and after execution of this method.
Public class | LogAttributeBase | Base class for all logging aspects.
Public class | LogExceptionAttribute | Custom attribute that, when applied on a method, causes PostSharp to implement tracing upon exception in this method.
Public class | LoggingProfile | Logging profiles are named configurations of logging aspects. They are typically instantiated in the PostSharp XML project file.
Interfaces
 | Interface | Description
Public interface | ILogAspect | Runtime semantics of the logging aspect.
Enumerations
 | Enumeration | Description
Public enumeration | LogLevel | Specifies the severity of a logged message.
Public enumeration | LogOptions | Specifies the options for logging parameter names, types and values.


ILogAspect Interface

ILogAspect Interface
Runtime semantics of the logging aspect.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILogAspect : IAspect
Remarks

This aspect has no semantic, therefore this interface is empty. However, it is required to bind aspect classes to the weaver. The aspect is configured through the LogAspectConfiguration object. Implementations of ILogAspect can implement IAspectBuildSemantics to provide the configuration objects, or the configuration objects can be provided otherwise (LogAspectConfigurationAttribute or IAspectProvider).

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration Class

LogAspectConfiguration Class
Configuration of an ILogAspect.
Inheritance Hierarchy
SystemObject
PostSharp.Aspects.ConfigurationAspectConfiguration
PostSharp.Patterns.DiagnosticsLogAspectConfiguration

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class LogAspectConfiguration : AspectConfiguration,
    IProfileAwareConfiguration

The LogAspectConfiguration type exposes the following members.

Constructors
 | Name | Description
Public method | LogAspectConfiguration | Initializes a new instance of the LogAspectConfiguration class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | OnEntryLevel | Gets or sets the severity level for logging before method execution.
Public property | OnEntryOptions | Gets or sets options for logging before method execution.
Public property | OnExceptionLevel | Gets or sets the severity level for logging on method exception.
Public property | OnExceptionOptions | Gets or sets options for logging on method exception.
Public property | OnSuccessLevel | Gets or sets the severity level for logging on method success.
Public property | OnSuccessOptions | Gets or sets options for logging on method success.
Public property | ProfileName | Gets or sets the name of the logging profile.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration Constructor

LogAspectConfiguration Constructor
Initializes a new instance of the LogAspectConfiguration class

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogAspectConfiguration()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfiguration Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration Methods

LogAspectConfiguration Methods

The LogAspectConfiguration type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LogAspectConfiguration Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration Properties

LogAspectConfiguration Properties

The LogAspectConfiguration type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the aspect priority. Aspects with smaller priority are processed first. The default priority is zero. (Inherited from AspectConfiguration.)
Public property | Dependencies | Gets or sets the collection of dependencies. (Inherited from AspectConfiguration.)
Public property | OnEntryLevel | Gets or sets the severity level for logging before method execution.
Public property | OnEntryOptions | Gets or sets options for logging before method execution.
Public property | OnExceptionLevel | Gets or sets the severity level for logging on method exception.
Public property | OnExceptionOptions | Gets or sets options for logging on method exception.
Public property | OnSuccessLevel | Gets or sets the severity level for logging on method success.
Public property | OnSuccessOptions | Gets or sets options for logging on method success.
Public property | ProfileName | Gets or sets the name of the logging profile.
Public property | SerializerType | Gets or sets the type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfiguration.)
Top
See Also

Reference

LogAspectConfiguration Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration.OnEntryLevel Property

LogAspectConfigurationOnEntryLevel Property
Gets or sets the severity level for logging before method execution.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogLevel> OnEntryLevel { get; set; }

Property Value

Type: Nullable LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfiguration Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration.OnEntryOptions Property

LogAspectConfigurationOnEntryOptions Property
Gets or sets options for logging before method execution.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogOptions> OnEntryOptions { get; set; }

Property Value

Type: Nullable LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfiguration Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration.OnExceptionLevel Property

LogAspectConfigurationOnExceptionLevel Property
Gets or sets the severity level for logging on method exception.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogLevel> OnExceptionLevel { get; set; }

Property Value

Type: Nullable LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfiguration Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration.OnExceptionOptions Property

LogAspectConfigurationOnExceptionOptions Property
Gets or sets options for logging on method exception.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogOptions> OnExceptionOptions { get; set; }

Property Value

Type: Nullable LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfiguration Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration.OnSuccessLevel Property

LogAspectConfigurationOnSuccessLevel Property
Gets or sets the severity level for logging on method success.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogLevel> OnSuccessLevel { get; set; }

Property Value

Type: Nullable LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfiguration Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration.OnSuccessOptions Property

LogAspectConfigurationOnSuccessOptions Property
Gets or sets options for logging on method success.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogOptions> OnSuccessOptions { get; set; }

Property Value

Type: Nullable LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfiguration Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfiguration.ProfileName Property

LogAspectConfigurationProfileName Property
Gets or sets the name of the logging profile.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string ProfileName { get; set; }

Property Value

Type: String
The name of the logging profile, or null to use the default logging profile

Implements

IProfileAwareConfigurationProfileName
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfiguration Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfigurationAttribute Class

LogAspectConfigurationAttribute Class
Configures an aspect of type ILogAspect.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Aspects.ConfigurationAspectConfigurationAttribute
PostSharp.Patterns.DiagnosticsLogAspectConfigurationAttribute

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class LogAspectConfigurationAttribute : AspectConfigurationAttribute

The LogAspectConfigurationAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | LogAspectConfigurationAttribute | Initializes a new instance of the LogAspectConfigurationAttribute class
Top
Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | OnEntryLevel | Gets or sets the severity level for logging before method execution.
Public property | OnEntryOptions | Gets or sets options for logging before method execution.
Public property | OnExceptionLevel | Gets or sets the severity level for logging on method exception.
Public property | OnExceptionOptions | Gets or sets options for logging on method exception.
Public property | OnSuccessLevel | Gets or sets the severity level for logging on method success.
Public property | OnSuccessOptions | Gets or sets options for logging on method success.
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Diagnostics Namespace


LogAspectConfigurationAttribute Constructor

LogAspectConfigurationAttribute Constructor
Initializes a new instance of the LogAspectConfigurationAttribute class

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogAspectConfigurationAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfigurationAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfigurationAttribute Methods

LogAspectConfigurationAttribute Methods

The LogAspectConfigurationAttribute type exposes the following members.

Methods
 | Name | Description
Public method | GetAspectConfiguration | Gets the AspectConfiguration corresponding to the current custom attribute. (Inherited from AspectConfigurationAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LogAspectConfigurationAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfigurationAttribute Properties

LogAspectConfigurationAttribute Properties

The LogAspectConfigurationAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from AspectConfigurationAttribute.)
Public property | OnEntryLevel | Gets or sets the severity level for logging before method execution.
Public property | OnEntryOptions | Gets or sets options for logging before method execution.
Public property | OnExceptionLevel | Gets or sets the severity level for logging on method exception.
Public property | OnExceptionOptions | Gets or sets options for logging on method exception.
Public property | OnSuccessLevel | Gets or sets the severity level for logging on method success.
Public property | OnSuccessOptions | Gets or sets options for logging on method success.
Public property | SerializerType | Gets or sets the Type of the serializer that will be used to configure the current aspect. (Inherited from AspectConfigurationAttribute.)
Top
See Also

Reference

LogAspectConfigurationAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfigurationAttribute.OnEntryLevel Property

LogAspectConfigurationAttributeOnEntryLevel Property
Gets or sets the severity level for logging before method execution.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogLevel OnEntryLevel { get; set; }

Property Value

Type: LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfigurationAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfigurationAttribute.OnEntryOptions Property

LogAspectConfigurationAttributeOnEntryOptions Property
Gets or sets options for logging before method execution.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogOptions OnEntryOptions { get; set; }

Property Value

Type: LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfigurationAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfigurationAttribute.OnExceptionLevel Property

LogAspectConfigurationAttributeOnExceptionLevel Property
Gets or sets the severity level for logging on method exception.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogLevel OnExceptionLevel { get; set; }

Property Value

Type: LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfigurationAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfigurationAttribute.OnExceptionOptions Property

LogAspectConfigurationAttributeOnExceptionOptions Property
Gets or sets options for logging on method exception.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogOptions OnExceptionOptions { get; set; }

Property Value

Type: LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfigurationAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfigurationAttribute.OnSuccessLevel Property

LogAspectConfigurationAttributeOnSuccessLevel Property
Gets or sets the severity level for logging on method success.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogLevel OnSuccessLevel { get; set; }

Property Value

Type: LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfigurationAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAspectConfigurationAttribute.OnSuccessOptions Property

LogAspectConfigurationAttributeOnSuccessOptions Property
Gets or sets options for logging on method success.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogOptions OnSuccessOptions { get; set; }

Property Value

Type: LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAspectConfigurationAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAttribute Class

LogAttribute Class
Custom attribute that, when applied on a method, causes PostSharp to implement tracing before and after execution of this method.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.Patterns.DiagnosticsLogAttributeBase
PostSharp.Patterns.DiagnosticsLogAttribute

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class LogAttribute : LogAttributeBase

The LogAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | LogAttribute | Initializes a new LogAttribute.
Public method | LogAttribute(String) | Initializes a new LogAttribute and specifies a logging profile.
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from LogAttributeBase.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | Configuration | Gets the aspect configuration. (Inherited from LogAttributeBase.)
Public property | OnEntryLevel | Gets or sets the severity level for logging before method execution.
Public property | OnEntryOptions | Gets or sets options for logging before method execution.
Public property | OnExceptionLevel | Gets or sets the severity level for logging on method exception.
Public property | OnExceptionOptions | Gets or sets options for logging on method exception.
Public property | OnSuccessLevel | Gets or sets the severity level for logging on method success.
Public property | OnSuccessOptions | Gets or sets options for logging on method success.
Public property | ProfileName | Gets or sets the name of the logging profile. (Inherited from LogAttributeBase.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

By default, the current custom attribute follows the settings of the default profile, which adds a Debug message on entry and on success, and a Warning on exception. All messages include parameter values. You can change these default settings by setting the properties of this class, or by choosing a different logging profile. The values set to properties in this class override the values set by the logging profile. debug

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Diagnostics Namespace


LogAttribute Constructor

LogAttribute Constructor
Overload List
 | Name | Description
Public method | LogAttribute | Initializes a new LogAttribute.
Public method | LogAttribute(String) | Initializes a new LogAttribute and specifies a logging profile.
Top
See Also

Reference

LogAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAttribute Constructor

LogAttribute Constructor
Initializes a new LogAttribute.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttribute Class
LogAttribute Overload
PostSharp.Patterns.Diagnostics Namespace


LogAttribute Constructor (String)

LogAttribute Constructor (String)
Initializes a new LogAttribute and specifies a logging profile.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogAttribute(
    string profileName
)

Parameters

profileName
Type: SystemString
The name of the logging profile, or null to use the default logging profile.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttribute Class
LogAttribute Overload
PostSharp.Patterns.Diagnostics Namespace


LogAttribute Methods

LogAttribute Methods

The LogAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from LogAttributeBase.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LogAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAttribute Properties

LogAttribute Properties

The LogAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | Configuration | Gets the aspect configuration. (Inherited from LogAttributeBase.)
Public property | OnEntryLevel | Gets or sets the severity level for logging before method execution.
Public property | OnEntryOptions | Gets or sets options for logging before method execution.
Public property | OnExceptionLevel | Gets or sets the severity level for logging on method exception.
Public property | OnExceptionOptions | Gets or sets options for logging on method exception.
Public property | OnSuccessLevel | Gets or sets the severity level for logging on method success.
Public property | OnSuccessOptions | Gets or sets options for logging on method success.
Public property | ProfileName | Gets or sets the name of the logging profile. (Inherited from LogAttributeBase.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

LogAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAttribute.OnEntryLevel Property

LogAttributeOnEntryLevel Property
Gets or sets the severity level for logging before method execution.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogLevel OnEntryLevel { get; set; }

Property Value

Type: LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAttribute.OnEntryOptions Property

LogAttributeOnEntryOptions Property
Gets or sets options for logging before method execution.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogOptions OnEntryOptions { get; set; }

Property Value

Type: LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAttribute.OnExceptionLevel Property

LogAttributeOnExceptionLevel Property
Gets or sets the severity level for logging on method exception.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogLevel OnExceptionLevel { get; set; }

Property Value

Type: LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAttribute.OnExceptionOptions Property

LogAttributeOnExceptionOptions Property
Gets or sets options for logging on method exception.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogOptions OnExceptionOptions { get; set; }

Property Value

Type: LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAttribute.OnSuccessLevel Property

LogAttributeOnSuccessLevel Property
Gets or sets the severity level for logging on method success.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogLevel OnSuccessLevel { get; set; }

Property Value

Type: LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAttribute.OnSuccessOptions Property

LogAttributeOnSuccessOptions Property
Gets or sets options for logging on method success.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogOptions OnSuccessOptions { get; set; }

Property Value

Type: LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogAttributeBase Class

LogAttributeBase Class
Base class for all logging aspects.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.Patterns.DiagnosticsLogAttributeBase
PostSharp.Patterns.DiagnosticsLogAttribute
PostSharp.Patterns.DiagnosticsLogExceptionAttribute

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class LogAttributeBase : MethodLevelAspect,
    ILogAspect, IAspect

The LogAttributeBase type exposes the following members.

Constructors
 | Name | Description
Protected method | LogAttributeBase | Initializes a new instance of the LogAttributeBase class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | Configuration | Gets the aspect configuration.
Public property | ProfileName | Gets or sets the name of the logging profile.
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

Implementations must configure the aspect by setting properties of the Configuration object. Optionally, the SetAspectConfiguration(AspectConfiguration, MethodBase) method may be overridden.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Diagnostics Namespace


LogAttributeBase Constructor

LogAttributeBase Constructor
Initializes a new instance of the LogAttributeBase class

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected LogAttributeBase()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttributeBase Class
PostSharp.Patterns.Diagnostics Namespace


LogAttributeBase Methods

LogAttributeBase Methods

The LogAttributeBase type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Overrides AspectCreateAspectConfiguration.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LogAttributeBase Class
PostSharp.Patterns.Diagnostics Namespace


LogAttributeBase.CreateAspectConfiguration Method

LogAttributeBaseCreateAspectConfiguration Method
Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed AspectConfiguration CreateAspectConfiguration()

Return Value

Type: AspectConfiguration
A new and empty instance of AspectConfiguration, whose concrete type corresponds to the concrete type of the Aspect.
Remarks
This method should not set up the returned AspectConfiguration. After the current method has returned, the SetAspectConfiguration(AspectConfiguration, Object) method will be invoked, and this method is responsible for setting up the AspectConfigurationobject.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttributeBase Class
PostSharp.Patterns.Diagnostics Namespace

Other Resources

Conceptual Documentation: Configuring Aspects


LogAttributeBase Properties

LogAttributeBase Properties

The LogAttributeBase type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | Configuration | Gets the aspect configuration.
Public property | ProfileName | Gets or sets the name of the logging profile.
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

LogAttributeBase Class
PostSharp.Patterns.Diagnostics Namespace


LogAttributeBase.Configuration Property

LogAttributeBaseConfiguration Property
Gets the aspect configuration.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected LogAspectConfiguration Configuration { get; }

Property Value

Type: LogAspectConfiguration
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttributeBase Class
PostSharp.Patterns.Diagnostics Namespace


LogAttributeBase.ProfileName Property

LogAttributeBaseProfileName Property
Gets or sets the name of the logging profile.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string ProfileName { get; set; }

Property Value

Type: String
Remarks

Settings of the logging profile are overwritten by properties of the current custom attributes, if these properties are specified.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogAttributeBase Class
PostSharp.Patterns.Diagnostics Namespace


LogExceptionAttribute Class

LogExceptionAttribute Class
Custom attribute that, when applied on a method, causes PostSharp to implement tracing upon exception in this method.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.Patterns.DiagnosticsLogAttributeBase
PostSharp.Patterns.DiagnosticsLogExceptionAttribute

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class LogExceptionAttribute : LogAttributeBase

The LogExceptionAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | LogExceptionAttribute | Initializes a new LogExceptionAttribute.
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from LogAttributeBase.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | Configuration | Gets the aspect configuration. (Inherited from LogAttributeBase.)
Public property | ProfileName | Gets or sets the name of the logging profile. (Inherited from LogAttributeBase.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Remarks

Using this custom attribute is strictly equivalent to using the LogAttribute with the Exceptions profile and no other property set.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Diagnostics Namespace


LogExceptionAttribute Constructor

LogExceptionAttribute Constructor
Initializes a new LogExceptionAttribute.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LogExceptionAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LogExceptionAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogExceptionAttribute Methods

LogExceptionAttribute Methods

The LogExceptionAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from LogAttributeBase.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, MethodBase) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LogExceptionAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LogExceptionAttribute Properties

LogExceptionAttribute Properties

The LogExceptionAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Protected property | Configuration | Gets the aspect configuration. (Inherited from LogAttributeBase.)
Public property | ProfileName | Gets or sets the name of the logging profile. (Inherited from LogAttributeBase.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

LogExceptionAttribute Class
PostSharp.Patterns.Diagnostics Namespace


LoggingProfile Class

LoggingProfile Class
Logging profiles are named configurations of logging aspects. They are typically instantiated in the PostSharp XML project file.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.DiagnosticsLoggingProfile

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class LoggingProfile

The LoggingProfile type exposes the following members.

Constructors
 | Name | Description
Public method | LoggingProfile | Initializes a new instance of the LoggingProfile class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | OnEntryLevel | Gets or sets the severity level for logging before method execution.
Public property | OnEntryOptions | Gets or sets options for logging before method execution.
Public property | OnExceptionLevel | Gets or sets the severity level for logging on method exception.
Public property | OnExceptionOptions | Gets or sets options for logging on method exception.
Public property | OnSuccessLevel | Gets or sets the severity level for logging on method success.
Public property | OnSuccessOptions | Gets or sets options for logging on method success.
Top
Remarks

Logging profiles are defined in the PostSharp XML project file, in the section LoggingProfiles of XML namespace clr-namespace:PostSharp.Patterns.Diagnostics;assembly:PostSharp.Patterns.Diagnostics. Logging profiles can then be referred to from the LogAttribute. There are two system-defined logging profiles: Default and Exceptions

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Diagnostics Namespace


LoggingProfile Constructor

LoggingProfile Constructor
Initializes a new instance of the LoggingProfile class

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LoggingProfile()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LoggingProfile Class
PostSharp.Patterns.Diagnostics Namespace


LoggingProfile Methods

LoggingProfile Methods

The LoggingProfile type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LoggingProfile Class
PostSharp.Patterns.Diagnostics Namespace


LoggingProfile Properties

LoggingProfile Properties

The LoggingProfile type exposes the following members.

Properties
 | Name | Description
Public property | OnEntryLevel | Gets or sets the severity level for logging before method execution.
Public property | OnEntryOptions | Gets or sets options for logging before method execution.
Public property | OnExceptionLevel | Gets or sets the severity level for logging on method exception.
Public property | OnExceptionOptions | Gets or sets options for logging on method exception.
Public property | OnSuccessLevel | Gets or sets the severity level for logging on method success.
Public property | OnSuccessOptions | Gets or sets options for logging on method success.
Top
See Also

Reference

LoggingProfile Class
PostSharp.Patterns.Diagnostics Namespace


LoggingProfile.OnEntryLevel Property

LoggingProfileOnEntryLevel Property
Gets or sets the severity level for logging before method execution.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogLevel> OnEntryLevel { get; set; }

Property Value

Type: Nullable LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LoggingProfile Class
PostSharp.Patterns.Diagnostics Namespace


LoggingProfile.OnEntryOptions Property

LoggingProfileOnEntryOptions Property
Gets or sets options for logging before method execution.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogOptions> OnEntryOptions { get; set; }

Property Value

Type: Nullable LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LoggingProfile Class
PostSharp.Patterns.Diagnostics Namespace


LoggingProfile.OnExceptionLevel Property

LoggingProfileOnExceptionLevel Property
Gets or sets the severity level for logging on method exception.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogLevel> OnExceptionLevel { get; set; }

Property Value

Type: Nullable LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LoggingProfile Class
PostSharp.Patterns.Diagnostics Namespace


LoggingProfile.OnExceptionOptions Property

LoggingProfileOnExceptionOptions Property
Gets or sets options for logging on method exception.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogOptions> OnExceptionOptions { get; set; }

Property Value

Type: Nullable LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LoggingProfile Class
PostSharp.Patterns.Diagnostics Namespace


LoggingProfile.OnSuccessLevel Property

LoggingProfileOnSuccessLevel Property
Gets or sets the severity level for logging on method success.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogLevel> OnSuccessLevel { get; set; }

Property Value

Type: Nullable LogLevel
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LoggingProfile Class
PostSharp.Patterns.Diagnostics Namespace


LoggingProfile.OnSuccessOptions Property

LoggingProfileOnSuccessOptions Property
Gets or sets options for logging on method success.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Nullable<LogOptions> OnSuccessOptions { get; set; }

Property Value

Type: Nullable LogOptions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LoggingProfile Class
PostSharp.Patterns.Diagnostics Namespace


LogLevel Enumeration

LogLevel Enumeration
Specifies the severity of a logged message.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public enum LogLevel
Members
Member name | Value | Description
None | 0 | No message should be logged.
Debug | 1 | The message should be logged at Debug/Trace level (when applicable).
Info | 2 | The message should be logged at Info level (when applicable).
Warning | 3 | The message should be logged at Warning level (when applicable).
Error | 4 | The message should be logged at Error level (when applicable).
Fatal | 5 | The message should be logged at Fatal level (when applicable).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Diagnostics Namespace


LogOptions Enumeration

LogOptions Enumeration
Specifies the options for logging parameter names, types and values.

Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics (in PostSharp.Patterns.Diagnostics.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
[FlagsAttribute]
public enum LogOptions
Members
Member name | Value | Description
None | 0 | No parameter information included.
IncludeParameterType | 1 | Includes parameter type information.
IncludeParameterName | 2 | Includes parameter name.
IncludeParameterValue | 4 | Includes parameter value, by calling ToString on the object instance.
IncludeReturnValue | 8 | Includes the return value.
IncludeThisArgument | 16 | Includes the value of this argument in an instance method.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Diagnostics Namespace


PostSharp.Patterns.Model Namespace

PostSharp.Patterns.Model Namespace
The PostSharp.Patterns.Model namespace contains an implementation of the Observer, Aggregatable and Disposable patterns.
Classes
 | Class | Description
Public class | AggregatableAttribute | Custom attribute that, when applied to class, enables instances of this class to be involved in a parent-child relationship.
Public class | AggregatableAttributeTargetClass | Describes the members that are introduced or overridden by the AggregatableAttribute aspect. You can define one or many of these members in classes that are the target of AggregatableAttribute to reacts to events of the Aggregatable pattern.
Public class | AggregatableClientAttribute | Base class for aspects that consume functionalities from the AggregatableAttribute aspect. This class provides functionalities to advise and unadvise children.
Public class | AggregatableExtensions | Provides extension methods to the IAggregatable interface.
Public class | AggregatableServices | Provide static methods to aid with implementation of the IAggregatable interface.
Public class | AncestorChangedEventArgs | Arguments of the AncestorChanged event.
Public class | ChildAttribute | Custom attribute that, when applied to a field or automatic property, specifies that the object assigned to this field or property is a child of the instance of the declaring type.
Public class | ChildInfo | Describes a location (typically a field or collection item) on which a child can be attached to a parent.
Public class | Depends | Provides a way to specify dependencies of a method to properties or chains of properties. This class should be used from methods marked with the SafeForDependencyAnalysisAttribute custom attribute.
Public class | DisposableAttribute | Custom attribute that, when applied to a class, implements the IDisposable in such a way that the Dispose method executes the Dispose method for all children objects that also implement the IDisposable interface.
Public class | DynamicallyAdvisableObject | Base class for objects into which advices can be dynamically injected. This class is not meant to be used in user code.
Public class | IgnoreAutoChangeNotificationAttribute | Custom attribute that, when applied to a method, prevents the NotifyPropertyChangedAttribute aspect to raise change notifications for this property.
Public class | MemberRelationshipAttribute | Base class for custom attributes that determine the kind of relationship of objects in a graph.
Public class | NotifyPropertyChangedAttribute | Custom attribute that, when applied on a type, implements the INotifyPropertyChanged interface for this class and all children classes.
Public class | NotifyPropertyChangedAttributeTargetClass | Describes the members that are consumed by the NotifyPropertyChangedAttribute aspect. You can define one or many of these members in classes that are the target of NotifyPropertyChangedAttribute to customize the behavior of the NotifyPropertyChangedAttribute aspect.
Public class | NotifyPropertyChangedOverflowException | Exception thrown at runtime when the NotifyPropertyChangedAttribute aspect encounters an excessively long chain is dependency. This situation is typically caused by a cyclic dependency.
Public class | NotifyPropertyChangedServices | Utility methods to work with the NotifyPropertyChangedAttribute aspect.
Public class | ParentAttribute | Custom attribute that, when applied to a field or automatic property, specifies that this field or property should be automatically set to the parent of the instance of the declaring type, whenever this instance is attached as a child to another object.
Public class | PropertyPath | Immutable property path with all components interned.
Public class | PureAttribute | Custom attribute that, when applied on a method, specifies that this method is a pure function, i.e. the method always returns the same result given the same parameter values. In the context of NotifyPropertyChangedAttribute, it is also assumed that pure functions have only parameters of primitive types (Int32, String, ...). The Object parameter type is also accepted, but then it is assumed that instances passed are immutable (and changes to these objects will not be tracked).
Public class | QueryInterfaceExtensions | Provides methods to aid with the use of dynamic interfaces.
Public class | ReferenceAttribute | Custom attribute that, when applied to a field or automatic property, specifies that this field or property is a simple reference, and is not involved in a parent-child relationship.
Public class | SafeForDependencyAnalysisAttribute | Custom attribute that, when applied on a property, prevents the dependency analysis algorithm used by the NotifyPropertyChangedAttribute aspect from emitting errors when it encounters constructs that it cannot analyze.
Structures
 | Structure | Description
Public structure | RelationshipInfo | Describes the relationship between a parent and a child.
Interfaces
 | Interface | Description
Public interface | IAggregatable | Defines members (principally Parent and VisitChildren(ChildVisitor, ChildVisitorOptions, Object)) that allow to consume parent-child relationships in an object tree.
Public interface | IAttachable | Defines setter methods for the IAggregatable.
Public interface | IAttacher | Describes the semantics of a service through which a child IAggregatable object can attach itself to a parent object. This interface is typically implemented by the parent object by composition.
Public interface | IDynamicInterfaceImplementation | Interface that must be implemented by objects implementing dynamic interfaces, which can be queried using QueryInterfaceT. The IDynamicInterfaceImplementation interface provides a mean to get a reference back to the principal object.
Public interface | IQueryInterface | Interface implemented by objects that can implement interface dynamically by composition, without implementing the interface directly at MSIL level. The QueryInterfaceT method must then be used instead of a normal cast.
Delegates
 | Delegate | Description
Public delegate | ChildVisitor | Encapsulates a method that is invoked by the VisitChildren(ChildVisitor, ChildVisitorOptions, Object) method.
Public delegate | DescendantVisitor | Encapsulates a method that is invoked by the VisitSelfAndDescendants(IAggregatable, DescendantVisitor, ChildVisitorOptions, Object) method.
Enumerations
 | Enumeration | Description
Public enumeration | ChildVisitorOptions | Options for the VisitChildren(ChildVisitor, ChildVisitorOptions, Object) and VisitSelfAndDescendants(IAggregatable, DescendantVisitor, ChildVisitorOptions, Object) methods.
Public enumeration | DescendantVisitorStatus | Type of the return value of ChildVisitor. Determines how the visitor should continue enumerating other objects.
Public enumeration | ObjectAccessLevel | Enumeration of access levels that methods of execution scopes can require on an object.
Public enumeration | RelationshipKind | Enumeration of the kinds of relationship between objects in a object graph.


AggregatableAttribute Class

AggregatableAttribute Class
Custom attribute that, when applied to class, enables instances of this class to be involved in a parent-child relationship.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AggregatableAttribute : InstanceLevelAspect,
    IAttachable, IAggregatable, IAdviceProvider, IAggregatableEventRaiser, IAspectProvider,
    IAspect, IService, IDeserializationCallback

The AggregatableAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | AggregatableAttribute | Initializes a new instance of the AggregatableAttribute class.
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | GetChildren | Gets the list of children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | GetDistinctChildren | Gets a list of distinct children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | IsDescendantOf | Determines whether a specified object is a descendant of a specified ancestor. (Defined by AggregatableExtensions.)
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Public Extension Method | VisitSelfAndDescendants | Executes a ChildVisitor for the a specified parent object and all its descendants. (Defined by AggregatableExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | DefaultItemRelationship | Gets or sets the default kind of relationship for collection items.
Public property | DefaultMemberRelationship | Gets or sets the default kind of relationship of fields and automatic properties.
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | IsParentSurrogate | Determines whether instances of the target class of this custom attribute are parent surrogates.
Public property | IsParentSurrogateSpecified | Determines whether the IsParentSurrogate property has been set.
Top
Remarks

This aspect implements the IAggregatable interface, which exposes members such as VisitChildren(ChildVisitor, ChildVisitorOptions, Object) and Parent.

The AggregatableAttribute aspect is implicitly used by several other aspects, including all threading models.

When a class has the AggregatableAttribute aspect, its reference-type fields and automatic properties must be annotated with one of the following attributes: ChildAttribute, ReferenceAttribute or ParentAttribute.

Target classes can customize the AggregatableAttribute aspect by implementing one or many of the members documented in the AggregatableAttributeTargetClass class.

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


AggregatableAttribute Constructor

AggregatableAttribute Constructor
Initializes a new instance of the AggregatableAttribute class.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AggregatableAttribute()
Version Information

Supported in: 4.1

See Also

Reference

AggregatableAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableAttribute Methods

AggregatableAttribute Methods

The AggregatableAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | GetChildren | Gets the list of children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | GetDistinctChildren | Gets a list of distinct children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | IsDescendantOf | Determines whether a specified object is a descendant of a specified ancestor. (Defined by AggregatableExtensions.)
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Public Extension Method | VisitSelfAndDescendants | Executes a ChildVisitor for the a specified parent object and all its descendants. (Defined by AggregatableExtensions.)
Top
See Also

Reference

AggregatableAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableAttribute Properties

AggregatableAttribute Properties

The AggregatableAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | DefaultItemRelationship | Gets or sets the default kind of relationship for collection items.
Public property | DefaultMemberRelationship | Gets or sets the default kind of relationship of fields and automatic properties.
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | IsParentSurrogate | Determines whether instances of the target class of this custom attribute are parent surrogates.
Public property | IsParentSurrogateSpecified | Determines whether the IsParentSurrogate property has been set.
Top
See Also

Reference

AggregatableAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableAttribute.DefaultItemRelationship Property

AggregatableAttributeDefaultItemRelationship Property
Gets or sets the default kind of relationship for collection items.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RelationshipKind DefaultItemRelationship { get; set; }

Property Value

Type: RelationshipKind
Remarks

If the target class of the AggregatableAttribute aspect is a collection class, the DefaultItemRelationship property applies to items of this collection. Otherwise, the property applies to items of collection children. In this case, the value of this property can be overwritten by the ItemsRelationship property of the ChildAttribute custom attribute.

The default value of this property is Default, which is interpreted as Child.

Version Information

Supported in: 4.1

See Also

Reference

AggregatableAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableAttribute.DefaultMemberRelationship Property

AggregatableAttributeDefaultMemberRelationship Property
Gets or sets the default kind of relationship of fields and automatic properties.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RelationshipKind DefaultMemberRelationship { get; set; }

Property Value

Type: RelationshipKind
Remarks

The default value of this property is Default, which causes a build-time error to be emitted if members are not annotated with ChildAttribute, ReferenceAttribute or ParentAttribute.

Version Information

Supported in: 4.1

See Also

Reference

AggregatableAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableAttribute.IsParentSurrogate Property

AggregatableAttributeIsParentSurrogate Property
Determines whether instances of the target class of this custom attribute are parent surrogates.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsParentSurrogate { get; set; }

Property Value

Type: Boolean
Remarks

If this property is set, the IsParentSurrogate property of the ChildAttribute class cannot be used.

Version Information

Supported in: 4.1

See Also

Reference

AggregatableAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableAttribute.IsParentSurrogateSpecified Property

AggregatableAttributeIsParentSurrogateSpecified Property
Determines whether the IsParentSurrogate property has been set.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsParentSurrogateSpecified { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

AggregatableAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableAttributeTargetClass Class

AggregatableAttributeTargetClass Class
Describes the members that are introduced or overridden by the AggregatableAttribute aspect. You can define one or many of these members in classes that are the target of AggregatableAttribute to reacts to events of the Aggregatable pattern.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelAggregatableAttributeTargetClass
PostSharp.Patterns.ThreadingThreadAwareAttributeTargetClass

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class AggregatableAttributeTargetClass

The AggregatableAttributeTargetClass type exposes the following members.

Methods
 | Name | Description
Protected method | OnAncestorChanged | Method invoked when an ancestor of the current object has changed. Implement this method only if the target class of AggregatableAttribute implements the IAggregatable interface. For other use cases, subscribe to the AncestorChanged event.
Protected method | OnChildAttached | Method invoked when a child has been attached to the current object.
Protected method | OnChildDetached | Method invoked when a child has been detached from the current object.
Protected method | OnParentChanged | Method invoked when the Parent of the current object has been changed.
Public method | VisitChildren | Executes an action for all direct children of the current object. Implement this method in the target class of AggregatableAttribute if you want to provide children objects that are not managed by the AggregatableAttribute aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
Note Note
This class it for documentation purpose only, and should not be used in code.

Additionally to declaring the members documented in this class, target classes of the AggregatableAttribute can also implement the IAttachable interface, which adds Attach and Detach semantics to the IAggregatable class.

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


AggregatableAttributeTargetClass Methods

AggregatableAttributeTargetClass Methods

The AggregatableAttributeTargetClass type exposes the following members.

Methods
 | Name | Description
Protected method | OnAncestorChanged | Method invoked when an ancestor of the current object has changed. Implement this method only if the target class of AggregatableAttribute implements the IAggregatable interface. For other use cases, subscribe to the AncestorChanged event.
Protected method | OnChildAttached | Method invoked when a child has been attached to the current object.
Protected method | OnChildDetached | Method invoked when a child has been detached from the current object.
Protected method | OnParentChanged | Method invoked when the Parent of the current object has been changed.
Public method | VisitChildren | Executes an action for all direct children of the current object. Implement this method in the target class of AggregatableAttribute if you want to provide children objects that are not managed by the AggregatableAttribute aspect.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AggregatableAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


AggregatableAttributeTargetClass.OnAncestorChanged Method

AggregatableAttributeTargetClassOnAncestorChanged Method
Method invoked when an ancestor of the current object has changed. Implement this method only if the target class of AggregatableAttribute implements the IAggregatable interface. For other use cases, subscribe to the AncestorChanged event.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void OnAncestorChanged(
    AncestorChangedEventArgs args
)

Parameters

args
Type: PostSharp.Patterns.ModelAncestorChangedEventArgs
An instance of AncestorChangedEventArgs whose Child property indicates which object had its Parent modified, or null if this object is the current object.
Remarks

This method will be invoked only if there is at least one subscriber to the AncestorChanged event, unless the object whose Parent property has been modified is the current object.

The AggregatableAttribute aspect will not override this method if it already exists. However, it will use it to raise the AncestorChanged event.

This method should raise the AncestorChanged event. If args is null, a new instance of the AncestorChangedEventArgs class should be created, passing the current object as the constructor argument.

Version Information

Supported in: 4.1

See Also

Reference

AggregatableAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


AggregatableAttributeTargetClass.OnChildAttached Method

AggregatableAttributeTargetClassOnChildAttached Method
Method invoked when a child has been attached to the current object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void OnChildAttached(
    Object child,
    ChildInfo childInfo
)

Parameters

child
Type: SystemObject
The child that has just been attached to the current object.
childInfo
Type: PostSharp.Patterns.ModelChildInfo
Information about the location (field or collection item, typically) to which the child is assigned and about the relationship of the current node relatively to the parent node.
Remarks

If child is the child of the current object through several relationships, this method is only invoked after the first relationship has been set.

Version Information

Supported in: 4.1

See Also

Reference

AggregatableAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


AggregatableAttributeTargetClass.OnChildDetached Method

AggregatableAttributeTargetClassOnChildDetached Method
Method invoked when a child has been detached from the current object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void OnChildDetached(
    Object child,
    ChildInfo childInfo
)

Parameters

child
Type: SystemObject
The child that has just been detached from the current object.
childInfo
Type: PostSharp.Patterns.ModelChildInfo
Information about the location (field or collection item, typically) to which the child is assigned and about the relationship of the current node relatively to the parent node.
Remarks

If child is the child of the current object through several relationships, this method is only invoked after the last relationship has been unset.

Version Information

Supported in: 4.1

See Also

Reference

AggregatableAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


AggregatableAttributeTargetClass.OnParentChanged Method

AggregatableAttributeTargetClassOnParentChanged Method
Method invoked when the Parent of the current object has been changed.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void OnParentChanged()
Remarks

This method is invoked after all parent members (field and automatic properties annotated with the ParentAttribute custom attributes) have been set.

If the current object implements the IAggregatable interface, this method must raise the ParentChanged event.

Version Information

Supported in: 4.1

See Also

Reference

AggregatableAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


AggregatableAttributeTargetClass.VisitChildren Method

AggregatableAttributeTargetClassVisitChildren Method
Executes an action for all direct children of the current object. Implement this method in the target class of AggregatableAttribute if you want to provide children objects that are not managed by the AggregatableAttribute aspect.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual bool VisitChildren(
    ChildVisitor visitor,
    ChildVisitorOptions options
)

Parameters

visitor
Type: PostSharp.Patterns.ModelChildVisitor
The action to be executed for each child.
options
Type: PostSharp.Patterns.ModelChildVisitorOptions
Options. The default behavior is to enumerate all children, but ignore parent surrogates.

Return Value

Type: Boolean
false if visitor returned Stop, otherwise true.
Remarks

If this method is implemented in the target class, the AggregatableAttribute aspect will invoke this user implementation first, and only then invoke visitor for child managed by the AggregatableAttribute aspect.

Version Information

Supported in: 4.1

See Also

Reference

AggregatableAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


AggregatableClientAttribute Class

AggregatableClientAttribute Class
Base class for aspects that consume functionalities from the AggregatableAttribute aspect. This class provides functionalities to advise and unadvise children.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ModelDisposableAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class AggregatableClientAttribute : InstanceLevelAspect,
    IAspectProvider, IService, IAdviceProvider, IAspect

The AggregatableClientAttribute type exposes the following members.

Methods
 | Name | Description
Protected method | Advise | Injects the advice into the child object.
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Overrides TypeLevelAspectCompileTimeInitialize(Type, AspectInfo).)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from InstanceLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | IsEligibleChild | Determines if an object is eligible to be a child of the target instance of the current aspect.
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed.
Protected method | ProvideAspects |
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Protected property | AppliedToCurrentType | Determines if the current custom attribute instance has been applied to the type of the target instance. This value is false if the custom attribute has been applied to a base type.
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Protected property | IsInitialized | Determines whether the target instance is fully initialized, i.e. if all constructors have completed.
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


AggregatableClientAttribute Methods

AggregatableClientAttribute Methods

The AggregatableClientAttribute type exposes the following members.

Methods
 | Name | Description
Protected method | Advise | Injects the advice into the child object.
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Overrides TypeLevelAspectCompileTimeInitialize(Type, AspectInfo).)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from InstanceLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | IsEligibleChild | Determines if an object is eligible to be a child of the target instance of the current aspect.
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed.
Protected method | ProvideAspects |
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AggregatableClientAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableClientAttribute.Advise Method

AggregatableClientAttributeAdvise Method
Injects the advice into the child object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected abstract bool Advise(
    Object obj
)

Parameters

obj
Type: SystemObject

Return Value

Type: Boolean
true if the children of obj have to be advised as well, false otherwise.
Version Information

Supported in: 4.1

See Also

Reference

AggregatableClientAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableClientAttribute.CompileTimeInitialize Method

AggregatableClientAttributeCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void CompileTimeInitialize(
    Type type,
    AspectInfo aspectInfo
)

Parameters

type
Type: SystemType
Type to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.

Implements

ITypeLevelAspectBuildSemanticsCompileTimeInitialize(Type, AspectInfo)
Version Information

Supported in: 4.1

See Also

Reference

AggregatableClientAttribute Class
PostSharp.Patterns.Model Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


AggregatableClientAttribute.IsEligibleChild Method

AggregatableClientAttributeIsEligibleChild Method
Determines if an object is eligible to be a child of the target instance of the current aspect.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected abstract bool IsEligibleChild(
    Object child,
    ChildInfo childInfo
)

Parameters

child
Type: SystemObject
childInfo
Type: PostSharp.Patterns.ModelChildInfo

Return Value

Type: Boolean
true if child is eligible to be a child without injecting any advice, otherwise false. When this method returns false, the aspect will the invoke the Advise(Object) method.
Version Information

Supported in: 4.1

See Also

Reference

AggregatableClientAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableClientAttribute.OnInstanceConstructed Method

AggregatableClientAttributeOnInstanceConstructed Method
Executed when the target instance gets fully initialized, i.e. just after all constructors have completed.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnInstanceConstructed()
Version Information

Supported in: 4.1

See Also

Reference

AggregatableClientAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableClientAttribute.ProvideAspects Method

AggregatableClientAttributeProvideAspects Method

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual IEnumerable<AspectInstance> ProvideAspects(
    Type targetType
)

Parameters

targetType
Type: SystemType

Return Value

Type: IEnumerable AspectInstance
Version Information

Supported in: 4.1

See Also

Reference

AggregatableClientAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableClientAttribute Properties

AggregatableClientAttribute Properties

The AggregatableClientAttribute type exposes the following members.

Properties
 | Name | Description
Protected property | AppliedToCurrentType | Determines if the current custom attribute instance has been applied to the type of the target instance. This value is false if the custom attribute has been applied to a base type.
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Protected property | IsInitialized | Determines whether the target instance is fully initialized, i.e. if all constructors have completed.
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

AggregatableClientAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableClientAttribute.AppliedToCurrentType Property

AggregatableClientAttributeAppliedToCurrentType Property
Determines if the current custom attribute instance has been applied to the type of the target instance. This value is false if the custom attribute has been applied to a base type.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected bool AppliedToCurrentType { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

AggregatableClientAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableClientAttribute.IsInitialized Property

AggregatableClientAttributeIsInitialized Property
Determines whether the target instance is fully initialized, i.e. if all constructors have completed.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected bool IsInitialized { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

AggregatableClientAttribute Class
PostSharp.Patterns.Model Namespace


AggregatableExtensions Class

AggregatableExtensions Class
Provides extension methods to the IAggregatable interface.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelAggregatableExtensions

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class AggregatableExtensions

The AggregatableExtensions type exposes the following members.

Methods
Name | Description
GetChildren | Gets the list of children of a specified parent object.
GetDistinctChildren | Gets a list of distinct children of a specified parent object.
IsDescendantOf | Determines whether a specified object is a descendant of a specified ancestor.
VisitSelfAndDescendants | Executes a ChildVisitor for the a specified parent object and all its descendants.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


AggregatableExtensions Methods

AggregatableExtensions Methods

The AggregatableExtensions type exposes the following members.

Methods
Name | Description
GetChildren | Gets the list of children of a specified parent object.
GetDistinctChildren | Gets a list of distinct children of a specified parent object.
IsDescendantOf | Determines whether a specified object is a descendant of a specified ancestor.
VisitSelfAndDescendants | Executes a ChildVisitor for the a specified parent object and all its descendants.
Top
See Also

Reference

AggregatableExtensions Class
PostSharp.Patterns.Model Namespace


AggregatableExtensions.GetChildren Method

AggregatableExtensionsGetChildren Method
Gets the list of children of a specified parent object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static IList<Object> GetChildren(
    this IAggregatable parent,
    ChildVisitorOptions options = ChildVisitorOptions.None
)

Parameters

parent
Type: PostSharp.Patterns.ModelIAggregatable
The parent object.
options (Optional)
Type: PostSharp.Patterns.ModelChildVisitorOptions
Options.

Return Value

Type: IList Object
A list of children.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IAggregatable. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks

This list may contain duplicates if an object has several parent-child relationships to the same parent. Use GetDistinctChildren(IAggregatable, ChildVisitorOptions) to get a list of distinct children.

Version Information

Supported in: 4.1

See Also

Reference

AggregatableExtensions Class
PostSharp.Patterns.Model Namespace


AggregatableExtensions.GetDistinctChildren Method

AggregatableExtensionsGetDistinctChildren Method
Gets a list of distinct children of a specified parent object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static HashSet<Object> GetDistinctChildren(
    this IAggregatable parent,
    ChildVisitorOptions options = ChildVisitorOptions.None
)

Parameters

parent
Type: PostSharp.Patterns.ModelIAggregatable
The parent object.
options (Optional)
Type: PostSharp.Patterns.ModelChildVisitorOptions
Options.

Return Value

Type: HashSet Object

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IAggregatable. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Version Information

Supported in: 4.1

See Also

Reference

AggregatableExtensions Class
PostSharp.Patterns.Model Namespace


AggregatableExtensions.IsDescendantOf Method

AggregatableExtensionsIsDescendantOf Method
Determines whether a specified object is a descendant of a specified ancestor.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool IsDescendantOf(
    this IAggregatable child,
    Object ancestor
)

Parameters

child
Type: PostSharp.Patterns.ModelIAggregatable
The child object.
ancestor
Type: SystemObject
The ancestor object.

Return Value

Type: Boolean
true if child is a descendant of ancestor, otherwise false.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IAggregatable. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Version Information

Supported in: 4.1

See Also

Reference

AggregatableExtensions Class
PostSharp.Patterns.Model Namespace


AggregatableExtensions.VisitSelfAndDescendants Method

AggregatableExtensionsVisitSelfAndDescendants Method
Executes a ChildVisitor for the a specified parent object and all its descendants.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool VisitSelfAndDescendants(
    this IAggregatable parent,
    DescendantVisitor visitor,
    ChildVisitorOptions options = ChildVisitorOptions.None,
    Object state = null
)

Parameters

parent
Type: PostSharp.Patterns.ModelIAggregatable
The parent object.
visitor
Type: PostSharp.Patterns.ModelDescendantVisitor
The action to execute.
options (Optional)
Type: PostSharp.Patterns.ModelChildVisitorOptions
Options.
state (Optional)
Type: SystemObject

Return Value

Type: Boolean

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IAggregatable. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Version Information

Supported in: 4.1

See Also

Reference

AggregatableExtensions Class
PostSharp.Patterns.Model Namespace


AggregatableServices Class

AggregatableServices Class
Provide static methods to aid with implementation of the IAggregatable interface.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelAggregatableServices

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class AggregatableServices

The AggregatableServices type exposes the following members.

Methods
Name | Description
Advice | Injects the Aggregatable dynamic advice into an object.
Unadvise | Removes the Aggregatable advise from an object.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


AggregatableServices Methods

AggregatableServices Methods

The AggregatableServices type exposes the following members.

Methods
Name | Description
Advice | Injects the Aggregatable dynamic advice into an object.
Unadvise | Removes the Aggregatable advise from an object.
Top
See Also

Reference

AggregatableServices Class
PostSharp.Patterns.Model Namespace


AggregatableServices.Advice Method

AggregatableServicesAdvice Method
Injects the Aggregatable dynamic advice into an object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool Advice(
    Object obj,
    RelationshipInfo relationshipInfo,
    bool required = true
)

Parameters

obj
Type: SystemObject
The object into which the advice must be injected.
relationshipInfo
Type: PostSharp.Patterns.ModelRelationshipInfo
The description of the relationship of obj relatively to its parent.
required (Optional)
Type: SystemBoolean
true if an InvalidOperationException should be thrown in case obj cannot be dynamically advised, otherwise false.

Return Value

Type: Boolean
true if the Aggregatable advice was successfully injected into obj, false if obj already implemented the advice, or if obj cannot be dynamically advised and required is false.
Version Information

Supported in: 4.1

See Also

Reference

AggregatableServices Class
PostSharp.Patterns.Model Namespace


AggregatableServices.Unadvise Method

AggregatableServicesUnadvise Method
Removes the Aggregatable advise from an object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool Unadvise(
    Object obj
)

Parameters

obj
Type: SystemObject
An AdvisableCollectionT or AdvisableDictionaryTKey, TValue,

Return Value

Type: Boolean
true if the advice was removed from obj, false if obj did not have the Aggregatable advice.
Version Information

Supported in: 4.1

See Also

Reference

AggregatableServices Class
PostSharp.Patterns.Model Namespace


AncestorChangedEventArgs Class

AncestorChangedEventArgs Class
Arguments of the AncestorChanged event.
Inheritance Hierarchy
SystemObject
SystemEventArgs
PostSharp.Patterns.ModelAncestorChangedEventArgs

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AncestorChangedEventArgs : EventArgs

The AncestorChangedEventArgs type exposes the following members.

Constructors
 | Name | Description
Public method | AncestorChangedEventArgs | Initializes a new instance of the AncestorChangedEventArgs class.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Child | Gets the child object.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


AncestorChangedEventArgs Constructor

AncestorChangedEventArgs Constructor
Initializes a new instance of the AncestorChangedEventArgs class.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AncestorChangedEventArgs(
    Object child
)

Parameters

child
Type: SystemObject
The child object.
Version Information

Supported in: 4.1

See Also

Reference

AncestorChangedEventArgs Class
PostSharp.Patterns.Model Namespace


AncestorChangedEventArgs Methods

AncestorChangedEventArgs Methods

The AncestorChangedEventArgs type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AncestorChangedEventArgs Class
PostSharp.Patterns.Model Namespace


AncestorChangedEventArgs Properties

AncestorChangedEventArgs Properties

The AncestorChangedEventArgs type exposes the following members.

Properties
 | Name | Description
Public property | Child | Gets the child object.
Top
See Also

Reference

AncestorChangedEventArgs Class
PostSharp.Patterns.Model Namespace


AncestorChangedEventArgs.Child Property

AncestorChangedEventArgsChild Property
Gets the child object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Child { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1

See Also

Reference

AncestorChangedEventArgs Class
PostSharp.Patterns.Model Namespace


ChildAttribute Class

ChildAttribute Class
Custom attribute that, when applied to a field or automatic property, specifies that the object assigned to this field or property is a child of the instance of the declaring type.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Patterns.ModelMemberRelationshipAttribute
PostSharp.Patterns.ModelChildAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ChildAttribute : MemberRelationshipAttribute

The ChildAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ChildAttribute | Initializes a new instance of the ChildAttribute class.
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MemberRelationshipAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | DisableBehaviorPropagation | Determines whether the behaviors applied to the declaring type of the target field should be applied to the object assigned this field. The default value of this property is false, which means that behaviors such as Recordable or threading models will be applied to children (resulting in build- or run-time exception if it is not possible). When it is set to true, behaviors will not be propagated. When applied to a field of collection type, the value applies to collection items.
Public property | DisableBuildTimeValidation | Determines whether the type of the target field or property should be validated at build-time against the rules of aspects that rely on the Aggregatable model, such as the Recordable aspect or the threading model aspects. If this property is set to true, validation will be performed at runtime only.
Public property | IsParentSurrogate | Determines whether the value assigned to the field or property is a parent surrogate. The Parent property of children of a parent surrogate are set to the parent of the parent surrogate, instead of to the field itself.
Public property | ItemsRelationship | Determines the kind of relationship between items
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace
PostSharp.Patterns.ModelReferenceAttribute
PostSharp.Patterns.ModelParentAttribute
PostSharp.Patterns.ModelAggregatableAttribute


ChildAttribute Constructor

ChildAttribute Constructor
Initializes a new instance of the ChildAttribute class.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ChildAttribute()
Version Information

Supported in: 4.1

See Also

Reference

ChildAttribute Class
PostSharp.Patterns.Model Namespace


ChildAttribute Methods

ChildAttribute Methods

The ChildAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MemberRelationshipAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ChildAttribute Class
PostSharp.Patterns.Model Namespace


ChildAttribute Properties

ChildAttribute Properties

The ChildAttribute type exposes the following members.

Properties
 | Name | Description
Public property | DisableBehaviorPropagation | Determines whether the behaviors applied to the declaring type of the target field should be applied to the object assigned this field. The default value of this property is false, which means that behaviors such as Recordable or threading models will be applied to children (resulting in build- or run-time exception if it is not possible). When it is set to true, behaviors will not be propagated. When applied to a field of collection type, the value applies to collection items.
Public property | DisableBuildTimeValidation | Determines whether the type of the target field or property should be validated at build-time against the rules of aspects that rely on the Aggregatable model, such as the Recordable aspect or the threading model aspects. If this property is set to true, validation will be performed at runtime only.
Public property | IsParentSurrogate | Determines whether the value assigned to the field or property is a parent surrogate. The Parent property of children of a parent surrogate are set to the parent of the parent surrogate, instead of to the field itself.
Public property | ItemsRelationship | Determines the kind of relationship between items
Top
See Also

Reference

ChildAttribute Class
PostSharp.Patterns.Model Namespace


ChildAttribute.DisableBehaviorPropagation Property

ChildAttributeDisableBehaviorPropagation Property
Determines whether the behaviors applied to the declaring type of the target field should be applied to the object assigned this field. The default value of this property is false, which means that behaviors such as Recordable or threading models will be applied to children (resulting in build- or run-time exception if it is not possible). When it is set to true, behaviors will not be propagated. When applied to a field of collection type, the value applies to collection items.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool DisableBehaviorPropagation { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

ChildAttribute Class
PostSharp.Patterns.Model Namespace


ChildAttribute.DisableBuildTimeValidation Property

ChildAttributeDisableBuildTimeValidation Property
Determines whether the type of the target field or property should be validated at build-time against the rules of aspects that rely on the Aggregatable model, such as the Recordable aspect or the threading model aspects. If this property is set to true, validation will be performed at runtime only.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool DisableBuildTimeValidation { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

ChildAttribute Class
PostSharp.Patterns.Model Namespace


ChildAttribute.IsParentSurrogate Property

ChildAttributeIsParentSurrogate Property
Determines whether the value assigned to the field or property is a parent surrogate. The Parent property of children of a parent surrogate are set to the parent of the parent surrogate, instead of to the field itself.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsParentSurrogate { get; set; }

Property Value

Type: Boolean
Remarks

When an item is attached to a parent surrogate, the Parent property of the item is set to the Parent of the parent surrogate, instead of the parent surrogate itself. Collections are typical examples of a parent surrogate, because the parent of collection items need to be the owner of the collection and not the collection itself.

The default value of this field is true for collections, and false otherwise.

Version Information

Supported in: 4.1

See Also

Reference

ChildAttribute Class
PostSharp.Patterns.Model Namespace


ChildAttribute.ItemsRelationship Property

ChildAttributeItemsRelationship Property
Determines the kind of relationship between items

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RelationshipKind ItemsRelationship { get; set; }

Property Value

Type: RelationshipKind
Version Information

Supported in: 4.1

See Also

Reference

ChildAttribute Class
PostSharp.Patterns.Model Namespace


ChildInfo Class

ChildInfo Class
Describes a location (typically a field or collection item) on which a child can be attached to a parent.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelChildInfo

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ChildInfo

The ChildInfo type exposes the following members.

Constructors
 | Name | Description
Public method | ChildInfo(FieldInfo, RelationshipInfo) | Initializes a new instance of the ChildInfo that represents a field.
Public method | ChildInfo(String, Type, RelationshipInfo) | Initializes a new instance of the ChildInfo that represents a collection item or a custom location.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the field where the child is stored, or Null if the current ChildInfo does not represent a field.
Public property | LocationName | Gets the name of the location to which the child is assigned.
Public property | LocationType | Gets the type of the location to which the child is assigned.
Public property | RelationshipInfo | Describes the kind of relationship between the child and its parent.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


ChildInfo Constructor

ChildInfo Constructor
Overload List
 | Name | Description
Public method | ChildInfo(FieldInfo, RelationshipInfo) | Initializes a new instance of the ChildInfo that represents a field.
Public method | ChildInfo(String, Type, RelationshipInfo) | Initializes a new instance of the ChildInfo that represents a collection item or a custom location.
Top
See Also

Reference

ChildInfo Class
PostSharp.Patterns.Model Namespace


ChildInfo Constructor (FieldInfo, RelationshipInfo)

ChildInfo Constructor (FieldInfo, RelationshipInfo)
Initializes a new instance of the ChildInfo that represents a field.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ChildInfo(
    FieldInfo field,
    RelationshipInfo relationshipInfo
)

Parameters

field
Type: System.ReflectionFieldInfo
A field.
relationshipInfo
Type: PostSharp.Patterns.ModelRelationshipInfo
A RelationshipInfo instance that describes the kind of relationship of the child object to its direct parent.
Version Information

Supported in: 4.1

See Also

Reference

ChildInfo Class
ChildInfo Overload
PostSharp.Patterns.Model Namespace


ChildInfo Constructor (String, Type, RelationshipInfo)

ChildInfo Constructor (String, Type, RelationshipInfo)
Initializes a new instance of the ChildInfo that represents a collection item or a custom location.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ChildInfo(
    string locationName,
    Type locationType,
    RelationshipInfo relationshipInfo
)

Parameters

locationName
Type: SystemString
Name of the location, for instance Item for a collection item.
locationType
Type: SystemType
Type of the location.
relationshipInfo
Type: PostSharp.Patterns.ModelRelationshipInfo
A RelationshipInfo instance that describes the kind of relationship of the child object to its direct parent.
Version Information

Supported in: 4.1

See Also

Reference

ChildInfo Class
ChildInfo Overload
PostSharp.Patterns.Model Namespace


ChildInfo Methods

ChildInfo Methods

The ChildInfo type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ChildInfo Class
PostSharp.Patterns.Model Namespace


ChildInfo Properties

ChildInfo Properties

The ChildInfo type exposes the following members.

Properties
 | Name | Description
Public property | DeclarationIdentifier | Gets the DeclarationIdentifier of the field where the child is stored, or Null if the current ChildInfo does not represent a field.
Public property | LocationName | Gets the name of the location to which the child is assigned.
Public property | LocationType | Gets the type of the location to which the child is assigned.
Public property | RelationshipInfo | Describes the kind of relationship between the child and its parent.
Top
See Also

Reference

ChildInfo Class
PostSharp.Patterns.Model Namespace


ChildInfo.DeclarationIdentifier Property

ChildInfoDeclarationIdentifier Property
Gets the DeclarationIdentifier of the field where the child is stored, or Null if the current ChildInfo does not represent a field.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeclarationIdentifier DeclarationIdentifier { get; }

Property Value

Type: DeclarationIdentifier
Version Information

Supported in: 4.1

See Also

Reference

ChildInfo Class
PostSharp.Patterns.Model Namespace


ChildInfo.LocationName Property

ChildInfoLocationName Property
Gets the name of the location to which the child is assigned.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string LocationName { get; }

Property Value

Type: String
Remarks

This property should be only used to generate texts of error messages for developers (such as exceptions). It is not meant as a mechanism to uniquely identify the location (use DeclarationIdentifier for this purpose) or to generate messages for the end-user.

Version Information

Supported in: 4.1

See Also

Reference

ChildInfo Class
PostSharp.Patterns.Model Namespace


ChildInfo.LocationType Property

ChildInfoLocationType Property
Gets the type of the location to which the child is assigned.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type LocationType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1

See Also

Reference

ChildInfo Class
PostSharp.Patterns.Model Namespace


ChildInfo.RelationshipInfo Property

ChildInfoRelationshipInfo Property
Describes the kind of relationship between the child and its parent.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RelationshipInfo RelationshipInfo { get; }

Property Value

Type: RelationshipInfo
Version Information

Supported in: 4.1

See Also

Reference

ChildInfo Class
PostSharp.Patterns.Model Namespace


ChildVisitor Delegate

ChildVisitor Delegate
Encapsulates a method that is invoked by the VisitChildren(ChildVisitor, ChildVisitorOptions, Object) method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public delegate bool ChildVisitor(
    Object child,
    ChildInfo childInfo,
    Object state
)

Parameters

child
Type: SystemObject
The object being visited.
childInfo
Type: PostSharp.Patterns.ModelChildInfo
Describes the field or other location to which the child is assigned.
state
Type: SystemObject

Return Value

Type: Boolean
true to instruct the VisitChildren(ChildVisitor, ChildVisitorOptions, Object) implementation to continue enumerating other children, false to instruct the VisitChildren(ChildVisitor, ChildVisitorOptions, Object) implementation to immediately return the false value without enumerating other children.
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


ChildVisitorOptions Enumeration

ChildVisitorOptions Enumeration
Options for the VisitChildren(ChildVisitor, ChildVisitorOptions, Object) and VisitSelfAndDescendants(IAggregatable, DescendantVisitor, ChildVisitorOptions, Object) methods.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[FlagsAttribute]
public enum ChildVisitorOptions
Members
Member name | Value | Description
None | 0 | Enumerates all children, but ignore parent surrogates.
IncludeParentSurrogates | 1 | Include parent surrogates.
ExcludeIndirectChildren | 2 | Exclude children of parent surrogates.
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


Depends Class

Depends Class
Provides a way to specify dependencies of a method to properties or chains of properties. This class should be used from methods marked with the SafeForDependencyAnalysisAttribute custom attribute.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelDepends

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class Depends

The Depends type exposes the following members.

Methods
Name | Description
On(Object) | Specifies an explicit dependency between the calling method and the argument passed to this method.
On(Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
Top
Fields
Name | Description
Guard | A Boolean value that is always false.
Top
Remarks

Members of this class are considered metadata-only. They are used only at build time, where their arguments are decompiled. They have no runtime effect. For performance reason, it is preferable to skip their runtime execution. This can be achieved by using the Guard field in the construct:

Copy
if ( Depends.Guard )
{
  Depends.On(this.foo.Bar);
}
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Model Namespace


Depends Fields

Depends Fields

The Depends type exposes the following members.

Fields
Name | Description
Guard | A Boolean value that is always false.
Top
See Also

Reference

Depends Class
PostSharp.Patterns.Model Namespace


Depends.Guard Field

DependsGuard Field
A Boolean value that is always false.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly bool Guard

Field Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
PostSharp.Patterns.Model Namespace


Depends Methods

Depends Methods
Methods
Name | Description
On(Object) | Specifies an explicit dependency between the calling method and the argument passed to this method.
On(Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
Top
See Also

Reference

Depends Class
PostSharp.Patterns.Model Namespace


Depends.On Method

DependsOn Method
Overload List
Name | Description
On(Object) | Specifies an explicit dependency between the calling method and the argument passed to this method.
On(Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
On(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object) | Specifies an explicit dependency between the calling method and the arguments passed to this method.
Top
See Also

Reference

Depends Class
PostSharp.Patterns.Model Namespace


Depends.On Method (Object)

DependsOn Method (Object)
Specifies an explicit dependency between the calling method and the argument passed to this method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void On(
    Object dependency1
)

Parameters

dependency1
Type: SystemObject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
On Overload
PostSharp.Patterns.Model Namespace


Depends.On Method (Object, Object)

DependsOn Method (Object, Object)
Specifies an explicit dependency between the calling method and the arguments passed to this method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void On(
    Object dependency1,
    Object dependency2
)

Parameters

dependency1
Type: SystemObject
dependency2
Type: SystemObject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
On Overload
PostSharp.Patterns.Model Namespace


Depends.On Method (Object, Object, Object)

DependsOn Method (Object, Object, Object)
Specifies an explicit dependency between the calling method and the arguments passed to this method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void On(
    Object dependency1,
    Object dependency2,
    Object dependency3
)

Parameters

dependency1
Type: SystemObject
dependency2
Type: SystemObject
dependency3
Type: SystemObject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
On Overload
PostSharp.Patterns.Model Namespace


Depends.On Method (Object, Object, Object, Object)

DependsOn Method (Object, Object, Object, Object)
Specifies an explicit dependency between the calling method and the arguments passed to this method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void On(
    Object dependency1,
    Object dependency2,
    Object dependency3,
    Object dependency4
)

Parameters

dependency1
Type: SystemObject
dependency2
Type: SystemObject
dependency3
Type: SystemObject
dependency4
Type: SystemObject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
On Overload
PostSharp.Patterns.Model Namespace


Depends.On Method (Object, Object, Object, Object, Object)

DependsOn Method (Object, Object, Object, Object, Object)
Specifies an explicit dependency between the calling method and the arguments passed to this method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void On(
    Object dependency1,
    Object dependency2,
    Object dependency3,
    Object dependency4,
    Object dependency5
)

Parameters

dependency1
Type: SystemObject
dependency2
Type: SystemObject
dependency3
Type: SystemObject
dependency4
Type: SystemObject
dependency5
Type: SystemObject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
On Overload
PostSharp.Patterns.Model Namespace


Depends.On Method (Object, Object, Object, Object, Object, Object)

DependsOn Method (Object, Object, Object, Object, Object, Object)
Specifies an explicit dependency between the calling method and the arguments passed to this method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void On(
    Object dependency1,
    Object dependency2,
    Object dependency3,
    Object dependency4,
    Object dependency5,
    Object dependency6
)

Parameters

dependency1
Type: SystemObject
dependency2
Type: SystemObject
dependency3
Type: SystemObject
dependency4
Type: SystemObject
dependency5
Type: SystemObject
dependency6
Type: SystemObject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
On Overload
PostSharp.Patterns.Model Namespace


Depends.On Method (Object, Object, Object, Object, Object, Object, Object)

DependsOn Method (Object, Object, Object, Object, Object, Object, Object)
Specifies an explicit dependency between the calling method and the arguments passed to this method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void On(
    Object dependency1,
    Object dependency2,
    Object dependency3,
    Object dependency4,
    Object dependency5,
    Object dependency6,
    Object dependency7
)

Parameters

dependency1
Type: SystemObject
dependency2
Type: SystemObject
dependency3
Type: SystemObject
dependency4
Type: SystemObject
dependency5
Type: SystemObject
dependency6
Type: SystemObject
dependency7
Type: SystemObject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
On Overload
PostSharp.Patterns.Model Namespace


Depends.On Method (Object, Object, Object, Object, Object, Object, Object, Object)

DependsOn Method (Object, Object, Object, Object, Object, Object, Object, Object)
Specifies an explicit dependency between the calling method and the arguments passed to this method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void On(
    Object dependency1,
    Object dependency2,
    Object dependency3,
    Object dependency4,
    Object dependency5,
    Object dependency6,
    Object dependency7,
    Object dependency8
)

Parameters

dependency1
Type: SystemObject
dependency2
Type: SystemObject
dependency3
Type: SystemObject
dependency4
Type: SystemObject
dependency5
Type: SystemObject
dependency6
Type: SystemObject
dependency7
Type: SystemObject
dependency8
Type: SystemObject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
On Overload
PostSharp.Patterns.Model Namespace


Depends.On Method (Object, Object, Object, Object, Object, Object, Object, Object, Object)

DependsOn Method (Object, Object, Object, Object, Object, Object, Object, Object, Object)
Specifies an explicit dependency between the calling method and the arguments passed to this method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void On(
    Object dependency1,
    Object dependency2,
    Object dependency3,
    Object dependency4,
    Object dependency5,
    Object dependency6,
    Object dependency7,
    Object dependency8,
    Object dependency9
)

Parameters

dependency1
Type: SystemObject
dependency2
Type: SystemObject
dependency3
Type: SystemObject
dependency4
Type: SystemObject
dependency5
Type: SystemObject
dependency6
Type: SystemObject
dependency7
Type: SystemObject
dependency8
Type: SystemObject
dependency9
Type: SystemObject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
On Overload
PostSharp.Patterns.Model Namespace


Depends.On Method (Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)

DependsOn Method (Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)
Specifies an explicit dependency between the calling method and the arguments passed to this method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void On(
    Object dependency1,
    Object dependency2,
    Object dependency3,
    Object dependency4,
    Object dependency5,
    Object dependency6,
    Object dependency7,
    Object dependency8,
    Object dependency9,
    Object dependency10
)

Parameters

dependency1
Type: SystemObject
dependency2
Type: SystemObject
dependency3
Type: SystemObject
dependency4
Type: SystemObject
dependency5
Type: SystemObject
dependency6
Type: SystemObject
dependency7
Type: SystemObject
dependency8
Type: SystemObject
dependency9
Type: SystemObject
dependency10
Type: SystemObject
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Depends Class
On Overload
PostSharp.Patterns.Model Namespace


DescendantVisitor Delegate

DescendantVisitor Delegate
Encapsulates a method that is invoked by the VisitSelfAndDescendants(IAggregatable, DescendantVisitor, ChildVisitorOptions, Object) method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public delegate DescendantVisitorStatus DescendantVisitor(
    Object descendant,
    ChildInfo childInfo,
    Object state
)

Parameters

descendant
Type: SystemObject
The object being visited.
childInfo
Type: PostSharp.Patterns.ModelChildInfo
Describes the field or other location to which the child is assigned.
state
Type: SystemObject

Return Value

Type: DescendantVisitorStatus
A value that determines how the visitor should continue enumerating other objects.
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


DescendantVisitorStatus Enumeration

DescendantVisitorStatus Enumeration
Type of the return value of ChildVisitor. Determines how the visitor should continue enumerating other objects.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum DescendantVisitorStatus
Members
Member name | Value | Description
Default | 0 | Equivalent to ContinueWithChildren for VisitSelfAndDescendants(IAggregatable, DescendantVisitor, ChildVisitorOptions, Object) or ContinueWithSiblings for VisitChildren(ChildVisitor, ChildVisitorOptions, Object).
Stop | 1 | Immediately stops enumeration and returns to the caller.
ContinueWithChildren | 2 | Continues enumerating the children of the current node, then the sibling nodes. This value is not supported by the VisitChildren(ChildVisitor, ChildVisitorOptions, Object) method.
ContinueWithSiblings | 3 | Continues enumerating the siblings of the current node, but do not enumerate the children nodes.
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


DisposableAttribute Class

DisposableAttribute Class
Custom attribute that, when applied to a class, implements the IDisposable in such a way that the Dispose method executes the Dispose method for all children objects that also implement the IDisposable interface.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ModelDisposableAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class DisposableAttribute : AggregatableClientAttribute,
    IDisposable

The DisposableAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | DisposableAttribute | Initializes a new instance of the DisposableAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | Dispose(Boolean) | Releases the unmanaged resources used by the DisposableAttribute and optionally releases the managed resources
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | ThrowObjectDisposedException | Determines whether an ObjectDisposedException should be thrown when an attempt is made to access an object that has already been disposed.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Model Namespace


DisposableAttribute Constructor

DisposableAttribute Constructor
Initializes a new instance of the DisposableAttribute class

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DisposableAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DisposableAttribute Class
PostSharp.Patterns.Model Namespace


DisposableAttribute Methods

DisposableAttribute Methods

The DisposableAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | Dispose(Boolean) |
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DisposableAttribute Class
PostSharp.Patterns.Model Namespace


DisposableAttribute.Dispose Method

DisposableAttributeDispose Method
Overload List
 | Name | Description
Public method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public method | Dispose(Boolean) | Releases the unmanaged resources used by the DisposableAttribute and optionally releases the managed resources
Top
See Also

Reference

DisposableAttribute Class
PostSharp.Patterns.Model Namespace


DisposableAttribute.Dispose Method

DisposableAttributeDispose Method
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Dispose()

Implements

IDisposableDispose
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DisposableAttribute Class
Dispose Overload
PostSharp.Patterns.Model Namespace


DisposableAttribute.Dispose Method (Boolean)

DisposableAttributeDispose Method (Boolean)
Releases the unmanaged resources used by the DisposableAttribute and optionally releases the managed resources

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Dispose(
    bool disposing
)

Parameters

disposing
Type: SystemBoolean
True to release both managed and unmanaged resources; false to release only unmanaged resources
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DisposableAttribute Class
Dispose Overload
PostSharp.Patterns.Model Namespace


DisposableAttribute Properties

DisposableAttribute Properties

The DisposableAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | ThrowObjectDisposedException | Determines whether an ObjectDisposedException should be thrown when an attempt is made to access an object that has already been disposed.
Top
See Also

Reference

DisposableAttribute Class
PostSharp.Patterns.Model Namespace


DisposableAttribute.ThrowObjectDisposedException Property

DisposableAttributeThrowObjectDisposedException Property
Determines whether an ObjectDisposedException should be thrown when an attempt is made to access an object that has already been disposed.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool ThrowObjectDisposedException { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DisposableAttribute Class
PostSharp.Patterns.Model Namespace


DynamicallyAdvisableObject Class

DynamicallyAdvisableObject Class
Base class for objects into which advices can be dynamically injected. This class is not meant to be used in user code.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelDynamicallyAdvisableObject
PostSharp.Patterns.CollectionsAdvisableCollectionT
PostSharp.Patterns.CollectionsAdvisableDictionaryTKey, TValue

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class DynamicallyAdvisableObject : IDynamicallyAdvisable,
    IQueryInterface, ISerializable, IDeserializationCallback

The DynamicallyAdvisableObject type exposes the following members.

Methods
 | Name | Description
Public method | GetObjectData | Populates a SerializationInfo with the data needed to serialize the target object.
Public method | OnDeserialization | Runs when the entire object graph has been deserialized.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


DynamicallyAdvisableObject Methods

DynamicallyAdvisableObject Methods

The DynamicallyAdvisableObject type exposes the following members.

Methods
 | Name | Description
Public method | GetObjectData | Populates a SerializationInfo with the data needed to serialize the target object.
Public method | OnDeserialization | Runs when the entire object graph has been deserialized.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DynamicallyAdvisableObject Class
PostSharp.Patterns.Model Namespace


DynamicallyAdvisableObject.GetObjectData Method

DynamicallyAdvisableObjectGetObjectData Method
Populates a SerializationInfo with the data needed to serialize the target object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void GetObjectData(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
The SerializationInfo to populate with data.
context
Type: System.Runtime.SerializationStreamingContext
The destination (see StreamingContext) for this serialization.

Implements

ISerializableGetObjectData(SerializationInfo, StreamingContext)
Exceptions
Exception | Condition
SecurityException | The caller does not have the required permission.
Version Information

Supported in: 4.1

See Also

Reference

DynamicallyAdvisableObject Class
PostSharp.Patterns.Model Namespace


DynamicallyAdvisableObject.OnDeserialization Method

DynamicallyAdvisableObjectOnDeserialization Method
Runs when the entire object graph has been deserialized.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void OnDeserialization(
    Object sender
)

Parameters

sender
Type: SystemObject
The object that initiated the callback. The functionality for this parameter is not currently implemented.

Implements

IDeserializationCallbackOnDeserialization(Object)
Version Information

Supported in: 4.1

See Also

Reference

DynamicallyAdvisableObject Class
PostSharp.Patterns.Model Namespace


IAggregatable Interface

IAggregatable Interface
Defines members (principally Parent and VisitChildren(ChildVisitor, ChildVisitorOptions, Object)) that allow to consume parent-child relationships in an object tree.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAggregatable

The IAggregatable type exposes the following members.

Methods
 | Name | Description
Public method | VisitChildren | Executes an action for all direct children of the current object.
Top
Extension Methods
 | Name | Description
Public Extension Method | GetChildren | Gets the list of children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | GetDistinctChildren | Gets a list of distinct children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | IsDescendantOf | Determines whether a specified object is a descendant of a specified ancestor. (Defined by AggregatableExtensions.)
Public Extension Method | VisitSelfAndDescendants | Executes a ChildVisitor for the a specified parent object and all its descendants. (Defined by AggregatableExtensions.)
Top
Properties
 | Name | Description
Public property | Parent | Gets the parent of the current object.
Public property | ParentRelationship | Describes the relationship between the current object and its parent. Valid values are Child or ParentSurrogate.
Top
Events
 | Name | Description
Public event | AncestorChanged | Occurs when any ancestor changes. An ancestor is the parent of the current object or the parent of an ancestor of the current object.
Public event | ParentChanged | Occurs when the Parent property changes.
Top
Remarks

If a class implements this interface, it must also implement IAttachable. These two interfaces have been separated for clarity, since IAttachable should normally not be consumed from user code.

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


IAggregatable Methods

IAggregatable Methods

The IAggregatable type exposes the following members.

Methods
 | Name | Description
Public method | VisitChildren | Executes an action for all direct children of the current object.
Top
Extension Methods
 | Name | Description
Public Extension Method | GetChildren | Gets the list of children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | GetDistinctChildren | Gets a list of distinct children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | IsDescendantOf | Determines whether a specified object is a descendant of a specified ancestor. (Defined by AggregatableExtensions.)
Public Extension Method | VisitSelfAndDescendants | Executes a ChildVisitor for the a specified parent object and all its descendants. (Defined by AggregatableExtensions.)
Top
See Also

Reference

IAggregatable Interface
PostSharp.Patterns.Model Namespace


IAggregatable.VisitChildren Method

IAggregatableVisitChildren Method
Executes an action for all direct children of the current object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool VisitChildren(
    ChildVisitor visitor,
    ChildVisitorOptions options = ChildVisitorOptions.None,
    Object state = null
)

Parameters

visitor
Type: PostSharp.Patterns.ModelChildVisitor
The action to be executed for each child.
options (Optional)
Type: PostSharp.Patterns.ModelChildVisitorOptions
Options. The default behavior is to enumerate all children, but ignore parent surrogates.
state (Optional)
Type: SystemObject

Return Value

Type: Boolean
false if visitor returned Stop, otherwise true.
Remarks
Note Note
If a parent is bound to a child through several relationships (for instance several fields), the visitor delegate will be invoked several times, once for each relationship. Store visited children into a HashSetT if you need to perform an action only once per child.
Version Information

Supported in: 4.1

See Also

Reference

IAggregatable Interface
PostSharp.Patterns.Model Namespace


IAggregatable Properties

IAggregatable Properties

The IAggregatable type exposes the following members.

Properties
 | Name | Description
Public property | Parent | Gets the parent of the current object.
Public property | ParentRelationship | Describes the relationship between the current object and its parent. Valid values are Child or ParentSurrogate.
Top
See Also

Reference

IAggregatable Interface
PostSharp.Patterns.Model Namespace


IAggregatable.Parent Property

IAggregatableParent Property
Gets the parent of the current object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object Parent { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1

See Also

Reference

IAggregatable Interface
PostSharp.Patterns.Model Namespace


IAggregatable.ParentRelationship Property

IAggregatableParentRelationship Property
Describes the relationship between the current object and its parent. Valid values are Child or ParentSurrogate.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
RelationshipKind ParentRelationship { get; }

Property Value

Type: RelationshipKind
Version Information

Supported in: 4.1

See Also

Reference

IAggregatable Interface
PostSharp.Patterns.Model Namespace


IAggregatable Events

IAggregatable Events

The IAggregatable type exposes the following members.

Events
 | Name | Description
Public event | AncestorChanged | Occurs when any ancestor changes. An ancestor is the parent of the current object or the parent of an ancestor of the current object.
Public event | ParentChanged | Occurs when the Parent property changes.
Top
See Also

Reference

IAggregatable Interface
PostSharp.Patterns.Model Namespace


IAggregatable.AncestorChanged Event

IAggregatableAncestorChanged Event
Occurs when any ancestor changes. An ancestor is the parent of the current object or the parent of an ancestor of the current object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
event EventHandler<AncestorChangedEventArgs> AncestorChanged

Value

Type: SystemEventHandler AncestorChangedEventArgs
Remarks

The sender parameter of the event handler will be set to the current object. The Child property of the AncestorChangedEventArgs object will be set to the object whose Parent actually changed. To retrieve the new ancestor, use args.Child.QueryInterface<IAggregatable>.Parent

Version Information

Supported in: 4.1

See Also

Reference

IAggregatable Interface
PostSharp.Patterns.Model Namespace


IAggregatable.ParentChanged Event

IAggregatableParentChanged Event
Occurs when the Parent property changes.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
event EventHandler ParentChanged

Value

Type: SystemEventHandler
Version Information

Supported in: 4.1

See Also

Reference

IAggregatable Interface
PostSharp.Patterns.Model Namespace


IAttachable Interface

IAttachable Interface
Defines setter methods for the IAggregatable.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAttachable : IAggregatable

The IAttachable type exposes the following members.

Methods
 | Name | Description
Public method | AttachToParent | Attaches the current object to a parent object.
Public method | DetachFromParent | Detaches the current object from its parent object.
Public method | VisitChildren | Executes an action for all direct children of the current object. (Inherited from IAggregatable.)
Top
Extension Methods
 | Name | Description
Public Extension Method | GetChildren | Gets the list of children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | GetDistinctChildren | Gets a list of distinct children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | IsDescendantOf | Determines whether a specified object is a descendant of a specified ancestor. (Defined by AggregatableExtensions.)
Public Extension Method | VisitSelfAndDescendants | Executes a ChildVisitor for the a specified parent object and all its descendants. (Defined by AggregatableExtensions.)
Top
Properties
 | Name | Description
Public property | Parent | Gets the parent of the current object. (Inherited from IAggregatable.)
Public property | ParentRelationship | Describes the relationship between the current object and its parent. Valid values are Child or ParentSurrogate. (Inherited from IAggregatable.)
Top
Events
 | Name | Description
Public event | AncestorChanged | Occurs when any ancestor changes. An ancestor is the parent of the current object or the parent of an ancestor of the current object. (Inherited from IAggregatable.)
Public event | ParentChanged | Occurs when the Parent property changes. (Inherited from IAggregatable.)
Top
Remarks

This interface is consumed by the AggregatableAttribute aspect. It should normally not be consumed in user code.

User classes may implement this interface in a class if a custom implementation of IAggregatable is required.

A child object may be attached several times to the same parent through several relationships.

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


IAttachable Methods

IAttachable Methods

The IAttachable type exposes the following members.

Methods
 | Name | Description
Public method | AttachToParent | Attaches the current object to a parent object.
Public method | DetachFromParent | Detaches the current object from its parent object.
Public method | VisitChildren | Executes an action for all direct children of the current object. (Inherited from IAggregatable.)
Top
Extension Methods
 | Name | Description
Public Extension Method | GetChildren | Gets the list of children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | GetDistinctChildren | Gets a list of distinct children of a specified parent object. (Defined by AggregatableExtensions.)
Public Extension Method | IsDescendantOf | Determines whether a specified object is a descendant of a specified ancestor. (Defined by AggregatableExtensions.)
Public Extension Method | VisitSelfAndDescendants | Executes a ChildVisitor for the a specified parent object and all its descendants. (Defined by AggregatableExtensions.)
Top
See Also

Reference

IAttachable Interface
PostSharp.Patterns.Model Namespace


IAttachable.AttachToParent Method

IAttachableAttachToParent Method
Attaches the current object to a parent object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool AttachToParent(
    RelationshipInfo relationshipInfo,
    IAttacher attacher,
    Object attacherState
)

Parameters

relationshipInfo
Type: PostSharp.Patterns.ModelRelationshipInfo
Information about the relationship of the parent node relatively to the current node. The Relationship property must be set to Child or ParentSurrogate.
attacher
Type: PostSharp.Patterns.ModelIAttacher
A service that allows the current node to attach itself to the parent.
attacherState
Type: SystemObject
An opaque state object to be passed as the first argument to all methods of the IAttacher interface.

Return Value

Type: Boolean
true if the current object was not previously attached to any parent, false if it was already attached to the same parent.
Remarks

In case a child is attached to its parent through several relationships, all relationships should have the same characteristics, i.e. their RelationshipInfo value should be identical.

Version Information

Supported in: 4.1

See Also

Reference

IAttachable Interface
PostSharp.Patterns.Model Namespace


IAttachable.DetachFromParent Method

IAttachableDetachFromParent Method
Detaches the current object from its parent object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool DetachFromParent()

Return Value

Type: Boolean
true if the current object has been fully detached, i.e. is no longer attached to its parent by any other relationship, or false if the current object is still attached to the parent by some relationship.
Version Information

Supported in: 4.1

See Also

Reference

IAttachable Interface
PostSharp.Patterns.Model Namespace


IAttachable Properties

IAttachable Properties

The IAttachable type exposes the following members.

Properties
 | Name | Description
Public property | Parent | Gets the parent of the current object. (Inherited from IAggregatable.)
Public property | ParentRelationship | Describes the relationship between the current object and its parent. Valid values are Child or ParentSurrogate. (Inherited from IAggregatable.)
Top
See Also

Reference

IAttachable Interface
PostSharp.Patterns.Model Namespace


IAttachable Events

IAttachable Events

The IAttachable type exposes the following members.

Events
 | Name | Description
Public event | AncestorChanged | Occurs when any ancestor changes. An ancestor is the parent of the current object or the parent of an ancestor of the current object. (Inherited from IAggregatable.)
Public event | ParentChanged | Occurs when the Parent property changes. (Inherited from IAggregatable.)
Top
See Also

Reference

IAttachable Interface
PostSharp.Patterns.Model Namespace


IAttacher Interface

IAttacher Interface
Describes the semantics of a service through which a child IAggregatable object can attach itself to a parent object. This interface is typically implemented by the parent object by composition.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAttacher

The IAttacher type exposes the following members.

Methods
 | Name | Description
Public method | AttachChild | Attach an object as a child of the current node.
Public method | DetachChild | Detaches an object as a child of the current node.
Public method | GetNode | Gets the underlying object instance which is subject to the current attacher. The instance is the aggregatable node that participates in the parent-child relationships with other objects.
Public method | OnChildAttached | Method invoked after a child has been successfully attached to the current node.
Public method | OnChildDetached | Method invoked when a child has been detached from the current node.
Top
Remarks

This interface should typically not be used or implemented in user code.

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


IAttacher Methods

IAttacher Methods

The IAttacher type exposes the following members.

Methods
 | Name | Description
Public method | AttachChild | Attach an object as a child of the current node.
Public method | DetachChild | Detaches an object as a child of the current node.
Public method | GetNode | Gets the underlying object instance which is subject to the current attacher. The instance is the aggregatable node that participates in the parent-child relationships with other objects.
Public method | OnChildAttached | Method invoked after a child has been successfully attached to the current node.
Public method | OnChildDetached | Method invoked when a child has been detached from the current node.
Top
See Also

Reference

IAttacher Interface
PostSharp.Patterns.Model Namespace


IAttacher.AttachChild Method

IAttacherAttachChild Method
Attach an object as a child of the current node.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object AttachChild(
    Object state,
    Object child,
    ChildInfo childInfo
)

Parameters

state
Type: SystemObject
The opaque state object passed to AttachToParent(RelationshipInfo, IAttacher, Object).
child
Type: SystemObject
The object that must be attached as a child to the current node.
childInfo
Type: PostSharp.Patterns.ModelChildInfo
Information about the location (field or collection item, typically) to which the child is assigned and about the relationship of the current node relatively to the parent node. The Relationship property must be set to Child or ParentSurrogate

Return Value

Type: Object
The new parent of child, or null if child was already attached to the same parent node through another relationship. If the current node is a parent surrogate, the method returns the parent of the current node.
Remarks
The new parent of child will be the current node (the value returned by GetNode(Object)); or the parent of the current node, if the current node is a parent surrogate.
Version Information

Supported in: 4.1

See Also

Reference

IAttacher Interface
PostSharp.Patterns.Model Namespace


IAttacher.DetachChild Method

IAttacherDetachChild Method
Detaches an object as a child of the current node.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object DetachChild(
    Object state,
    Object child,
    ChildInfo childInfo
)

Parameters

state
Type: SystemObject
The opaque state object passed to AttachToParent(RelationshipInfo, IAttacher, Object).
child
Type: SystemObject
The object that must be detached as a child as the current node.
childInfo
Type: PostSharp.Patterns.ModelChildInfo

Return Value

Type: Object
The former effective parent of child, or null if the child is still attached to the parent through another relationship.
Version Information

Supported in: 4.1

See Also

Reference

IAttacher Interface
PostSharp.Patterns.Model Namespace


IAttacher.GetNode Method

IAttacherGetNode Method
Gets the underlying object instance which is subject to the current attacher. The instance is the aggregatable node that participates in the parent-child relationships with other objects.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object GetNode(
    Object state
)

Parameters

state
Type: SystemObject
The opaque state object passed to AttachToParent(RelationshipInfo, IAttacher, Object).

Return Value

Type: Object
An object implementing IAggregatable, either directly or dynamically.
Version Information

Supported in: 4.1

See Also

Reference

IAttacher Interface
PostSharp.Patterns.Model Namespace


IAttacher.OnChildAttached Method

IAttacherOnChildAttached Method
Method invoked after a child has been successfully attached to the current node.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnChildAttached(
    Object state,
    Object parent,
    Object child,
    ChildInfo childInfo
)

Parameters

state
Type: SystemObject
The opaque state object passed to AttachToParent(RelationshipInfo, IAttacher, Object).
parent
Type: SystemObject
The actual parent of child. If child is assigned to a parent surrogate, the parameter is set to the actual parent, i.e. to the parent of the parent surrogate.
child
Type: SystemObject
The child object.
childInfo
Type: PostSharp.Patterns.ModelChildInfo
Information about the location (field or collection item, typically) to which the child is assigned and about the relationship of the current node relatively to the parent node.
Version Information

Supported in: 4.1

See Also

Reference

IAttacher Interface
PostSharp.Patterns.Model Namespace


IAttacher.OnChildDetached Method

IAttacherOnChildDetached Method
Method invoked when a child has been detached from the current node.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnChildDetached(
    Object state,
    Object parent,
    Object child,
    ChildInfo childInfo
)

Parameters

state
Type: SystemObject
The opaque state object passed to AttachToParent(RelationshipInfo, IAttacher, Object).
parent
Type: SystemObject
The former actual parent of child. If child was assigned to a parent surrogate, the parameter is set to the former actual parent, i.e. to the parent of the parent surrogate.
child
Type: SystemObject
The child object.
childInfo
Type: PostSharp.Patterns.ModelChildInfo
Information about the location (field or collection item, typically) to which the child was assigned and about the relationship of the current node relatively to the parent node.
Version Information

Supported in: 4.1

See Also

Reference

IAttacher Interface
PostSharp.Patterns.Model Namespace


IDynamicInterfaceImplementation Interface

IDynamicInterfaceImplementation Interface
Interface that must be implemented by objects implementing dynamic interfaces, which can be queried using QueryInterfaceT. The IDynamicInterfaceImplementation interface provides a mean to get a reference back to the principal object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IDynamicInterfaceImplementation

The IDynamicInterfaceImplementation type exposes the following members.

Properties
 | Name | Description
Public property | PrincipalObject | Gets the principal object for which the current object is an indirect interface implementation.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


IDynamicInterfaceImplementation Properties

IDynamicInterfaceImplementation Properties

The IDynamicInterfaceImplementation type exposes the following members.

Properties
 | Name | Description
Public property | PrincipalObject | Gets the principal object for which the current object is an indirect interface implementation.
Top
See Also

Reference

IDynamicInterfaceImplementation Interface
PostSharp.Patterns.Model Namespace


IDynamicInterfaceImplementation.PrincipalObject Property

IDynamicInterfaceImplementationPrincipalObject Property
Gets the principal object for which the current object is an indirect interface implementation.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object PrincipalObject { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1

See Also

Reference

IDynamicInterfaceImplementation Interface
PostSharp.Patterns.Model Namespace


IgnoreAutoChangeNotificationAttribute Class

IgnoreAutoChangeNotificationAttribute Class
Custom attribute that, when applied to a method, prevents the NotifyPropertyChangedAttribute aspect to raise change notifications for this property.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Patterns.ModelIgnoreAutoChangeNotificationAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class IgnoreAutoChangeNotificationAttribute : Attribute

The IgnoreAutoChangeNotificationAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | IgnoreAutoChangeNotificationAttribute | Initializes a new instance of the IgnoreAutoChangeNotificationAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Model Namespace


IgnoreAutoChangeNotificationAttribute Constructor

IgnoreAutoChangeNotificationAttribute Constructor
Initializes a new instance of the IgnoreAutoChangeNotificationAttribute class

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IgnoreAutoChangeNotificationAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IgnoreAutoChangeNotificationAttribute Class
PostSharp.Patterns.Model Namespace


IgnoreAutoChangeNotificationAttribute Methods

IgnoreAutoChangeNotificationAttribute Methods

The IgnoreAutoChangeNotificationAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

IgnoreAutoChangeNotificationAttribute Class
PostSharp.Patterns.Model Namespace


IQueryInterface Interface

IQueryInterface Interface
Interface implemented by objects that can implement interface dynamically by composition, without implementing the interface directly at MSIL level. The QueryInterfaceT method must then be used instead of a normal cast.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IQueryInterface

The IQueryInterface type exposes the following members.

Methods
 | Name | Description
Public method | QueryInterfaceT | Gets the implementation of a specified interface for the current object.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace
PostSharp.Patterns.ModelIDynamicInterfaceImplementation
PostSharp.Patterns.ModelQueryInterfaceExtensions


IQueryInterface Methods

IQueryInterface Methods

The IQueryInterface type exposes the following members.

Methods
 | Name | Description
Public method | QueryInterfaceT | Gets the implementation of a specified interface for the current object.
Top
See Also

Reference

IQueryInterface Interface
PostSharp.Patterns.Model Namespace


IQueryInterface.QueryInterface(T) Method

IQueryInterfaceQueryInterfaceT Method
Gets the implementation of a specified interface for the current object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
T QueryInterface<T>()
where T : class

Type Parameters

T
The type of the required interface.

Return Value

Type: T
An object implementing the T interface on behalf of the current object, or null if the current object does not implement the T interface.
Remarks

This method shall return the current object if the type of the current object statically implements the interface. Otherwise, the method shall return another object that implements T on behalf of the current object. In this case, the returned object shall implement the IDynamicInterfaceImplementation interface, which allows to navigate back to the current object.

User code typically uses the QueryInterfaceT(Object, Boolean) extension method.

Version Information

Supported in: 4.1

See Also

Reference

IQueryInterface Interface
PostSharp.Patterns.Model Namespace


MemberRelationshipAttribute Class

MemberRelationshipAttribute Class
Base class for custom attributes that determine the kind of relationship of objects in a graph.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Patterns.ModelMemberRelationshipAttribute
PostSharp.Patterns.ModelChildAttribute
PostSharp.Patterns.ModelParentAttribute
PostSharp.Patterns.ModelReferenceAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class MemberRelationshipAttribute : Attribute,
    IValidableAnnotation

The MemberRelationshipAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace
PostSharp.Patterns.ModelChildAttribute
PostSharp.Patterns.ModelParentAttribute
PostSharp.Patterns.ModelReferenceAttribute


MemberRelationshipAttribute Methods

MemberRelationshipAttribute Methods

The MemberRelationshipAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MemberRelationshipAttribute Class
PostSharp.Patterns.Model Namespace


MemberRelationshipAttribute.CompileTimeValidate Method

MemberRelationshipAttributeCompileTimeValidate Method
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Target element.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.

Implements

IValidableAnnotationCompileTimeValidate(Object)
Remarks
The implementation of this method is expected to emit an error message or an exception of type InvalidAnnotationException in case of error. Only returning false causes the aspect to be silently ignored.
Version Information

Supported in: 4.1

See Also

Reference

MemberRelationshipAttribute Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttribute Class

NotifyPropertyChangedAttribute Class
Custom attribute that, when applied on a type, implements the INotifyPropertyChanged interface for this class and all children classes.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelNotifyPropertyChangedAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class NotifyPropertyChangedAttribute : InstanceLevelAspect,
    ISerializationCallback, INotifyPropertyChangedController, INotifyChildPropertyChanged, INotifyPropertyChanged, IAdviceProvider,
    IAspect

The NotifyPropertyChangedAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | NotifyPropertyChangedAttribute | Initializes a new instance of the NotifyPropertyChangedAttribute class that stores strong references to the client delegates.
Public method | NotifyPropertyChangedAttribute(Boolean) | Initializes a new instance of the NotifyPropertyChangedAttribute class and specifies whether the PostSharp.Patterns.Model.NotifyPropertyChanged event should hold a weak or strong reference to to the client delegates.
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Overrides TypeLevelAspectCompileTimeInitialize(Type, AspectInfo).)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides TypeLevelAspectCompileTimeValidate(Type).)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Overrides InstanceLevelAspectCreateInstance(AdviceArgs).)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Overrides InstanceLevelAspectOnCloned(ICloneAwareAspect).)
Public method | RuntimeInitialize | Initializes the current aspect. (Overrides TypeLevelAspectRuntimeInitialize(Type).)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Top
Remarks

The aspect analyzes dependencies between property getters and fields. The aspect understands indirect dependencies. For instance, a property getter may depend on several other methods or property getters, which in turn can depend on other methods or fields. The algorithm is not able to analyze calls to virtual methods or delegates (because of prohibitive computational cost), and will only try to analyze methods in the current class.

The aspect will emit a build-time error if it is not able to understand the code of the target class. In this case, you can exclude the property from automatic change notification by applying the IgnoreAutoChangeNotificationAttribute custom attribute to the problematic property, or SafeForDependencyAnalysisAttribute to ignore the warnings of the dependency analysis engine. You will then need to specify dependencies explicitly using the Depends class. You can also mark a helper method with the PureAttribute to make it safe from use in a property getter. For instance, the string.Format method is pure.

By default, the NotifyPropertyChangedAttribute aspect holds strong references to the client delegates. This behavior can cause memory leaks if client delegates are not properly removed before client objects are disposed. To cause the aspect to store weak references, pass the true value to the NotifyPropertyChangedAttribute(Boolean) constructor.

Target classes can customize the NotifyPropertyChangedAttribute aspect by implementing one or many of the members documented in the NotifyPropertyChangedAttributeTargetClass class.

By default, the NotifyPropertyChangedAttribute aspect holds strong references to the client delegates. This behavior can cause memory leaks if client delegates are not properly removed before client objects are disposed. To cause the aspect to store weak references, pass the true value to the NotifyPropertyChangedAttribute(Boolean) constructor.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttribute Constructor

NotifyPropertyChangedAttribute Constructor
Overload List
 | Name | Description
Public method | NotifyPropertyChangedAttribute | Initializes a new instance of the NotifyPropertyChangedAttribute class that stores strong references to the client delegates.
Public method | NotifyPropertyChangedAttribute(Boolean) | Initializes a new instance of the NotifyPropertyChangedAttribute class and specifies whether the PostSharp.Patterns.Model.NotifyPropertyChanged event should hold a weak or strong reference to to the client delegates.
Top
See Also

Reference

NotifyPropertyChangedAttribute Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttribute Constructor

NotifyPropertyChangedAttribute Constructor
Initializes a new instance of the NotifyPropertyChangedAttribute class that stores strong references to the client delegates.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public NotifyPropertyChangedAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotifyPropertyChangedAttribute Class
NotifyPropertyChangedAttribute Overload
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttribute Constructor (Boolean)

NotifyPropertyChangedAttribute Constructor (Boolean)
Initializes a new instance of the NotifyPropertyChangedAttribute class and specifies whether the PostSharp.Patterns.Model.NotifyPropertyChanged event should hold a weak or strong reference to to the client delegates.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public NotifyPropertyChangedAttribute(
    bool holdWeakReference = false
)

Parameters

holdWeakReference (Optional)
Type: SystemBoolean
true if the PostSharp.Patterns.Model.NotifyPropertyChanged event should hold a WeakReference to the client delegates, false if the event should hold a normal reference.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

NotifyPropertyChangedAttribute Class
NotifyPropertyChangedAttribute Overload
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttribute Methods

NotifyPropertyChangedAttribute Methods

The NotifyPropertyChangedAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Overrides TypeLevelAspectCompileTimeInitialize(Type, AspectInfo).)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides TypeLevelAspectCompileTimeValidate(Type).)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Overrides InstanceLevelAspectCreateInstance(AdviceArgs).)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Overrides InstanceLevelAspectOnCloned(ICloneAwareAspect).)
Public method | RuntimeInitialize | Initializes the current aspect. (Overrides TypeLevelAspectRuntimeInitialize(Type).)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

NotifyPropertyChangedAttribute Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttribute.CompileTimeInitialize Method

NotifyPropertyChangedAttributeCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void CompileTimeInitialize(
    Type type,
    AspectInfo aspectInfo
)

Parameters

type
Type: SystemType
Type to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.

Implements

ITypeLevelAspectBuildSemanticsCompileTimeInitialize(Type, AspectInfo)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotifyPropertyChangedAttribute Class
PostSharp.Patterns.Model Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


NotifyPropertyChangedAttribute.CompileTimeValidate Method

NotifyPropertyChangedAttributeCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides TypeLevelAspectCompileTimeValidate(Type).)
Top
See Also

Reference

NotifyPropertyChangedAttribute Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttribute.CompileTimeValidate Method (Type)

NotifyPropertyChangedAttributeCompileTimeValidate Method (Type)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool CompileTimeValidate(
    Type type
)

Parameters

type
Type: SystemType
Type to which the aspect has been applied

Return Value

Type: Boolean
true if the aspect was applied to an acceptable field, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotifyPropertyChangedAttribute Class
CompileTimeValidate Overload
PostSharp.Patterns.Model Namespace

Other Resources

Conceptual Documentation: Validating Aspects


NotifyPropertyChangedAttribute.CreateInstance Method

NotifyPropertyChangedAttributeCreateInstance Method
Creates a new instance of the aspect based on the current instance, serving as a prototype.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object CreateInstance(
    AdviceArgs adviceArgs
)

Parameters

adviceArgs
Type: PostSharp.AspectsAdviceArgs
Aspect arguments.

Return Value

Type: Object
A new instance of the aspect, typically a clone of the current prototype instance.

Implements

IInstanceScopedAspectCreateInstance(AdviceArgs)
Remarks
This method is typically implemented by invoking MemberwiseClone.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotifyPropertyChangedAttribute Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttribute.OnCloned Method

NotifyPropertyChangedAttributeOnCloned Method
Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void OnCloned(
    ICloneAwareAspect source
)

Parameters

source
Type: PostSharp.AspectsICloneAwareAspect
Aspect instance corresponding to the current aspect instance in the cloned target object.

Implements

ICloneAwareAspectOnCloned(ICloneAwareAspect)
Remarks

Prior to calling the current method, the aspect framework initializes the source object using CreateInstance(AdviceArgs) and RuntimeInitializeInstance. That is, the aspect instance in the cloned object is not cloned from the source aspect instance, but from the prototype aspect instance.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotifyPropertyChangedAttribute Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttribute.RuntimeInitialize Method

NotifyPropertyChangedAttributeRuntimeInitialize Method
Initializes the current aspect.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void RuntimeInitialize(
    Type type
)

Parameters

type
Type: SystemType
Type to which the current aspect is applied.

Implements

ITypeLevelAspectRuntimeInitialize(Type)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotifyPropertyChangedAttribute Class
PostSharp.Patterns.Model Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


NotifyPropertyChangedAttribute Properties

NotifyPropertyChangedAttribute Properties

The NotifyPropertyChangedAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Top
See Also

Reference

NotifyPropertyChangedAttribute Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttributeTargetClass Class

NotifyPropertyChangedAttributeTargetClass Class
Describes the members that are consumed by the NotifyPropertyChangedAttribute aspect. You can define one or many of these members in classes that are the target of NotifyPropertyChangedAttribute to customize the behavior of the NotifyPropertyChangedAttribute aspect.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelNotifyPropertyChangedAttributeTargetClass

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class NotifyPropertyChangedAttributeTargetClass : INotifyPropertyChanged

The NotifyPropertyChangedAttributeTargetClass type exposes the following members.

Constructors
 | Name | Description
Public method | NotifyPropertyChangedAttributeTargetClass | Initializes a new instance of the NotifyPropertyChangedAttributeTargetClass class
Top
Methods
 | Name | Description
Protected method | OnPropertyChanged | Raises the PropertyChanged event. If this method is already present in the target code, the NotifyPropertyChangedAttribute aspect will use it to raise the PropertyChanged event. Otherwise, the aspect will introduce the method into the target class.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Events
 | Name | Description
Public event | PropertyChanged | Event raised when a property has changed. This event is introduced by the NotifyPropertyChangedAttribute aspect unless it is already present in the target class.
Top
Remarks
Note Note

This class it for documentation purpose only, and should not be used in code.

If the target class implements the INotifyPropertyChanged interface, then it must also:

  • implement the OnPropertyChanged(String) method with the exact same signature and modifiers, and
  • introduce the PropertyChanged event as a public member (introducing a private interface interpretation would result in incorrect behavior).
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttributeTargetClass Constructor

NotifyPropertyChangedAttributeTargetClass Constructor
Initializes a new instance of the NotifyPropertyChangedAttributeTargetClass class

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public NotifyPropertyChangedAttributeTargetClass()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

NotifyPropertyChangedAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttributeTargetClass Methods

NotifyPropertyChangedAttributeTargetClass Methods

The NotifyPropertyChangedAttributeTargetClass type exposes the following members.

Methods
 | Name | Description
Protected method | OnPropertyChanged | Raises the PropertyChanged event. If this method is already present in the target code, the NotifyPropertyChangedAttribute aspect will use it to raise the PropertyChanged event. Otherwise, the aspect will introduce the method into the target class.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

NotifyPropertyChangedAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttributeTargetClass.OnPropertyChanged Method

NotifyPropertyChangedAttributeTargetClassOnPropertyChanged Method
Raises the PropertyChanged event. If this method is already present in the target code, the NotifyPropertyChangedAttribute aspect will use it to raise the PropertyChanged event. Otherwise, the aspect will introduce the method into the target class.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void OnPropertyChanged(
    string propertyName
)

Parameters

propertyName
Type: SystemString
Name of the changed property. The NotifyPropertyChangedAttribute aspect never passes null to this parameter.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

NotifyPropertyChangedAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttributeTargetClass Events

NotifyPropertyChangedAttributeTargetClass Events

The NotifyPropertyChangedAttributeTargetClass type exposes the following members.

Events
 | Name | Description
Public event | PropertyChanged | Event raised when a property has changed. This event is introduced by the NotifyPropertyChangedAttribute aspect unless it is already present in the target class.
Top
See Also

Reference

NotifyPropertyChangedAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedAttributeTargetClass.PropertyChanged Event

NotifyPropertyChangedAttributeTargetClassPropertyChanged Event
Event raised when a property has changed. This event is introduced by the NotifyPropertyChangedAttribute aspect unless it is already present in the target class.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public event PropertyChangedEventHandler PropertyChanged

Value

Type: System.ComponentModelPropertyChangedEventHandler

Implements

INotifyPropertyChangedPropertyChanged
Remarks

If the INotifyPropertyChanged interface is already implemented in the target class, the PropertyChanged event must be raised by the OnPropertyChanged(String) method, with respect of the implementation guidelines for the INotifyPropertyChanged interface.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

NotifyPropertyChangedAttributeTargetClass Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedOverflowException Class

NotifyPropertyChangedOverflowException Class
Exception thrown at runtime when the NotifyPropertyChangedAttribute aspect encounters an excessively long chain is dependency. This situation is typically caused by a cyclic dependency.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.Patterns.ModelNotifyPropertyChangedOverflowException

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class NotifyPropertyChangedOverflowException : Exception

The NotifyPropertyChangedOverflowException type exposes the following members.

Constructors
 | Name | Description
Public method | NotifyPropertyChangedOverflowException | Initializes a new NotifyPropertyChangedOverflowException.
Public method | NotifyPropertyChangedOverflowException(String) | Initializes a new NotifyPropertyChangedOverflowException and sets the exception message.
Public method | NotifyPropertyChangedOverflowException(String, Exception) | Initializes a new NotifyPropertyChangedOverflowException and sets the exception message and the inner exception.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Model Namespace


NotifyPropertyChangedOverflowException Constructor

NotifyPropertyChangedOverflowException Constructor
Overload List
 | Name | Description
Public method | NotifyPropertyChangedOverflowException | Initializes a new NotifyPropertyChangedOverflowException.
Public method | NotifyPropertyChangedOverflowException(String) | Initializes a new NotifyPropertyChangedOverflowException and sets the exception message.
Public method | NotifyPropertyChangedOverflowException(String, Exception) | Initializes a new NotifyPropertyChangedOverflowException and sets the exception message and the inner exception.
Top
See Also

Reference

NotifyPropertyChangedOverflowException Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedOverflowException Constructor

NotifyPropertyChangedOverflowException Constructor
Initializes a new NotifyPropertyChangedOverflowException.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public NotifyPropertyChangedOverflowException()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotifyPropertyChangedOverflowException Class
NotifyPropertyChangedOverflowException Overload
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedOverflowException Constructor (String)

NotifyPropertyChangedOverflowException Constructor (String)
Initializes a new NotifyPropertyChangedOverflowException and sets the exception message.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public NotifyPropertyChangedOverflowException(
    string message
)

Parameters

message
Type: SystemString
Exception message.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotifyPropertyChangedOverflowException Class
NotifyPropertyChangedOverflowException Overload
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedOverflowException Constructor (String, Exception)

NotifyPropertyChangedOverflowException Constructor (String, Exception)
Initializes a new NotifyPropertyChangedOverflowException and sets the exception message and the inner exception.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public NotifyPropertyChangedOverflowException(
    string message,
    Exception innerException
)

Parameters

message
Type: SystemString
Exception message.
innerException
Type: SystemException
Inner exception.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotifyPropertyChangedOverflowException Class
NotifyPropertyChangedOverflowException Overload
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedOverflowException Methods

NotifyPropertyChangedOverflowException Methods

The NotifyPropertyChangedOverflowException type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

NotifyPropertyChangedOverflowException Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedServices Class

NotifyPropertyChangedServices Class
Utility methods to work with the NotifyPropertyChangedAttribute aspect.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelNotifyPropertyChangedServices

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class NotifyPropertyChangedServices

The NotifyPropertyChangedServices type exposes the following members.

Methods
Name | Description
RaiseEventsImmediate | Raises all PropertyChanged events that are currently stored in the event buffer for the current thread and a given object.
ResumeEvents | Resumes the raising of PropertyChanged events for the current thread after it has been suspending by the SuspendEvents method.
SuspendEvents | Suspends the raising of PropertyChanged events for the current thread.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Model Namespace


NotifyPropertyChangedServices Methods

NotifyPropertyChangedServices Methods

The NotifyPropertyChangedServices type exposes the following members.

Methods
Name | Description
RaiseEventsImmediate | Raises all PropertyChanged events that are currently stored in the event buffer for the current thread and a given object.
ResumeEvents | Resumes the raising of PropertyChanged events for the current thread after it has been suspending by the SuspendEvents method.
SuspendEvents | Suspends the raising of PropertyChanged events for the current thread.
Top
See Also

Reference

NotifyPropertyChangedServices Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedServices.RaiseEventsImmediate Method

NotifyPropertyChangedServicesRaiseEventsImmediate Method
Raises all PropertyChanged events that are currently stored in the event buffer for the current thread and a given object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void RaiseEventsImmediate(
    Object instance
)

Parameters

instance
Type: SystemObject
The object for which events should be raised.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

NotifyPropertyChangedServices Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedServices.ResumeEvents Method

NotifyPropertyChangedServicesResumeEvents Method
Resumes the raising of PropertyChanged events for the current thread after it has been suspending by the SuspendEvents method.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void ResumeEvents()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

NotifyPropertyChangedServices Class
PostSharp.Patterns.Model Namespace


NotifyPropertyChangedServices.SuspendEvents Method

NotifyPropertyChangedServicesSuspendEvents Method
Suspends the raising of PropertyChanged events for the current thread.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool SuspendEvents()

Return Value

Type: Boolean
true if events were suspended as a result of the current method call, false if events were already suspended before.
Remarks

The ResumeEvents method should be invoked as many times as the SuspendEvents method has been invoked, regardless of the return value of the SuspendEvents method.

When events are suspended, they are still being collected in the event buffer, but the buffer is not flushed.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

NotifyPropertyChangedServices Class
PostSharp.Patterns.Model Namespace


ObjectAccessLevel Enumeration

ObjectAccessLevel Enumeration
Enumeration of access levels that methods of execution scopes can require on an object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum ObjectAccessLevel
Members
Member name | Value | Description
None | 0 | None.
Unknown | 1 | The required access level is unknown; maximal access is required.
Read | 2 | Read-only.
Write | 3 | Read-write.
UpgradeableRead | 4 | Read-only access that prevents other threads from acquiring Write or UpgradeableRead access.
Unchecked | 5 | Disables all runtime verification of access permissions.
Yield | 6 | Indicates that the control flow is passed to another object.
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


ParentAttribute Class

ParentAttribute Class
Custom attribute that, when applied to a field or automatic property, specifies that this field or property should be automatically set to the parent of the instance of the declaring type, whenever this instance is attached as a child to another object.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Patterns.ModelMemberRelationshipAttribute
PostSharp.Patterns.ModelParentAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ParentAttribute : MemberRelationshipAttribute

The ParentAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ParentAttribute | Initializes a new instance of the ParentAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MemberRelationshipAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks

It is recommended to add this custom attribute only to private fields or automatic properties with a private setter.

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace
PostSharp.Patterns.ModelChildAttribute
PostSharp.Patterns.ModelReferenceAttribute
PostSharp.Patterns.ModelAggregatableAttribute


ParentAttribute Constructor

ParentAttribute Constructor
Initializes a new instance of the ParentAttribute class

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ParentAttribute()
Version Information

Supported in: 4.1

See Also

Reference

ParentAttribute Class
PostSharp.Patterns.Model Namespace


ParentAttribute Methods

ParentAttribute Methods

The ParentAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MemberRelationshipAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ParentAttribute Class
PostSharp.Patterns.Model Namespace


PropertyPath Class

PropertyPath Class
Immutable property path with all components interned.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelPropertyPath

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class PropertyPath : ISerializationCallback

The PropertyPath type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Overrides ObjectEquals(Object).)
Public method | GetHashCode | Serves as a hash function for a particular type. (Overrides ObjectGetHashCode.)
Public method | ToString | Returns a string that represents the current object. (Overrides ObjectToString.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Model Namespace


PropertyPath Methods

PropertyPath Methods

The PropertyPath type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Overrides ObjectEquals(Object).)
Public method | GetHashCode | Serves as a hash function for a particular type. (Overrides ObjectGetHashCode.)
Public method | ToString | Returns a string that represents the current object. (Overrides ObjectToString.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PropertyPath Class
PostSharp.Patterns.Model Namespace


PropertyPath.Equals Method

PropertyPathEquals Method
Determines whether the specified Object is equal to the current Object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool Equals(
    Object obj
)

Parameters

obj
Type: SystemObject
The object to compare with the current object.

Return Value

Type: Boolean
true if the specified object is equal to the current object; otherwise, false.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PropertyPath Class
PostSharp.Patterns.Model Namespace


PropertyPath.GetHashCode Method

PropertyPathGetHashCode Method
Serves as a hash function for a particular type.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int GetHashCode()

Return Value

Type: Int32
A hash code for the current Object.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PropertyPath Class
PostSharp.Patterns.Model Namespace


PropertyPath.ToString Method

PropertyPathToString Method
Returns a string that represents the current object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override string ToString()

Return Value

Type: String
A string that represents the current object.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PropertyPath Class
PostSharp.Patterns.Model Namespace


PureAttribute Class

PureAttribute Class
Custom attribute that, when applied on a method, specifies that this method is a pure function, i.e. the method always returns the same result given the same parameter values. In the context of NotifyPropertyChangedAttribute, it is also assumed that pure functions have only parameters of primitive types (Int32, String, ...). The Object parameter type is also accepted, but then it is assumed that instances passed are immutable (and changes to these objects will not be tracked).
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ModelPureAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class PureAttribute : MulticastAttribute,
    IValidableAnnotation

The PureAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | PureAttribute | Initializes a new instance of the PureAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Model Namespace


PureAttribute Constructor

PureAttribute Constructor
Initializes a new instance of the PureAttribute class

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PureAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PureAttribute Class
PostSharp.Patterns.Model Namespace


PureAttribute Methods

PureAttribute Methods

The PureAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PureAttribute Class
PostSharp.Patterns.Model Namespace


PureAttribute.CompileTimeValidate Method

PureAttributeCompileTimeValidate Method
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Target element.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.

Implements

IValidableAnnotationCompileTimeValidate(Object)
Remarks
The implementation of this method is expected to emit an error message or an exception of type InvalidAnnotationException in case of error. Only returning false causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PureAttribute Class
PostSharp.Patterns.Model Namespace


PureAttribute Properties

PureAttribute Properties

The PureAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

PureAttribute Class
PostSharp.Patterns.Model Namespace


QueryInterfaceExtensions Class

QueryInterfaceExtensions Class
Provides methods to aid with the use of dynamic interfaces.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelQueryInterfaceExtensions

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class QueryInterfaceExtensions

The QueryInterfaceExtensions type exposes the following members.

Methods
Name | Description
QueryInterfaceT | Gets the implementation of a specified interface for the specified object.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace
PostSharp.Patterns.ModelIQueryInterface


QueryInterfaceExtensions Methods

QueryInterfaceExtensions Methods

The QueryInterfaceExtensions type exposes the following members.

Methods
Name | Description
QueryInterfaceT | Gets the implementation of a specified interface for the specified object.
Top
See Also

Reference

QueryInterfaceExtensions Class
PostSharp.Patterns.Model Namespace


QueryInterfaceExtensions.QueryInterface(T) Method

QueryInterfaceExtensionsQueryInterfaceT Method
Gets the implementation of a specified interface for the specified object.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static T QueryInterface<T>(
    this Object obj,
    bool throwing = true
)
where T : class

Parameters

obj
Type: SystemObject
The object for which the interface should be queried.
throwing (Optional)
Type: SystemBoolean
true if the method should throw a InvalidCastException if obj does not implement the T interface, false if null be returned instead. The default value is true.

Type Parameters

T
The type of the required interface.

Return Value

Type: T
An object implementing the T interface on behalf of obj, or null if obj does not implement T and throwing is true.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Object. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks

This method shall return obj if the type of obj statically implements the interface. Otherwise, the method shall return another object that implements T on behalf of obj. In this case, the returned object shall implement the IDynamicInterfaceImplementation interface, which allows to navigate back to obj.

Version Information

Supported in: 4.1

See Also

Reference

QueryInterfaceExtensions Class
PostSharp.Patterns.Model Namespace


ReferenceAttribute Class

ReferenceAttribute Class
Custom attribute that, when applied to a field or automatic property, specifies that this field or property is a simple reference, and is not involved in a parent-child relationship.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Patterns.ModelMemberRelationshipAttribute
PostSharp.Patterns.ModelReferenceAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ReferenceAttribute : MemberRelationshipAttribute

The ReferenceAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ReferenceAttribute | Initializes a new instance of the ReferenceAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MemberRelationshipAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace
PostSharp.Patterns.ModelChildAttribute
PostSharp.Patterns.ModelParentAttribute
PostSharp.Patterns.ModelAggregatableAttribute


ReferenceAttribute Constructor

ReferenceAttribute Constructor
Initializes a new instance of the ReferenceAttribute class

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ReferenceAttribute()
Version Information

Supported in: 4.1

See Also

Reference

ReferenceAttribute Class
PostSharp.Patterns.Model Namespace


ReferenceAttribute Methods

ReferenceAttribute Methods

The ReferenceAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MemberRelationshipAttribute.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReferenceAttribute Class
PostSharp.Patterns.Model Namespace


RelationshipInfo Structure

RelationshipInfo Structure
Describes the relationship between a parent and a child.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public struct RelationshipInfo : IEquatable<RelationshipInfo>

The RelationshipInfo type exposes the following members.

Constructors
 | Name | Description
Public method | RelationshipInfo | Initializes a new instance of the RelationshipInfo type.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(RelationshipInfo) |
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Top
Operators
Name | Description
Equality | Determines whether two instances of the RelationshipInfo type are equal.
Inequality | Determines whether two instances of the RelationshipInfo type are equal.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ItemsRelationship | Gets the kind of relationship of items of the child collection relatively to the child collection.
Public property | PropagateBehaviors | Specifies whether behaviors of the parent should be propagated to objects assigned to the field.
Public property | PropagateBehaviorsToItems | Specifies whether behaviors of the parent should be propagated to objects added to collections assigned to this field. This property is ignored if PropagateBehaviors is false.
Public property | Relationship | Gets the kind of relationship of the child relatively to the parent. Valid values are Child, ParentSurrogate or ChildOrParentSurrogate.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


RelationshipInfo Constructor

RelationshipInfo Constructor
Initializes a new instance of the RelationshipInfo type.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RelationshipInfo(
    RelationshipKind itemsRelationship,
    RelationshipKind relationship = RelationshipKind.Child
)

Parameters

itemsRelationship
Type: PostSharp.Patterns.ModelRelationshipKind
The kind of relationship of items of the child collection relatively to the child collection.
relationship (Optional)
Type: PostSharp.Patterns.ModelRelationshipKind
The kind of relationship of the child relatively to the parent. Valid values are Child, ParentSurrogate or ChildOrParentSurrogate.
Version Information

Supported in: 4.1

See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo Methods

RelationshipInfo Methods

The RelationshipInfo type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(RelationshipInfo) |
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo.Equals Method

RelationshipInfoEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(RelationshipInfo) |
Top
See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo.Equals Method (Object)

RelationshipInfoEquals Method (Object)
Indicates whether this instance and a specified object are equal.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool Equals(
    Object obj
)

Parameters

obj
Type: SystemObject
Another object to compare to.

Return Value

Type: Boolean
true if obj and this instance are the same type and represent the same value; otherwise, false.
Version Information

Supported in: 4.1

See Also

Reference

RelationshipInfo Structure
Equals Overload
PostSharp.Patterns.Model Namespace


RelationshipInfo.Equals Method (RelationshipInfo)

RelationshipInfoEquals Method (RelationshipInfo)

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Equals(
    RelationshipInfo other
)

Parameters

other
Type: PostSharp.Patterns.ModelRelationshipInfo

Return Value

Type: Boolean

Implements

IEquatableTEquals(T)
Version Information

Supported in: 4.1

See Also

Reference

RelationshipInfo Structure
Equals Overload
PostSharp.Patterns.Model Namespace


RelationshipInfo.GetHashCode Method

RelationshipInfoGetHashCode Method
Returns the hash code for this instance.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int GetHashCode()

Return Value

Type: Int32
A 32-bit signed integer that is the hash code for this instance.
Version Information

Supported in: 4.1

See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo Operators

RelationshipInfo Operators

The RelationshipInfo type exposes the following members.

Operators
Name | Description
Equality | Determines whether two instances of the RelationshipInfo type are equal.
Inequality | Determines whether two instances of the RelationshipInfo type are equal.
Top
See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo.Equality Operator

RelationshipInfoEquality Operator
Determines whether two instances of the RelationshipInfo type are equal.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator ==(
    RelationshipInfo left,
    RelationshipInfo right
)

Parameters

left
Type: PostSharp.Patterns.ModelRelationshipInfo
right
Type: PostSharp.Patterns.ModelRelationshipInfo

Return Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo.Inequality Operator

RelationshipInfoInequality Operator
Determines whether two instances of the RelationshipInfo type are equal.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator !=(
    RelationshipInfo left,
    RelationshipInfo right
)

Parameters

left
Type: PostSharp.Patterns.ModelRelationshipInfo
right
Type: PostSharp.Patterns.ModelRelationshipInfo

Return Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo Properties

RelationshipInfo Properties

The RelationshipInfo type exposes the following members.

Properties
 | Name | Description
Public property | ItemsRelationship | Gets the kind of relationship of items of the child collection relatively to the child collection.
Public property | PropagateBehaviors | Specifies whether behaviors of the parent should be propagated to objects assigned to the field.
Public property | PropagateBehaviorsToItems | Specifies whether behaviors of the parent should be propagated to objects added to collections assigned to this field. This property is ignored if PropagateBehaviors is false.
Public property | Relationship | Gets the kind of relationship of the child relatively to the parent. Valid values are Child, ParentSurrogate or ChildOrParentSurrogate.
Top
See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo.ItemsRelationship Property

RelationshipInfoItemsRelationship Property
Gets the kind of relationship of items of the child collection relatively to the child collection.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RelationshipKind ItemsRelationship { get; }

Property Value

Type: RelationshipKind
Version Information

Supported in: 4.1

See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo.PropagateBehaviors Property

RelationshipInfoPropagateBehaviors Property
Specifies whether behaviors of the parent should be propagated to objects assigned to the field.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool PropagateBehaviors { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo.PropagateBehaviorsToItems Property

RelationshipInfoPropagateBehaviorsToItems Property
Specifies whether behaviors of the parent should be propagated to objects added to collections assigned to this field. This property is ignored if PropagateBehaviors is false.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool PropagateBehaviorsToItems { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipInfo.Relationship Property

RelationshipInfoRelationship Property
Gets the kind of relationship of the child relatively to the parent. Valid values are Child, ParentSurrogate or ChildOrParentSurrogate.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RelationshipKind Relationship { get; }

Property Value

Type: RelationshipKind
Version Information

Supported in: 4.1

See Also

Reference

RelationshipInfo Structure
PostSharp.Patterns.Model Namespace


RelationshipKind Enumeration

RelationshipKind Enumeration
Enumeration of the kinds of relationship between objects in a object graph.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[FlagsAttribute]
public enum RelationshipKind
Members
Member name | Value | Description
None | 0 | No relationship.
Default | 1 | Means that the relationship kind has not been specified. The typical behavior is a build-time error or warning.
Child | 2 | Child (see ChildAttribute).
Reference | 4 | Reference (see ReferenceAttribute).
ParentSurrogate | 8 | Parent surrogate (see IsParentSurrogate).
Parent | 16 | Parent (see ParentAttribute).
ChildOrParentSurrogate | 10 | Either Child or ParentSurrogate, depending on the type of the specific object assigned to the field or property. This is the default relationship kind for ChildAttribute when the IsParentSurrogate property is not set: it causes the field to be a ParentSurrogate if the object is an AdvisableCollectionT or an AdvisableDictionaryTKey, TValue, otherwise a Child.
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model Namespace


SafeForDependencyAnalysisAttribute Class

SafeForDependencyAnalysisAttribute Class
Custom attribute that, when applied on a property, prevents the dependency analysis algorithm used by the NotifyPropertyChangedAttribute aspect from emitting errors when it encounters constructs that it cannot analyze.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Patterns.ModelSafeForDependencyAnalysisAttribute

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class SafeForDependencyAnalysisAttribute : Attribute

The SafeForDependencyAnalysisAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | SafeForDependencyAnalysisAttribute | Initializes a new instance of the SafeForDependencyAnalysisAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks

Getters of properties annotated with SafeForDependencyAnalysisAttribute should typically specify dependencies manually using the Depends class. Note that all dependencies that can be found using code analysis will be taken into account. The SafeForDependencyAnalysisAttribute only disables errors, but not the code analysis itself.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Model Namespace


SafeForDependencyAnalysisAttribute Constructor

SafeForDependencyAnalysisAttribute Constructor
Initializes a new instance of the SafeForDependencyAnalysisAttribute class

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SafeForDependencyAnalysisAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SafeForDependencyAnalysisAttribute Class
PostSharp.Patterns.Model Namespace


SafeForDependencyAnalysisAttribute Methods

SafeForDependencyAnalysisAttribute Methods

The SafeForDependencyAnalysisAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SafeForDependencyAnalysisAttribute Class
PostSharp.Patterns.Model Namespace


PostSharp.Patterns.Model.Controls Namespace

PostSharp.Patterns.Model.Controls Namespace
Classes
 | Class | Description
Public class | RedoButton | A typical implementation of a Redo button, with an optional and expandable list of operations that can be redone.
Public class | RedoCommand | A command that redoes a single operation in a Recorder.
Public class | StringEscaper |
Public class | UndoButton | A typical implementation of an Undo button, with an optional and expandable list of operations that can be undone.
Public class | UndoCommand | A command that undoes a single operation in a Recorder.
Public class | UndoRedoButtonBase | Base class for UndoButton and RedoButton.
Public class | UndoRedoCommandBase | Base class for UndoCommand and RedoCommand.


RedoButton Class

RedoButton Class
A typical implementation of a Redo button, with an optional and expandable list of operations that can be redone.
Inheritance Hierarchy
SystemObject
System.Windows.ThreadingDispatcherObject
System.WindowsDependencyObject
System.Windows.MediaVisual
System.WindowsUIElement
System.WindowsFrameworkElement
System.Windows.ControlsControl
System.Windows.ControlsContentControl
System.Windows.Controls.PrimitivesButtonBase
System.Windows.ControlsButton
PostSharp.Patterns.Model.ControlsUndoRedoButtonBase
PostSharp.Patterns.Model.ControlsRedoButton

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class RedoButton : UndoRedoButtonBase

The RedoButton type exposes the following members.

Constructors
 | Name | Description
Public method | RedoButton | Initializes a new instance of the RedoButton class.
Top
Methods
 | Name | Description
Public method | OnApplyTemplate | When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate. (Inherited from UndoRedoButtonBase.)
Protected method | OnClick | Called when a Button is clicked. (Inherited from UndoRedoButtonBase.)
Protected method | OnKeyDown | Provides class handling for the KeyDown routed event that occurs when the user presses a key while this control has focus. (Inherited from UndoRedoButtonBase.)
Protected method | OnPropertyChanged | Raises the PropertyChanged event. (Inherited from UndoRedoButtonBase.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Protected property | IsEnabledCore | Gets the value of the IsEnabled property. (Inherited from UndoRedoButtonBase.)
Public property | IsListEnabled | Determines whether the button can be extended and display the list of operations that can be undone or redone. (Inherited from UndoRedoButtonBase.)
Public property | IsListExpanded | Determines whether the detailed list of operations is currently expanded. (Inherited from UndoRedoButtonBase.)
Public property | MaxOperationsCount | Gets or sets the maximal number of operations displayed by the current button. (Inherited from UndoRedoButtonBase.)
Public property | Operations | Gets the list of operations displayed by the current button when in expanded state. (Inherited from UndoRedoButtonBase.)
Public property | Recorder | Gets or sets the Recorder bound to the current control. (Inherited from UndoRedoButtonBase.)
Public property | UndoCommand | (Inherited from UndoRedoButtonBase.)
Top
Events
 | Name | Description
Public event | PropertyChanged | Occurs when a property value changes. (Inherited from UndoRedoButtonBase.)
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model.Controls Namespace


RedoButton Constructor

RedoButton Constructor
Initializes a new instance of the RedoButton class.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RedoButton()
Version Information

Supported in: 4.1

See Also

Reference

RedoButton Class
PostSharp.Patterns.Model.Controls Namespace


RedoButton Methods

RedoButton Methods

The RedoButton type exposes the following members.

Methods
 | Name | Description
Public method | OnApplyTemplate | When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate. (Inherited from UndoRedoButtonBase.)
Protected method | OnClick | Called when a Button is clicked. (Inherited from UndoRedoButtonBase.)
Protected method | OnKeyDown | Provides class handling for the KeyDown routed event that occurs when the user presses a key while this control has focus. (Inherited from UndoRedoButtonBase.)
Protected method | OnPropertyChanged | Raises the PropertyChanged event. (Inherited from UndoRedoButtonBase.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RedoButton Class
PostSharp.Patterns.Model.Controls Namespace


RedoButton Properties

RedoButton Properties

The RedoButton type exposes the following members.

Properties
 | Name | Description
Protected property | IsEnabledCore | Gets the value of the IsEnabled property. (Inherited from UndoRedoButtonBase.)
Public property | IsListEnabled | Determines whether the button can be extended and display the list of operations that can be undone or redone. (Inherited from UndoRedoButtonBase.)
Public property | IsListExpanded | Determines whether the detailed list of operations is currently expanded. (Inherited from UndoRedoButtonBase.)
Public property | MaxOperationsCount | Gets or sets the maximal number of operations displayed by the current button. (Inherited from UndoRedoButtonBase.)
Public property | Operations | Gets the list of operations displayed by the current button when in expanded state. (Inherited from UndoRedoButtonBase.)
Public property | Recorder | Gets or sets the Recorder bound to the current control. (Inherited from UndoRedoButtonBase.)
Public property | UndoCommand | (Inherited from UndoRedoButtonBase.)
Top
See Also

Reference

RedoButton Class
PostSharp.Patterns.Model.Controls Namespace


RedoButton Events

RedoButton Events

The RedoButton type exposes the following members.

Events
 | Name | Description
Public event | PropertyChanged | Occurs when a property value changes. (Inherited from UndoRedoButtonBase.)
Top
See Also

Reference

RedoButton Class
PostSharp.Patterns.Model.Controls Namespace


RedoCommand Class

RedoCommand Class
A command that redoes a single operation in a Recorder.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.Model.ControlsUndoRedoCommandBase
PostSharp.Patterns.Model.ControlsRedoCommand

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class RedoCommand : UndoRedoCommandBase

The RedoCommand type exposes the following members.

Constructors
 | Name | Description
Public method | RedoCommand | Initializes a new instance of the RedoCommand class and binds it to the DefaultRecorder.
Public method | RedoCommand(Recorder) | Initializes a new instance of the UndoCommand class and specifies to which Recorder it should be bound.
Top
Methods
 | Name | Description
Public method | CanExecute | Defines the method that determines whether the command can execute in its current state. (Inherited from UndoRedoCommandBase.)
Public method | Execute | Defines the method to be called when the command is invoked. (Inherited from UndoRedoCommandBase.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Recorder | Gets the Recorder bound to this command. (Inherited from UndoRedoCommandBase.)
Top
Events
 | Name | Description
Public event | CanExecuteChanged | Occurs when changes occur that affect whether or not the command should execute. (Inherited from UndoRedoCommandBase.)
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model.Controls Namespace


RedoCommand Constructor

RedoCommand Constructor
Overload List
 | Name | Description
Public method | RedoCommand | Initializes a new instance of the RedoCommand class and binds it to the DefaultRecorder.
Public method | RedoCommand(Recorder) | Initializes a new instance of the UndoCommand class and specifies to which Recorder it should be bound.
Top
See Also

Reference

RedoCommand Class
PostSharp.Patterns.Model.Controls Namespace


RedoCommand Constructor

RedoCommand Constructor
Initializes a new instance of the RedoCommand class and binds it to the DefaultRecorder.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RedoCommand()
Version Information

Supported in: 4.1

See Also

Reference

RedoCommand Class
RedoCommand Overload
PostSharp.Patterns.Model.Controls Namespace


RedoCommand Constructor (Recorder)

RedoCommand Constructor (Recorder)
Initializes a new instance of the UndoCommand class and specifies to which Recorder it should be bound.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RedoCommand(
    Recorder recorder
)

Parameters

recorder
Type: PostSharp.Patterns.RecordingRecorder
The Recorder to which the new RedoCommand should be bound.
Version Information

Supported in: 4.1

See Also

Reference

RedoCommand Class
RedoCommand Overload
PostSharp.Patterns.Model.Controls Namespace


RedoCommand Methods

RedoCommand Methods

The RedoCommand type exposes the following members.

Methods
 | Name | Description
Public method | CanExecute | Defines the method that determines whether the command can execute in its current state. (Inherited from UndoRedoCommandBase.)
Public method | Execute | Defines the method to be called when the command is invoked. (Inherited from UndoRedoCommandBase.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RedoCommand Class
PostSharp.Patterns.Model.Controls Namespace


RedoCommand Properties

RedoCommand Properties

The RedoCommand type exposes the following members.

Properties
 | Name | Description
Public property | Recorder | Gets the Recorder bound to this command. (Inherited from UndoRedoCommandBase.)
Top
See Also

Reference

RedoCommand Class
PostSharp.Patterns.Model.Controls Namespace


RedoCommand Events

RedoCommand Events

The RedoCommand type exposes the following members.

Events
 | Name | Description
Public event | CanExecuteChanged | Occurs when changes occur that affect whether or not the command should execute. (Inherited from UndoRedoCommandBase.)
Top
See Also

Reference

RedoCommand Class
PostSharp.Patterns.Model.Controls Namespace


StringEscaper Class

StringEscaper Class
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.Model.ControlsStringEscaper

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class StringEscaper : IValueConverter

The StringEscaper type exposes the following members.

Constructors
 | Name | Description
Public method | StringEscaper | Initializes a new instance of the StringEscaper class
Top
Methods
 | Name | Description
Public method | Convert |
Public method | ConvertBack |
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model.Controls Namespace


StringEscaper Constructor

StringEscaper Constructor
Initializes a new instance of the StringEscaper class

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public StringEscaper()
Version Information

Supported in: 4.1

See Also

Reference

StringEscaper Class
PostSharp.Patterns.Model.Controls Namespace


StringEscaper Methods

StringEscaper Methods

The StringEscaper type exposes the following members.

Methods
 | Name | Description
Public method | Convert |
Public method | ConvertBack |
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

StringEscaper Class
PostSharp.Patterns.Model.Controls Namespace


StringEscaper.Convert Method

StringEscaperConvert Method

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Convert(
    Object value,
    Type targetType,
    Object parameter,
    CultureInfo culture
)

Parameters

value
Type: SystemObject
targetType
Type: SystemType
parameter
Type: SystemObject
culture
Type: System.GlobalizationCultureInfo

Return Value

Type: Object

Implements

IValueConverterConvert(Object, Type, Object, CultureInfo)
Version Information

Supported in: 4.1

See Also

Reference

StringEscaper Class
PostSharp.Patterns.Model.Controls Namespace


StringEscaper.ConvertBack Method

StringEscaperConvertBack Method

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object ConvertBack(
    Object value,
    Type targetType,
    Object parameter,
    CultureInfo culture
)

Parameters

value
Type: SystemObject
targetType
Type: SystemType
parameter
Type: SystemObject
culture
Type: System.GlobalizationCultureInfo

Return Value

Type: Object

Implements

IValueConverterConvertBack(Object, Type, Object, CultureInfo)
Version Information

Supported in: 4.1

See Also

Reference

StringEscaper Class
PostSharp.Patterns.Model.Controls Namespace


UndoButton Class

UndoButton Class
A typical implementation of an Undo button, with an optional and expandable list of operations that can be undone.
Inheritance Hierarchy
SystemObject
System.Windows.ThreadingDispatcherObject
System.WindowsDependencyObject
System.Windows.MediaVisual
System.WindowsUIElement
System.WindowsFrameworkElement
System.Windows.ControlsControl
System.Windows.ControlsContentControl
System.Windows.Controls.PrimitivesButtonBase
System.Windows.ControlsButton
PostSharp.Patterns.Model.ControlsUndoRedoButtonBase
PostSharp.Patterns.Model.ControlsUndoButton

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class UndoButton : UndoRedoButtonBase

The UndoButton type exposes the following members.

Constructors
 | Name | Description
Public method | UndoButton | Initializes a new instance of the UndoButton class.
Top
Methods
 | Name | Description
Public method | OnApplyTemplate | When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate. (Inherited from UndoRedoButtonBase.)
Protected method | OnClick | Called when a Button is clicked. (Inherited from UndoRedoButtonBase.)
Protected method | OnKeyDown | Provides class handling for the KeyDown routed event that occurs when the user presses a key while this control has focus. (Inherited from UndoRedoButtonBase.)
Protected method | OnPropertyChanged | Raises the PropertyChanged event. (Inherited from UndoRedoButtonBase.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Protected property | IsEnabledCore | Gets the value of the IsEnabled property. (Inherited from UndoRedoButtonBase.)
Public property | IsListEnabled | Determines whether the button can be extended and display the list of operations that can be undone or redone. (Inherited from UndoRedoButtonBase.)
Public property | IsListExpanded | Determines whether the detailed list of operations is currently expanded. (Inherited from UndoRedoButtonBase.)
Public property | MaxOperationsCount | Gets or sets the maximal number of operations displayed by the current button. (Inherited from UndoRedoButtonBase.)
Public property | Operations | Gets the list of operations displayed by the current button when in expanded state. (Inherited from UndoRedoButtonBase.)
Public property | Recorder | Gets or sets the Recorder bound to the current control. (Inherited from UndoRedoButtonBase.)
Public property | UndoCommand | (Inherited from UndoRedoButtonBase.)
Top
Events
 | Name | Description
Public event | PropertyChanged | Occurs when a property value changes. (Inherited from UndoRedoButtonBase.)
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model.Controls Namespace


UndoButton Constructor

UndoButton Constructor
Initializes a new instance of the UndoButton class.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public UndoButton()
Version Information

Supported in: 4.1

See Also

Reference

UndoButton Class
PostSharp.Patterns.Model.Controls Namespace


UndoButton Methods

UndoButton Methods

The UndoButton type exposes the following members.

Methods
 | Name | Description
Public method | OnApplyTemplate | When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate. (Inherited from UndoRedoButtonBase.)
Protected method | OnClick | Called when a Button is clicked. (Inherited from UndoRedoButtonBase.)
Protected method | OnKeyDown | Provides class handling for the KeyDown routed event that occurs when the user presses a key while this control has focus. (Inherited from UndoRedoButtonBase.)
Protected method | OnPropertyChanged | Raises the PropertyChanged event. (Inherited from UndoRedoButtonBase.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

UndoButton Class
PostSharp.Patterns.Model.Controls Namespace


UndoButton Properties

UndoButton Properties

The UndoButton type exposes the following members.

Properties
 | Name | Description
Protected property | IsEnabledCore | Gets the value of the IsEnabled property. (Inherited from UndoRedoButtonBase.)
Public property | IsListEnabled | Determines whether the button can be extended and display the list of operations that can be undone or redone. (Inherited from UndoRedoButtonBase.)
Public property | IsListExpanded | Determines whether the detailed list of operations is currently expanded. (Inherited from UndoRedoButtonBase.)
Public property | MaxOperationsCount | Gets or sets the maximal number of operations displayed by the current button. (Inherited from UndoRedoButtonBase.)
Public property | Operations | Gets the list of operations displayed by the current button when in expanded state. (Inherited from UndoRedoButtonBase.)
Public property | Recorder | Gets or sets the Recorder bound to the current control. (Inherited from UndoRedoButtonBase.)
Public property | UndoCommand | (Inherited from UndoRedoButtonBase.)
Top
See Also

Reference

UndoButton Class
PostSharp.Patterns.Model.Controls Namespace


UndoButton Events

UndoButton Events

The UndoButton type exposes the following members.

Events
 | Name | Description
Public event | PropertyChanged | Occurs when a property value changes. (Inherited from UndoRedoButtonBase.)
Top
See Also

Reference

UndoButton Class
PostSharp.Patterns.Model.Controls Namespace


UndoCommand Class

UndoCommand Class
A command that undoes a single operation in a Recorder.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.Model.ControlsUndoRedoCommandBase
PostSharp.Patterns.Model.ControlsUndoCommand

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class UndoCommand : UndoRedoCommandBase

The UndoCommand type exposes the following members.

Constructors
 | Name | Description
Public method | UndoCommand | Initializes a new instance of the UndoCommand class and binds it to the DefaultRecorder.
Public method | UndoCommand(Recorder) | Initializes a new instance of the UndoCommand class and specifies to which Recorder it should be bound.
Top
Methods
 | Name | Description
Public method | CanExecute | Defines the method that determines whether the command can execute in its current state. (Inherited from UndoRedoCommandBase.)
Public method | Execute | Defines the method to be called when the command is invoked. (Inherited from UndoRedoCommandBase.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Recorder | Gets the Recorder bound to this command. (Inherited from UndoRedoCommandBase.)
Top
Events
 | Name | Description
Public event | CanExecuteChanged | Occurs when changes occur that affect whether or not the command should execute. (Inherited from UndoRedoCommandBase.)
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model.Controls Namespace


UndoCommand Constructor

UndoCommand Constructor
Overload List
 | Name | Description
Public method | UndoCommand | Initializes a new instance of the UndoCommand class and binds it to the DefaultRecorder.
Public method | UndoCommand(Recorder) | Initializes a new instance of the UndoCommand class and specifies to which Recorder it should be bound.
Top
See Also

Reference

UndoCommand Class
PostSharp.Patterns.Model.Controls Namespace


UndoCommand Constructor

UndoCommand Constructor
Initializes a new instance of the UndoCommand class and binds it to the DefaultRecorder.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public UndoCommand()
Version Information

Supported in: 4.1

See Also

Reference

UndoCommand Class
UndoCommand Overload
PostSharp.Patterns.Model.Controls Namespace


UndoCommand Constructor (Recorder)

UndoCommand Constructor (Recorder)
Initializes a new instance of the UndoCommand class and specifies to which Recorder it should be bound.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public UndoCommand(
    Recorder recorder
)

Parameters

recorder
Type: PostSharp.Patterns.RecordingRecorder
The Recorder to which the new UndoCommand should be bound.
Version Information

Supported in: 4.1

See Also

Reference

UndoCommand Class
UndoCommand Overload
PostSharp.Patterns.Model.Controls Namespace


UndoCommand Methods

UndoCommand Methods

The UndoCommand type exposes the following members.

Methods
 | Name | Description
Public method | CanExecute | Defines the method that determines whether the command can execute in its current state. (Inherited from UndoRedoCommandBase.)
Public method | Execute | Defines the method to be called when the command is invoked. (Inherited from UndoRedoCommandBase.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

UndoCommand Class
PostSharp.Patterns.Model.Controls Namespace


UndoCommand Properties

UndoCommand Properties

The UndoCommand type exposes the following members.

Properties
 | Name | Description
Public property | Recorder | Gets the Recorder bound to this command. (Inherited from UndoRedoCommandBase.)
Top
See Also

Reference

UndoCommand Class
PostSharp.Patterns.Model.Controls Namespace


UndoCommand Events

UndoCommand Events

The UndoCommand type exposes the following members.

Events
 | Name | Description
Public event | CanExecuteChanged | Occurs when changes occur that affect whether or not the command should execute. (Inherited from UndoRedoCommandBase.)
Top
See Also

Reference

UndoCommand Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase Class

UndoRedoButtonBase Class
Base class for UndoButton and RedoButton.
Inheritance Hierarchy
SystemObject
System.Windows.ThreadingDispatcherObject
System.WindowsDependencyObject
System.Windows.MediaVisual
System.WindowsUIElement
System.WindowsFrameworkElement
System.Windows.ControlsControl
System.Windows.ControlsContentControl
System.Windows.Controls.PrimitivesButtonBase
System.Windows.ControlsButton
PostSharp.Patterns.Model.ControlsUndoRedoButtonBase
PostSharp.Patterns.Model.ControlsRedoButton
PostSharp.Patterns.Model.ControlsUndoButton

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class UndoRedoButtonBase : Button,
    INotifyPropertyChanged

The UndoRedoButtonBase type exposes the following members.

Methods
 | Name | Description
Public method | OnApplyTemplate | When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate. (Overrides FrameworkElementOnApplyTemplate.)
Protected method | OnClick | Called when a Button is clicked. (Overrides ButtonOnClick.)
Protected method | OnKeyDown | Provides class handling for the KeyDown routed event that occurs when the user presses a key while this control has focus. (Overrides ButtonBaseOnKeyDown(KeyEventArgs).)
Protected method | OnPropertyChanged | Raises the PropertyChanged event.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
IsListEnabledProperty | Definition of the IsListEnabled property.
MaxOperationsCountProperty | Definition of the MaxOperationsCount property.
RecorderProperty | Definition of the Recorder property.
UndoCommandProperty |
Top
Properties
 | Name | Description
Protected property | IsEnabledCore | Gets the value of the IsEnabled property. (Overrides ButtonBaseIsEnabledCore.)
Public property | IsListEnabled | Determines whether the button can be extended and display the list of operations that can be undone or redone.
Public property | IsListExpanded | Determines whether the detailed list of operations is currently expanded.
Public property | MaxOperationsCount | Gets or sets the maximal number of operations displayed by the current button.
Public property | Operations | Gets the list of operations displayed by the current button when in expanded state.
Public property | Recorder | Gets or sets the Recorder bound to the current control.
Public property | UndoCommand |
Top
Events
 | Name | Description
Public event | PropertyChanged | Occurs when a property value changes.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase Fields

UndoRedoButtonBase Fields

The UndoRedoButtonBase type exposes the following members.

Fields
Name | Description
IsListEnabledProperty | Definition of the IsListEnabled property.
MaxOperationsCountProperty | Definition of the MaxOperationsCount property.
RecorderProperty | Definition of the Recorder property.
UndoCommandProperty |
Top
See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.IsListEnabledProperty Field

UndoRedoButtonBaseIsListEnabledProperty Field
Definition of the IsListEnabled property.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly DependencyProperty IsListEnabledProperty

Field Value

Type: DependencyProperty
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.MaxOperationsCountProperty Field

UndoRedoButtonBaseMaxOperationsCountProperty Field
Definition of the MaxOperationsCount property.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly DependencyProperty MaxOperationsCountProperty

Field Value

Type: DependencyProperty
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.RecorderProperty Field

UndoRedoButtonBaseRecorderProperty Field
Definition of the Recorder property.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly DependencyProperty RecorderProperty

Field Value

Type: DependencyProperty
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.UndoCommandProperty Field

UndoRedoButtonBaseUndoCommandProperty Field

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly DependencyProperty UndoCommandProperty

Field Value

Type: DependencyProperty
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase Methods

UndoRedoButtonBase Methods

The UndoRedoButtonBase type exposes the following members.

Methods
 | Name | Description
Public method | OnApplyTemplate | When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate. (Overrides FrameworkElementOnApplyTemplate.)
Protected method | OnClick | Called when a Button is clicked. (Overrides ButtonOnClick.)
Protected method | OnKeyDown | Provides class handling for the KeyDown routed event that occurs when the user presses a key while this control has focus. (Overrides ButtonBaseOnKeyDown(KeyEventArgs).)
Protected method | OnPropertyChanged | Raises the PropertyChanged event.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.OnApplyTemplate Method

UndoRedoButtonBaseOnApplyTemplate Method
When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void OnApplyTemplate()
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.OnClick Method

UndoRedoButtonBaseOnClick Method
Called when a Button is clicked.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override void OnClick()
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.OnKeyDown Method

UndoRedoButtonBaseOnKeyDown Method
Provides class handling for the KeyDown routed event that occurs when the user presses a key while this control has focus.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override void OnKeyDown(
    KeyEventArgs eventArgs
)

Parameters

eventArgs
Type: System.Windows.InputKeyEventArgs
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.OnPropertyChanged Method

UndoRedoButtonBaseOnPropertyChanged Method
Raises the PropertyChanged event.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void OnPropertyChanged(
    string propertyName
)

Parameters

propertyName
Type: SystemString
Name of the changed property.
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase Properties

UndoRedoButtonBase Properties

The UndoRedoButtonBase type exposes the following members.

Properties
 | Name | Description
Protected property | IsEnabledCore | Gets the value of the IsEnabled property. (Overrides ButtonBaseIsEnabledCore.)
Public property | IsListEnabled | Determines whether the button can be extended and display the list of operations that can be undone or redone.
Public property | IsListExpanded | Determines whether the detailed list of operations is currently expanded.
Public property | MaxOperationsCount | Gets or sets the maximal number of operations displayed by the current button.
Public property | Operations | Gets the list of operations displayed by the current button when in expanded state.
Public property | Recorder | Gets or sets the Recorder bound to the current control.
Public property | UndoCommand |
Top
See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.IsEnabledCore Property

UndoRedoButtonBaseIsEnabledCore Property
Gets the value of the IsEnabled property.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override bool IsEnabledCore { get; }

Return Value

Type: Boolean
true if the control is enabled; otherwise, false.
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.IsListEnabled Property

UndoRedoButtonBaseIsListEnabled Property
Determines whether the button can be extended and display the list of operations that can be undone or redone.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsListEnabled { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.IsListExpanded Property

UndoRedoButtonBaseIsListExpanded Property
Determines whether the detailed list of operations is currently expanded.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsListExpanded { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.MaxOperationsCount Property

UndoRedoButtonBaseMaxOperationsCount Property
Gets or sets the maximal number of operations displayed by the current button.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int MaxOperationsCount { get; set; }

Property Value

Type: Int32
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.Operations Property

UndoRedoButtonBaseOperations Property
Gets the list of operations displayed by the current button when in expanded state.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IEnumerable<Operation> Operations { get; }

Property Value

Type: IEnumerable Operation
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.Recorder Property

UndoRedoButtonBaseRecorder Property
Gets or sets the Recorder bound to the current control.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Recorder Recorder { get; set; }

Property Value

Type: Recorder
Remarks
When this property is not set, the ambient recorder is used.
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.UndoCommand Property

UndoRedoButtonBaseUndoCommand Property

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public UndoRedoCommandBase UndoCommand { get; }

Property Value

Type: UndoRedoCommandBase
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase Events

UndoRedoButtonBase Events

The UndoRedoButtonBase type exposes the following members.

Events
 | Name | Description
Public event | PropertyChanged | Occurs when a property value changes.
Top
See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoButtonBase.PropertyChanged Event

UndoRedoButtonBasePropertyChanged Event
Occurs when a property value changes.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public event PropertyChangedEventHandler PropertyChanged

Value

Type: System.ComponentModelPropertyChangedEventHandler

Implements

INotifyPropertyChangedPropertyChanged
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoButtonBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoCommandBase Class

UndoRedoCommandBase Class
Base class for UndoCommand and RedoCommand.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.Model.ControlsUndoRedoCommandBase
PostSharp.Patterns.Model.ControlsRedoCommand
PostSharp.Patterns.Model.ControlsUndoCommand

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class UndoRedoCommandBase : ICommand

The UndoRedoCommandBase type exposes the following members.

Methods
 | Name | Description
Public method | CanExecute | Defines the method that determines whether the command can execute in its current state.
Public method | Execute | Defines the method to be called when the command is invoked.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Recorder | Gets the Recorder bound to this command.
Top
Events
 | Name | Description
Public event | CanExecuteChanged | Occurs when changes occur that affect whether or not the command should execute.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Model.Controls Namespace


UndoRedoCommandBase Methods

UndoRedoCommandBase Methods

The UndoRedoCommandBase type exposes the following members.

Methods
 | Name | Description
Public method | CanExecute | Defines the method that determines whether the command can execute in its current state.
Public method | Execute | Defines the method to be called when the command is invoked.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

UndoRedoCommandBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoCommandBase.CanExecute Method

UndoRedoCommandBaseCanExecute Method
Defines the method that determines whether the command can execute in its current state.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CanExecute(
    Object parameter
)

Parameters

parameter
Type: SystemObject
Data used by the command. If the command does not require data to be passed, this object can be set to null.

Return Value

Type: Boolean
true if this command can be executed; otherwise, false.

Implements

ICommandCanExecute(Object)
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoCommandBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoCommandBase.Execute Method

UndoRedoCommandBaseExecute Method
Defines the method to be called when the command is invoked.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Execute(
    Object parameter
)

Parameters

parameter
Type: SystemObject
Data used by the command. If the command does not require data to be passed, this object can be set to null.

Implements

ICommandExecute(Object)
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoCommandBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoCommandBase Properties

UndoRedoCommandBase Properties

The UndoRedoCommandBase type exposes the following members.

Properties
 | Name | Description
Public property | Recorder | Gets the Recorder bound to this command.
Top
See Also

Reference

UndoRedoCommandBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoCommandBase.Recorder Property

UndoRedoCommandBaseRecorder Property
Gets the Recorder bound to this command.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Recorder Recorder { get; }

Property Value

Type: Recorder
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoCommandBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoCommandBase Events

UndoRedoCommandBase Events

The UndoRedoCommandBase type exposes the following members.

Events
 | Name | Description
Public event | CanExecuteChanged | Occurs when changes occur that affect whether or not the command should execute.
Top
See Also

Reference

UndoRedoCommandBase Class
PostSharp.Patterns.Model.Controls Namespace


UndoRedoCommandBase.CanExecuteChanged Event

UndoRedoCommandBaseCanExecuteChanged Event
Occurs when changes occur that affect whether or not the command should execute.

Namespace: PostSharp.Patterns.Model.Controls
Assembly: PostSharp.Patterns.Model.Controls (in PostSharp.Patterns.Model.Controls.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public event EventHandler CanExecuteChanged

Value

Type: SystemEventHandler

Implements

ICommandCanExecuteChanged
Version Information

Supported in: 4.1

See Also

Reference

UndoRedoCommandBase Class
PostSharp.Patterns.Model.Controls Namespace


PostSharp.Patterns.Recording Namespace

PostSharp.Patterns.Recording Namespace
The PostSharp.Patterns.Recording namespace implements the undo/redo feature.
Classes
 | Class | Description
Public class | EditableObjectAttribute | Custom attribute that, when applied to a class, implements IEditableObject into this class.
Public class | NotRecordedAttribute | Custom attribute that, when applied to field or property, specifies that it should not be affected by the RecordableAttribute aspect. Therefore, changes to this field or property will not be recorded into a Recorder, and will not be affected by undo/redo operations.
Public class | Operation | Base class for all operations. An operation is any change of state that can be appended to a Recorder and be therefore involved in an undo/redo operation.
Public class | OperationCollection | Read-only collection of operations (Operation). The class is exposed on the UndoOperations and RedoOperations properties.
Public class | OperationFormatter | Base class for all operation formatters, which provide a human-readable description of operations (Operation).
Public class | RecordableAttribute | Custom attribute that, when applied to a class, instruments fields and methods of this class so that it can be involved in undo/redo operations.
Public class | Recorder | Records changed done on an object model and allow to undo and redo them.
Public class | RecorderProvider | Abstract class that represents a node in the chain of responsibility, starting at the RecorderProvider property, whose role is to provide a default Recorder to recordable objects.
Public class | RecordingScope | Defines the scope a logical operation, that is, a set of change that should be undone or redone as a whole.
Public class | RecordingScopeAttribute | Custom attribute that, when applied to a method, defines the characteristics of the RecordingScope that corresponds to the target method.
Public class | RecordingServices | Provides global methods to work with the PostSharp.Patterns.Recording namespace.
Public class | ReplayContext | Represents the context of an undo or redo operation. The class gives access to system-defined and user-defined pieces of information.
Public class | RestorePoint | Represents a point to which operations can be undone or redone. A RestorePoint is a pseudo-Operation that does not represent any change.
Interfaces
 | Interface | Description
Public interface | IRecordable | Interface implemented by the RecordableAttribute aspect.
Public interface | IRecordableCallback | Defines callback methods that are invoked when a recordable object is involved in an undo or redo operation.
Enumerations
 | Enumeration | Description
Public enumeration | MergeStatus | Enumeration of possible return values for the GetMergeStatus(Operation) method.
Public enumeration | OperationKind | Enumeration of different kinds of Operation
Public enumeration | RecordingScopeOption | Enumerates the kinds of recording scope.
Public enumeration | ReplayKind | Enumerates the kind of situations in which the OnReplaying(ReplayKind, ReplayContext) or OnReplayed(ReplayKind, ReplayContext) methods are invoked.


EditableObjectAttribute Class

EditableObjectAttribute Class
Custom attribute that, when applied to a class, implements IEditableObject into this class.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.RecordingEditableObjectAttribute

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class EditableObjectAttribute : InstanceLevelAspect,
    IEditableObject, IAspectProvider, IAspect, IService

The EditableObjectAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | EditableObjectAttribute | Initializes a new instance of the EditableObjectAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Top
Remarks

This aspect implicitly adds the RecordableAttribute aspect to the target class, unless the aspect is already applied to this class.

The aspect is implemented by creating a restore point using the AddRestorePoint(String) method in the BeginEdit method, and undo using UndoTo(Operation) when the CancelEdit method is invoked. The implementation assumes that no other object being tracked by the same Recorder will be modified between calls to BeginEdit and CancelEdit, otherwise changes to these other objects will be canceled as well.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


EditableObjectAttribute Constructor

EditableObjectAttribute Constructor
Initializes a new instance of the EditableObjectAttribute class

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EditableObjectAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

EditableObjectAttribute Class
PostSharp.Patterns.Recording Namespace


EditableObjectAttribute Methods

EditableObjectAttribute Methods

The EditableObjectAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EditableObjectAttribute Class
PostSharp.Patterns.Recording Namespace


EditableObjectAttribute Properties

EditableObjectAttribute Properties

The EditableObjectAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Top
See Also

Reference

EditableObjectAttribute Class
PostSharp.Patterns.Recording Namespace


IRecordable Interface

IRecordable Interface
Interface implemented by the RecordableAttribute aspect.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IRecordable

The IRecordable type exposes the following members.

Methods
 | Name | Description
Public method | HasRecorder | Determines whether the current object is attached to a Recorder, if not, optionally attaches the object to the default Recorder.
Top
Properties
 | Name | Description
Public property | Recorder | Gets the recorder attached to the current object.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


IRecordable Methods

IRecordable Methods

The IRecordable type exposes the following members.

Methods
 | Name | Description
Public method | HasRecorder | Determines whether the current object is attached to a Recorder, if not, optionally attaches the object to the default Recorder.
Top
See Also

Reference

IRecordable Interface
PostSharp.Patterns.Recording Namespace


IRecordable.HasRecorder Method

IRecordableHasRecorder Method
Determines whether the current object is attached to a Recorder, if not, optionally attaches the object to the default Recorder.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool HasRecorder(
    bool autoAttach
)

Parameters

autoAttach
Type: SystemBoolean
true if the current object should be automatically attached to the default Recorder if it is not yet attached, otherwise false.

Return Value

Type: Boolean
true if the object is already attached to a Recorder or if autoAttach is true, otherwise false.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IRecordable Interface
PostSharp.Patterns.Recording Namespace


IRecordable Properties

IRecordable Properties

The IRecordable type exposes the following members.

Properties
 | Name | Description
Public property | Recorder | Gets the recorder attached to the current object.
Top
See Also

Reference

IRecordable Interface
PostSharp.Patterns.Recording Namespace


IRecordable.Recorder Property

IRecordableRecorder Property
Gets the recorder attached to the current object.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Recorder Recorder { get; set; }

Property Value

Type: Recorder
Remarks

Getting this property automatically attaches the object to the default Recorder if it is not yet attached. Use the HasRecorder(Boolean) method with the false argument to determine whether the object is already attached to a recorder.

Note Note
Named code should not invoke the setting of this property.

When this property is set, it is not the responsibility of the class implementing this interface to also set the property to all children. This responsibility belongs to the Recorder class

Version Information

Supported in: 4.1, 4.0

See Also

Reference

IRecordable Interface
PostSharp.Patterns.Recording Namespace


IRecordableCallback Interface

IRecordableCallback Interface
Defines callback methods that are invoked when a recordable object is involved in an undo or redo operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IRecordableCallback

The IRecordableCallback type exposes the following members.

Methods
 | Name | Description
Public method | OnReplayed | Method invoked after the undo or redo operation has started.
Public method | OnReplaying | Method invoked before the undo or redo operation has started.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


IRecordableCallback Methods

IRecordableCallback Methods

The IRecordableCallback type exposes the following members.

Methods
 | Name | Description
Public method | OnReplayed | Method invoked after the undo or redo operation has started.
Public method | OnReplaying | Method invoked before the undo or redo operation has started.
Top
See Also

Reference

IRecordableCallback Interface
PostSharp.Patterns.Recording Namespace


IRecordableCallback.OnReplayed Method

IRecordableCallbackOnReplayed Method
Method invoked after the undo or redo operation has started.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnReplayed(
    ReplayKind kind,
    ReplayContext context
)

Parameters

kind
Type: PostSharp.Patterns.RecordingReplayKind
Undo or Redo.
context
Type: PostSharp.Patterns.RecordingReplayContext
Reserved for future use.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IRecordableCallback Interface
PostSharp.Patterns.Recording Namespace


IRecordableCallback.OnReplaying Method

IRecordableCallbackOnReplaying Method
Method invoked before the undo or redo operation has started.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnReplaying(
    ReplayKind kind,
    ReplayContext context
)

Parameters

kind
Type: PostSharp.Patterns.RecordingReplayKind
Undo or Redo.
context
Type: PostSharp.Patterns.RecordingReplayContext
Reserved for future use.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IRecordableCallback Interface
PostSharp.Patterns.Recording Namespace


MergeStatus Enumeration

MergeStatus Enumeration
Enumeration of possible return values for the GetMergeStatus(Operation) method.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum MergeStatus
Members
Member name | Value | Description
None | 0 | The subsequent Operation cannot be merged and is not commutative with the current Operation.
Mergeable | 1 | The subsequent Operation can be merged into the current Operation (for instance, two subsequent changes to the same field).
Commutative | 2 | The subsequent Operation cannot be merged into the current Operation, but both operations are commutative (for instance, two subsequent changes to different fields).
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


NotRecordedAttribute Class

NotRecordedAttribute Class
Custom attribute that, when applied to field or property, specifies that it should not be affected by the RecordableAttribute aspect. Therefore, changes to this field or property will not be recorded into a Recorder, and will not be affected by undo/redo operations.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.Patterns.RecordingNotRecordedAttribute

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class NotRecordedAttribute : Attribute

The NotRecordedAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | NotRecordedAttribute | Initializes a new instance of the NotRecordedAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


NotRecordedAttribute Constructor

NotRecordedAttribute Constructor
Initializes a new instance of the NotRecordedAttribute class

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public NotRecordedAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

NotRecordedAttribute Class
PostSharp.Patterns.Recording Namespace


NotRecordedAttribute Methods

NotRecordedAttribute Methods

The NotRecordedAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

NotRecordedAttribute Class
PostSharp.Patterns.Recording Namespace


Operation Class

Operation Class
Base class for all operations. An operation is any change of state that can be appended to a Recorder and be therefore involved in an undo/redo operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
More...

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class Operation : IOperationDescriptor

The Operation type exposes the following members.

Constructors
 | Name | Description
Protected method | Operation | Initializes a new instance of the Operation class.
Top
Methods
 | Name | Description
Protected method | GetMergeStatus | Determines how a given Operation can be merged with the current Operation.
Protected method | Merge | Merges a given Operation into the current Operation.
Protected method | Redo | Redo the current operation.
Protected method | Undo | Undo the current operation.
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Name | Gets the operation name.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation.
Public property | OperationKind | Gets the kind of operation.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsCollectionOperationT
PostSharp.Patterns.Recording.OperationsCompositeOperation
PostSharp.Patterns.Recording.OperationsDictionaryOperationTKey, TValue
PostSharp.Patterns.Recording.OperationsFieldOperationT
PostSharp.Patterns.Recording.OperationsRecorderOperation
PostSharp.Patterns.RecordingRestorePoint


Operation Constructor

Operation Constructor
Initializes a new instance of the Operation class.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected Operation()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


Operation Methods

Operation Methods

The Operation type exposes the following members.

Methods
 | Name | Description
Protected method | GetMergeStatus | Determines how a given Operation can be merged with the current Operation.
Protected method | Merge | Merges a given Operation into the current Operation.
Protected method | Redo | Redo the current operation.
Protected method | Undo | Undo the current operation.
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


Operation.GetMergeStatus Method

OperationGetMergeStatus Method
Determines how a given Operation can be merged with the current Operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual MergeStatus GetMergeStatus(
    Operation subsequent
)

Parameters

subsequent
Type: PostSharp.Patterns.RecordingOperation
The subsequent Operation to be merged with the current one.

Return Value

Type: MergeStatus
A MergeStatus.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


Operation.Merge Method

OperationMerge Method
Merges a given Operation into the current Operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void Merge(
    Operation subsequent
)

Parameters

subsequent
Type: PostSharp.Patterns.RecordingOperation
The Operation to merge into the current one.
Remarks

This method is invoked only if the GetMergeStatus(Operation) method returned MergeStatus.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


Operation.Redo Method

OperationRedo Method
Redo the current operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected abstract void Redo(
    ReplayContext context
)

Parameters

context
Type: PostSharp.Patterns.RecordingReplayContext
Reserved for future use.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


Operation.Undo Method

OperationUndo Method
Undo the current operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected abstract void Undo(
    ReplayContext context
)

Parameters

context
Type: PostSharp.Patterns.RecordingReplayContext
Reserved for future use.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


Operation.VisitAffectedObjects Method

OperationVisitAffectedObjects Method
Executes a given action on all recordable objects involved with the current Operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void VisitAffectedObjects(
    Action<Object> action
)

Parameters

action
Type: SystemAction Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


Operation Properties

Operation Properties

The Operation type exposes the following members.

Properties
 | Name | Description
Public property | Name | Gets the operation name.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation.
Public property | OperationKind | Gets the kind of operation.
Top
See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


Operation.Name Property

OperationName Property
Gets the operation name.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Name { get; }

Property Value

Type: String
Remarks

Operation names are lazily evaluated thanks to the OperationFormatter.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


Operation.OperationDescriptor Property

OperationOperationDescriptor Property
Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual IOperationDescriptor OperationDescriptor { get; }

Property Value

Type: IOperationDescriptor
Remarks

By default, the OperationDescriptor property returns the current Operation.

When the Operation represents a user-defined scope, the property evaluates to an instance of the NamedOperationDescriptor class. When it represents a method scope, it evaluates to an instance of the MethodExecutionOperationDescriptor class.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


Operation.OperationKind Property

OperationOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Operation Class
PostSharp.Patterns.Recording Namespace


OperationCollection Class

OperationCollection Class
Read-only collection of operations (Operation). The class is exposed on the UndoOperations and RedoOperations properties.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperationCollection

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class OperationCollection : ICollection<Operation>,
    IEnumerable<Operation>, IEnumerable, INotifyPropertyChanged, INotifyCollectionChanged

The OperationCollection type exposes the following members.

Methods
 | Name | Description
Public method | CopyTo | Copies the elements of the ICollectionT to an Array, starting at a particular Array index.
Public method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public method | Trim(Int32) | Trims the current collection to a given maximal number of operations.
Public method | Trim(RestorePoint) | Trims the current collection to a specified RestorePoint.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Count | Gets the number of elements contained in the ICollectionT.
Public property | IsReadOnly | Gets a value indicating whether the ICollectionT is read-only.
Top
Events
 | Name | Description
Public event | CollectionChanged | Occurs when the collection changes.
Public event | PropertyChanged | Occurs when a property value changes.
Top
Remarks

Additionally to traditional collection members, this class exposes the Trim(Int32) method, which allows to trim the collection of UndoOperations or RedoOperations.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


OperationCollection Methods

OperationCollection Methods

The OperationCollection type exposes the following members.

Methods
 | Name | Description
Public method | CopyTo | Copies the elements of the ICollectionT to an Array, starting at a particular Array index.
Public method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public method | Trim(Int32) | Trims the current collection to a given maximal number of operations.
Public method | Trim(RestorePoint) | Trims the current collection to a specified RestorePoint.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OperationCollection Class
PostSharp.Patterns.Recording Namespace


OperationCollection.CopyTo Method

OperationCollectionCopyTo Method
Copies the elements of the ICollectionT to an Array, starting at a particular Array index.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void CopyTo(
    Operation[] array,
    int arrayIndex
)

Parameters

array
Type: PostSharp.Patterns.RecordingOperation
The one-dimensional Array that is the destination of the elements copied from ICollectionT. The Array must have zero-based indexing.
arrayIndex
Type: SystemInt32
The zero-based index in array at which copying begins.

Implements

ICollectionTCopyTo(T, Int32)
Exceptions
Exception | Condition
ArgumentNullException | array is null.
ArgumentOutOfRangeException | arrayIndex is less than 0.
ArgumentException | The number of elements in the source ICollectionT is greater than the available space from arrayIndex to the end of the destination array.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationCollection Class
PostSharp.Patterns.Recording Namespace


OperationCollection.GetEnumerator Method

OperationCollectionGetEnumerator Method
Returns an enumerator that iterates through the collection.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IEnumerator<Operation> GetEnumerator()

Return Value

Type: IEnumerator Operation
A IEnumeratorT that can be used to iterate through the collection.

Implements

IEnumerableTGetEnumerator
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationCollection Class
PostSharp.Patterns.Recording Namespace


OperationCollection.Trim Method

OperationCollectionTrim Method
Overload List
 | Name | Description
Public method | Trim(Int32) | Trims the current collection to a given maximal number of operations.
Public method | Trim(RestorePoint) | Trims the current collection to a specified RestorePoint.
Top
See Also

Reference

OperationCollection Class
PostSharp.Patterns.Recording Namespace


OperationCollection.Trim Method (Int32)

OperationCollectionTrim Method (Int32)
Trims the current collection to a given maximal number of operations.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Trim(
    int count
)

Parameters

count
Type: SystemInt32
The maximal number of operations to keep in the collection.
Remarks
Note Note
The UndoOperations collection is automatically trimmed to the value of MaximumOperationsCount property.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationCollection Class
Trim Overload
PostSharp.Patterns.Recording Namespace


OperationCollection.Trim Method (RestorePoint)

OperationCollectionTrim Method (RestorePoint)
Trims the current collection to a specified RestorePoint.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Trim(
    RestorePoint restorePoint
)

Parameters

restorePoint
Type: PostSharp.Patterns.RecordingRestorePoint
A token to the RestorePoint to which the current collection should be trimmed.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationCollection Class
Trim Overload
PostSharp.Patterns.Recording Namespace


OperationCollection Properties

OperationCollection Properties

The OperationCollection type exposes the following members.

Properties
 | Name | Description
Public property | Count | Gets the number of elements contained in the ICollectionT.
Public property | IsReadOnly | Gets a value indicating whether the ICollectionT is read-only.
Top
See Also

Reference

OperationCollection Class
PostSharp.Patterns.Recording Namespace


OperationCollection.Count Property

OperationCollectionCount Property
Gets the number of elements contained in the ICollectionT.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int Count { get; }

Return Value

Type: Int32
The number of elements contained in the ICollectionT.

Implements

ICollectionTCount
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationCollection Class
PostSharp.Patterns.Recording Namespace


OperationCollection.IsReadOnly Property

OperationCollectionIsReadOnly Property
Gets a value indicating whether the ICollectionT is read-only.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsReadOnly { get; }

Return Value

Type: Boolean
true if the ICollectionT is read-only; otherwise, false.

Implements

ICollectionTIsReadOnly
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationCollection Class
PostSharp.Patterns.Recording Namespace


OperationCollection Events

OperationCollection Events

The OperationCollection type exposes the following members.

Events
 | Name | Description
Public event | CollectionChanged | Occurs when the collection changes.
Public event | PropertyChanged | Occurs when a property value changes.
Top
See Also

Reference

OperationCollection Class
PostSharp.Patterns.Recording Namespace


OperationCollection.CollectionChanged Event

OperationCollectionCollectionChanged Event
Occurs when the collection changes.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public event NotifyCollectionChangedEventHandler CollectionChanged

Value

Type: System.Collections.SpecializedNotifyCollectionChangedEventHandler

Implements

INotifyCollectionChangedCollectionChanged
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationCollection Class
PostSharp.Patterns.Recording Namespace


OperationCollection.PropertyChanged Event

OperationCollectionPropertyChanged Event
Occurs when a property value changes.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public event PropertyChangedEventHandler PropertyChanged

Value

Type: System.ComponentModelPropertyChangedEventHandler

Implements

INotifyPropertyChangedPropertyChanged
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationCollection Class
PostSharp.Patterns.Recording Namespace


OperationFormatter Class

OperationFormatter Class
Base class for all operation formatters, which provide a human-readable description of operations (Operation).
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperationFormatter

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class OperationFormatter

The OperationFormatter type exposes the following members.

Constructors
 | Name | Description
Protected method | OperationFormatter | Initializes a new instance of the OperationFormatter class.
Top
Methods
 | Name | Description
Public method | FormatOperation | Gets a human-readable description of an Operation.
Protected method | FormatOperationDescriptor | Gets a human-readable description of an Operation given its IOperationDescriptor.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks

Instances of the OperationFormatter class form a chain of responsibility. If one instance does not know how to format an Operation, it calls the next instance in the chain.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


OperationFormatter Constructor

OperationFormatter Constructor
Initializes a new instance of the OperationFormatter class.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected OperationFormatter(
    OperationFormatter next
)

Parameters

next
Type: PostSharp.Patterns.RecordingOperationFormatter
The next instance in the chain of responsibility.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationFormatter Class
PostSharp.Patterns.Recording Namespace


OperationFormatter Methods

OperationFormatter Methods

The OperationFormatter type exposes the following members.

Methods
 | Name | Description
Public method | FormatOperation | Gets a human-readable description of an Operation.
Protected method | FormatOperationDescriptor | Gets a human-readable description of an Operation given its IOperationDescriptor.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

OperationFormatter Class
PostSharp.Patterns.Recording Namespace


OperationFormatter.FormatOperation Method

OperationFormatterFormatOperation Method
Gets a human-readable description of an Operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string FormatOperation(
    Operation operation
)

Parameters

operation
Type: PostSharp.Patterns.RecordingOperation
The Operation.

Return Value

Type: String
A human-readable description of the Operation.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationFormatter Class
PostSharp.Patterns.Recording Namespace


OperationFormatter.FormatOperationDescriptor Method

OperationFormatterFormatOperationDescriptor Method
Gets a human-readable description of an Operation given its IOperationDescriptor.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected abstract string FormatOperationDescriptor(
    IOperationDescriptor operation
)

Parameters

operation
Type: PostSharp.Patterns.Recording.OperationsIOperationDescriptor
The operation descriptor.

Return Value

Type: String
A human-readable description for operation, or null if the current OperationFormatter does not know how to format operation, in which case the next OperationFormatter in the chain of responsibility will be invoked.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

OperationFormatter Class
PostSharp.Patterns.Recording Namespace


OperationKind Enumeration

OperationKind Enumeration
Enumeration of different kinds of Operation

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum OperationKind
Members
Member name | Value | Description
AttachRecorderToObject | 0 | AttachObjectToRecorderOperation
ClearCollection | 1 | ClearCollectionOperationT
Composite | 2 | CompositeOperation
DetachRecorderFromObject | 3 | DetachObjectFromRecorderOperation
Field | 4 | FieldOperationT
InsertCollectionItem | 5 | AddCollectionItemOperationT
RemoveCollectionItem | 6 | RemoveCollectionItemOperationT
SetCollectionItem | 7 | SetCollectionItemOperationT
RestorePoint | 8 | RestorePoint
Method | 9 | MethodExecutionOperationDescriptor
Named | 10 | NamedOperationDescriptor
InsertDictionaryItem | 11 | AddDictionaryItemOperationTKey, TValue
RemoveDictionaryItem | 12 |
SetDictionaryItem | 13 | SetDictionaryItemOperationTKey, TValue
ClearDictionary | 14 | ClearDictionaryOperationTKey, TValue
Other | 65536 | User-defined operation. Any value higher than Other is acceptable.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


RecordableAttribute Class

RecordableAttribute Class
Custom attribute that, when applied to a class, instruments fields and methods of this class so that it can be involved in undo/redo operations.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.RecordingRecordableAttribute

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class RecordableAttribute : InstanceLevelAspect,
    IRecordable, IAspectProvider, IAspect, IService

The RecordableAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | RecordableAttribute | Initializes a new instance of the class.
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Overrides TypeLevelAspectCompileTimeInitialize(Type, AspectInfo).)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | AutoRecord | Determines whether changes in this object must be recorded as soon as the object constructor has completed.
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | ProvideMethodContext | Determines whether full method invocation context is provided to the MethodExecutionOperationDescriptor class for use in a custom OperationFormatter. This property is set to false by default for performance reasons.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace
PostSharp.Patterns.RecordingRecorder


RecordableAttribute Constructor

RecordableAttribute Constructor
Initializes a new instance of the class.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RecordableAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordableAttribute Class
PostSharp.Patterns.Recording Namespace
PostSharp.Patterns.RecordingRecordableAttribute


RecordableAttribute Methods

RecordableAttribute Methods

The RecordableAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Overrides TypeLevelAspectCompileTimeInitialize(Type, AspectInfo).)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RecordableAttribute Class
PostSharp.Patterns.Recording Namespace


RecordableAttribute.CompileTimeInitialize Method

RecordableAttributeCompileTimeInitialize Method
Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void CompileTimeInitialize(
    Type type,
    AspectInfo aspectInfo
)

Parameters

type
Type: SystemType
Type to which the current aspect is applied
aspectInfo
Type: PostSharp.AspectsAspectInfo
Reserved for future usage.

Implements

ITypeLevelAspectBuildSemanticsCompileTimeInitialize(Type, AspectInfo)
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordableAttribute Class
PostSharp.Patterns.Recording Namespace

Other Resources

Conceptual Documentation: Initializing Aspects


RecordableAttribute Properties

RecordableAttribute Properties

The RecordableAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | AutoRecord | Determines whether changes in this object must be recorded as soon as the object constructor has completed.
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | ProvideMethodContext | Determines whether full method invocation context is provided to the MethodExecutionOperationDescriptor class for use in a custom OperationFormatter. This property is set to false by default for performance reasons.
Top
See Also

Reference

RecordableAttribute Class
PostSharp.Patterns.Recording Namespace


RecordableAttribute.AutoRecord Property

RecordableAttributeAutoRecord Property
Determines whether changes in this object must be recorded as soon as the object constructor has completed.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool AutoRecord { get; set; }

Property Value

Type: Boolean
Remarks

If this property is set to true, a Recorder will be automatically assigned to the target instance using the OperationFormatter. Set this property to false if you need to assign the Recorder manually.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordableAttribute Class
PostSharp.Patterns.Recording Namespace


RecordableAttribute.ProvideMethodContext Property

RecordableAttributeProvideMethodContext Property
Determines whether full method invocation context is provided to the MethodExecutionOperationDescriptor class for use in a custom OperationFormatter. This property is set to false by default for performance reasons.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool ProvideMethodContext { get; set; }

Property Value

Type: Boolean
Remarks

This property applies to all public methods of the target class.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordableAttribute Class
PostSharp.Patterns.Recording Namespace


Recorder Class

Recorder Class
Records changed done on an object model and allow to undo and redo them.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingRecorder

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class Recorder : INotifyPropertyChanged

The Recorder type exposes the following members.

Constructors
 | Name | Description
Public method | Recorder | Initializes a new instance of the Recorder class.
Public method | Recorder(Object) | Initializes a new instance of the Recorder class and attaches it to a given object.
Top
Methods
 | Name | Description
Public method | AddOperation | Adds a new Operation to UndoOperations collection of the current Recorder.
Public method | AddRestorePoint | Adds new restore point with given name.
Public method | Attach | Attaches a recordable object (including its descendant objects) to the current Recorder so that changes in this objects start being recorded into the current Recorder.
Public method | Clear | Clears undo and redo lists.
Public method | Detach | Detaches a recordable object from the current Recorder, so that changes in this objects stop being recorded into the current Recorder.
Public method | OpenScope(RecordingScopeOption) | Opens an unnamed RecordingScope.
Public method | OpenScope(String, RecordingScopeOption) | Opens a RecordingScope with a given name.
Public method | Redo | Redo last operation.
Public method | RedoTo | redo all operation to specific operation.
Public method | Undo | Undo last operation.
Public method | UndoTo | Undo all operations to specific Operation or RestorePoint.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | CanAddRestorePoint | Determines if the AddRestorePoint(String) method can be invoked.
Public property | CanRedo | Determines if the Redo method can be invoked.
Public property | CanUndo | Determines if the Undo method can be invoked.
Public property | MaximumOperationsCount | Gets the maximum number of operations in the UndoOperations and RedoOperations collections. These collections are automatically trimmed so that their size never exceeds MaximumOperationsCount.
Public property | RedoOperations | Gets the collection of operations that can be redone using the Redo method.
Public property | UndoOperations | Gets the collection of operations that can be undone using the Undo method.
Top
Events
 | Name | Description
Public event | PropertyChanged | Occurs when a property value changes.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


Recorder Constructor

Recorder Constructor
Overload List
 | Name | Description
Public method | Recorder | Initializes a new instance of the Recorder class.
Public method | Recorder(Object) | Initializes a new instance of the Recorder class and attaches it to a given object.
Top
See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder Constructor

Recorder Constructor
Initializes a new instance of the Recorder class.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Recorder()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
Recorder Overload
PostSharp.Patterns.Recording Namespace


Recorder Constructor (Object)

Recorder Constructor (Object)
Initializes a new instance of the Recorder class and attaches it to a given object.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Recorder(
    Object owner
)

Parameters

owner
Type: SystemObject
The object to which the new Recorder should be attached.
Remarks

The Recorder created using this constructor will be private to its owner, that is, no other object than owner and descendants of owner will be allowed to be attached to this Recorder.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
Recorder Overload
PostSharp.Patterns.Recording Namespace


Recorder Methods

Recorder Methods

The Recorder type exposes the following members.

Methods
 | Name | Description
Public method | AddOperation | Adds a new Operation to UndoOperations collection of the current Recorder.
Public method | AddRestorePoint | Adds new restore point with given name.
Public method | Attach | Attaches a recordable object (including its descendant objects) to the current Recorder so that changes in this objects start being recorded into the current Recorder.
Public method | Clear | Clears undo and redo lists.
Public method | Detach | Detaches a recordable object from the current Recorder, so that changes in this objects stop being recorded into the current Recorder.
Public method | OpenScope(RecordingScopeOption) | Opens an unnamed RecordingScope.
Public method | OpenScope(String, RecordingScopeOption) | Opens a RecordingScope with a given name.
Public method | Redo | Redo last operation.
Public method | RedoTo | redo all operation to specific operation.
Public method | Undo | Undo last operation.
Public method | UndoTo | Undo all operations to specific Operation or RestorePoint.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.AddOperation Method

RecorderAddOperation Method
Adds a new Operation to UndoOperations collection of the current Recorder.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void AddOperation(
    Operation operation
)

Parameters

operation
Type: PostSharp.Patterns.RecordingOperation
The operation.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.AddRestorePoint Method

RecorderAddRestorePoint Method
Adds new restore point with given name.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RestorePoint AddRestorePoint(
    string name = null
)

Parameters

name (Optional)
Type: SystemString
The name of the restore point, or null to create an unnamed restore point.

Return Value

Type: RestorePoint
The newly created RestorePoint.
Remarks

A RestorePoint can be used as an argument to the UndoTo(Operation) or RedoTo(Operation) method.

To remove a RestorePoint from UndoOperations or RedoOperations, call the Remove method.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.Attach Method

RecorderAttach Method
Attaches a recordable object (including its descendant objects) to the current Recorder so that changes in this objects start being recorded into the current Recorder.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Attach(
    Object obj
)

Parameters

obj
Type: SystemObject
The recordable object whose changes need to be recorded into the current Recorder.
Remarks

This method implicitly attaches all descendants of obj to the current Recorder.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.Clear Method

RecorderClear Method
Clears undo and redo lists.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Clear()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.Detach Method

RecorderDetach Method
Detaches a recordable object from the current Recorder, so that changes in this objects stop being recorded into the current Recorder.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Detach(
    Object obj
)

Parameters

obj
Type: SystemObject
The recordable object whose changes no longer need to be recorded into the current Recorder.
Remarks

This method implicitly detaches all descendants of obj from the current Recorder.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.OpenScope Method

RecorderOpenScope Method
Overload List
 | Name | Description
Public method | OpenScope(RecordingScopeOption) | Opens an unnamed RecordingScope.
Public method | OpenScope(String, RecordingScopeOption) | Opens a RecordingScope with a given name.
Top
See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.OpenScope Method (RecordingScopeOption)

RecorderOpenScope Method (RecordingScopeOption)
Opens an unnamed RecordingScope.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RecordingScope OpenScope(
    RecordingScopeOption option = RecordingScopeOption.Default
)

Parameters

option (Optional)
Type: PostSharp.Patterns.RecordingRecordingScopeOption
Scope options. Specify this parameter if you want the scope to be Atomic.

Return Value

Type: RecordingScope
A RecordingScope object, which should be closed using Complete or Dispose.
Remarks

The name of the scope can be set at any time by setting the OperationDescriptor property.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
OpenScope Overload
PostSharp.Patterns.Recording Namespace


Recorder.OpenScope Method (String, RecordingScopeOption)

RecorderOpenScope Method (String, RecordingScopeOption)
Opens a RecordingScope with a given name.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RecordingScope OpenScope(
    string name,
    RecordingScopeOption option = RecordingScopeOption.Default
)

Parameters

name
Type: SystemString
The scope name, or null to create an unnamed scope.
option (Optional)
Type: PostSharp.Patterns.RecordingRecordingScopeOption
Scope options. Specify this parameter if you want the scope to be Atomic.

Return Value

Type: RecordingScope
A RecordingScope object, which should be closed using Complete or Dispose.
Remarks

The name of the scope can be set at any time by setting the OperationDescriptor property.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
OpenScope Overload
PostSharp.Patterns.Recording Namespace


Recorder.Redo Method

RecorderRedo Method
Redo last operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Redo()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.RedoTo Method

RecorderRedoTo Method
redo all operation to specific operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void RedoTo(
    Operation operation
)

Parameters

operation
Type: PostSharp.Patterns.RecordingOperation
the operation.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.Undo Method

RecorderUndo Method
Undo last operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Undo()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.UndoTo Method

RecorderUndoTo Method
Undo all operations to specific Operation or RestorePoint.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void UndoTo(
    Operation operation
)

Parameters

operation
Type: PostSharp.Patterns.RecordingOperation
the operation.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder Properties

Recorder Properties

The Recorder type exposes the following members.

Properties
 | Name | Description
Public property | CanAddRestorePoint | Determines if the AddRestorePoint(String) method can be invoked.
Public property | CanRedo | Determines if the Redo method can be invoked.
Public property | CanUndo | Determines if the Undo method can be invoked.
Public property | MaximumOperationsCount | Gets the maximum number of operations in the UndoOperations and RedoOperations collections. These collections are automatically trimmed so that their size never exceeds MaximumOperationsCount.
Public property | RedoOperations | Gets the collection of operations that can be redone using the Redo method.
Public property | UndoOperations | Gets the collection of operations that can be undone using the Undo method.
Top
See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.CanAddRestorePoint Property

RecorderCanAddRestorePoint Property
Determines if the AddRestorePoint(String) method can be invoked.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CanAddRestorePoint { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.CanRedo Property

RecorderCanRedo Property
Determines if the Redo method can be invoked.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CanRedo { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.CanUndo Property

RecorderCanUndo Property
Determines if the Undo method can be invoked.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CanUndo { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.MaximumOperationsCount Property

RecorderMaximumOperationsCount Property
Gets the maximum number of operations in the UndoOperations and RedoOperations collections. These collections are automatically trimmed so that their size never exceeds MaximumOperationsCount.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int MaximumOperationsCount { get; set; }

Property Value

Type: Int32
The default value is int.MaxValue.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.RedoOperations Property

RecorderRedoOperations Property
Gets the collection of operations that can be redone using the Redo method.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OperationCollection RedoOperations { get; }

Property Value

Type: OperationCollection
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.UndoOperations Property

RecorderUndoOperations Property
Gets the collection of operations that can be undone using the Undo method.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OperationCollection UndoOperations { get; }

Property Value

Type: OperationCollection
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder Events

Recorder Events

The Recorder type exposes the following members.

Events
 | Name | Description
Public event | PropertyChanged | Occurs when a property value changes.
Top
See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


Recorder.PropertyChanged Event

RecorderPropertyChanged Event
Occurs when a property value changes.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public event PropertyChangedEventHandler PropertyChanged

Value

Type: System.ComponentModelPropertyChangedEventHandler

Implements

INotifyPropertyChangedPropertyChanged
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Recorder Class
PostSharp.Patterns.Recording Namespace


RecorderProvider Class

RecorderProvider Class
Abstract class that represents a node in the chain of responsibility, starting at the RecorderProvider property, whose role is to provide a default Recorder to recordable objects.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingRecorderProvider

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class RecorderProvider

The RecorderProvider type exposes the following members.

Constructors
 | Name | Description
Protected method | RecorderProvider | Initializes a new instance of the RecorderProvider class.
Top
Methods
 | Name | Description
Public method | GetRecorder | Gets the default Recorder for a given object. This method goes through the whole chain of responsibility.
Protected method | GetRecorderCore | Gets the default Recorder for a given object.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


RecorderProvider Constructor

RecorderProvider Constructor
Initializes a new instance of the RecorderProvider class.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected RecorderProvider(
    RecorderProvider next
)

Parameters

next
Type: PostSharp.Patterns.RecordingRecorderProvider
Next instance in the chain of responsibility.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecorderProvider Class
PostSharp.Patterns.Recording Namespace


RecorderProvider Methods

RecorderProvider Methods

The RecorderProvider type exposes the following members.

Methods
 | Name | Description
Public method | GetRecorder | Gets the default Recorder for a given object. This method goes through the whole chain of responsibility.
Protected method | GetRecorderCore | Gets the default Recorder for a given object.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RecorderProvider Class
PostSharp.Patterns.Recording Namespace


RecorderProvider.GetRecorder Method

RecorderProviderGetRecorder Method
Gets the default Recorder for a given object. This method goes through the whole chain of responsibility.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Recorder GetRecorder(
    Object obj
)

Parameters

obj
Type: SystemObject
The object for which the default Recorder is required, or null if the global default provider (exposed for convenience on the DefaultRecorder) property if required.

Return Value

Type: Recorder
The Recorder for obj, or null if no RecorderProvider in the chain of responsibility knows how to provide a Recorder for obj.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecorderProvider Class
PostSharp.Patterns.Recording Namespace


RecorderProvider.GetRecorderCore Method

RecorderProviderGetRecorderCore Method
Gets the default Recorder for a given object.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected abstract Recorder GetRecorderCore(
    Object obj
)

Parameters

obj
Type: SystemObject
The object for which the default Recorder is required, or null if the global default provider (exposed for convenience on the DefaultRecorder) property if required.

Return Value

Type: Recorder
The Recorder for obj, or null if the current RecorderProvider does not know how to provide a Recorder for obj, in which case the caller shall invoke the next RecorderProvider in the chain of responsibility.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecorderProvider Class
PostSharp.Patterns.Recording Namespace


RecordingScope Class

RecordingScope Class
Defines the scope a logical operation, that is, a set of change that should be undone or redone as a whole.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingRecordingScope

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class RecordingScope : IDisposable

The RecordingScope type exposes the following members.

Methods
 | Name | Description
Public method | Complete | Closes the current RecordingScope and mark it as successful.
Public method | Dispose | Closes the current RecordingScope.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | OperationDescriptor | Gets or sets the IOperationDescriptor for the current scope.
Top
Remarks

Scopes can be defined declaratively using the RecordingScopeAttribute custom attribute.

To open a scope imperatively, use the OpenScope(RecordingScopeOption) method. Use the Complete or Dispose method to close the scope.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


RecordingScope Methods

RecordingScope Methods

The RecordingScope type exposes the following members.

Methods
 | Name | Description
Public method | Complete | Closes the current RecordingScope and mark it as successful.
Public method | Dispose | Closes the current RecordingScope.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RecordingScope Class
PostSharp.Patterns.Recording Namespace


RecordingScope.Complete Method

RecordingScopeComplete Method
Closes the current RecordingScope and mark it as successful.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Complete()
Remarks

It allowed but unnecessary to call the Dispose method after the Complete method.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordingScope Class
PostSharp.Patterns.Recording Namespace


RecordingScope.Dispose Method

RecordingScopeDispose Method
Closes the current RecordingScope.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Dispose()

Implements

IDisposableDispose
Remarks

If the current RecordingScope is atomic, invoking Dispose without Complete will undo all changes done in the current scope. In other words, Dispose without Complete has rollback semantics.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordingScope Class
PostSharp.Patterns.Recording Namespace


RecordingScope Properties

RecordingScope Properties

The RecordingScope type exposes the following members.

Properties
 | Name | Description
Public property | OperationDescriptor | Gets or sets the IOperationDescriptor for the current scope.
Top
See Also

Reference

RecordingScope Class
PostSharp.Patterns.Recording Namespace


RecordingScope.OperationDescriptor Property

RecordingScopeOperationDescriptor Property
Gets or sets the IOperationDescriptor for the current scope.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IOperationDescriptor OperationDescriptor { get; set; }

Property Value

Type: IOperationDescriptor
Remarks

To set the name of the current scope, assign this property to an instance of the NamedOperationDescriptor class.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordingScope Class
PostSharp.Patterns.Recording Namespace


RecordingScopeAttribute Class

RecordingScopeAttribute Class
Custom attribute that, when applied to a method, defines the characteristics of the RecordingScope that corresponds to the target method.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.RecordingRecordingScopeAttribute

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class RecordingScopeAttribute : MulticastAttribute

The RecordingScopeAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | RecordingScopeAttribute(RecordingScopeOption) | Initializes a new instance of the RecordingScopeAttribute.
Public method | RecordingScopeAttribute(String, RecordingScopeOption) | Initializes a new instance of the RecordingScopeAttribute class and specify the scope name.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Name | Gets the scope name.
Public property | Option | Gets the scope option.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


RecordingScopeAttribute Constructor

RecordingScopeAttribute Constructor
Overload List
 | Name | Description
Public method | RecordingScopeAttribute(RecordingScopeOption) | Initializes a new instance of the RecordingScopeAttribute.
Public method | RecordingScopeAttribute(String, RecordingScopeOption) | Initializes a new instance of the RecordingScopeAttribute class and specify the scope name.
Top
See Also

Reference

RecordingScopeAttribute Class
PostSharp.Patterns.Recording Namespace


RecordingScopeAttribute Constructor (RecordingScopeOption)

RecordingScopeAttribute Constructor (RecordingScopeOption)
Initializes a new instance of the RecordingScopeAttribute.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RecordingScopeAttribute(
    RecordingScopeOption option
)

Parameters

option
Type: PostSharp.Patterns.RecordingRecordingScopeOption
Scope options. Typically Atomic or Skip.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordingScopeAttribute Class
RecordingScopeAttribute Overload
PostSharp.Patterns.Recording Namespace


RecordingScopeAttribute Constructor (String, RecordingScopeOption)

RecordingScopeAttribute Constructor (String, RecordingScopeOption)
Initializes a new instance of the RecordingScopeAttribute class and specify the scope name.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RecordingScopeAttribute(
    string name,
    RecordingScopeOption option = RecordingScopeOption.Default
)

Parameters

name
Type: SystemString
The scope name, or null.
option (Optional)
Type: PostSharp.Patterns.RecordingRecordingScopeOption
Scope options.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordingScopeAttribute Class
RecordingScopeAttribute Overload
PostSharp.Patterns.Recording Namespace


RecordingScopeAttribute Methods

RecordingScopeAttribute Methods

The RecordingScopeAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RecordingScopeAttribute Class
PostSharp.Patterns.Recording Namespace


RecordingScopeAttribute Properties

RecordingScopeAttribute Properties

The RecordingScopeAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Name | Gets the scope name.
Public property | Option | Gets the scope option.
Top
See Also

Reference

RecordingScopeAttribute Class
PostSharp.Patterns.Recording Namespace


RecordingScopeAttribute.Name Property

RecordingScopeAttributeName Property
Gets the scope name.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Name { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordingScopeAttribute Class
PostSharp.Patterns.Recording Namespace


RecordingScopeAttribute.Option Property

RecordingScopeAttributeOption Property
Gets the scope option.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RecordingScopeOption Option { get; }

Property Value

Type: RecordingScopeOption
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordingScopeAttribute Class
PostSharp.Patterns.Recording Namespace


RecordingScopeOption Enumeration

RecordingScopeOption Enumeration
Enumerates the kinds of recording scope.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum RecordingScopeOption
Members
Member name | Value | Description
Default | 0 | For declarative scopes, a RecordingScope is automatically opened for the first public method of a recordable object on the call stack.
Skip | 1 | Prevents a RecordingScope to be automatically opened for the target method. Cannot be used with OpenScope(RecordingScopeOption).
Atomic | 2 | Causes changes in the RecordingScope to be rolled back if the scope execution is not successful. In case of declarative scope (RecordingScopeAttribute), it means that changes done by the method will be rolled back if the method results in an exception. For imperative scopes (OpenScope(RecordingScopeOption), the changes will be rolled back if the scope is disposed by the Dispose method without previous call to the Complete method. Unlike normal scopes, atomic scopes are nested. However, only the top scope can be seen in the UndoOperations and RedoOperations collections.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace
PostSharp.Patterns.RecordingRecordingScope
PostSharp.Patterns.RecordingRecordingScopeAttribute
RecorderOpenScope(RecordingScopeOption)


RecordingServices Class

RecordingServices Class
Provides global methods to work with the PostSharp.Patterns.Recording namespace.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingRecordingServices

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class RecordingServices

The RecordingServices type exposes the following members.

Properties
Name | Description
DefaultRecorder | Gets the global default Recorder.
OperationFormatter | Gets or sets the OperationFormatter, which provides human-readable descriptions of operations.
RecorderProvider | Gets or sets the RecorderProvider, which provides the default Recorder for recordable objects that have the AutoRecord property set to true (which is the default value).
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


RecordingServices Properties

RecordingServices Properties

The RecordingServices type exposes the following members.

Properties
Name | Description
DefaultRecorder | Gets the global default Recorder.
OperationFormatter | Gets or sets the OperationFormatter, which provides human-readable descriptions of operations.
RecorderProvider | Gets or sets the RecorderProvider, which provides the default Recorder for recordable objects that have the AutoRecord property set to true (which is the default value).
Top
See Also

Reference

RecordingServices Class
PostSharp.Patterns.Recording Namespace


RecordingServices.DefaultRecorder Property

RecordingServicesDefaultRecorder Property
Gets the global default Recorder.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static Recorder DefaultRecorder { get; }

Property Value

Type: Recorder
Remarks

This property is provided for convenience only. It is equivalent to calling GetRecorder(Object) with a null argument.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordingServices Class
PostSharp.Patterns.Recording Namespace


RecordingServices.OperationFormatter Property

RecordingServicesOperationFormatter Property
Gets or sets the OperationFormatter, which provides human-readable descriptions of operations.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static OperationFormatter OperationFormatter { get; set; }

Property Value

Type: OperationFormatter
Remarks

This property is the head of a chain of responsibility. If you set this property to a new value, you typically have to pass the previous value of this property to the constructor of your custom OperationFormatter.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordingServices Class
PostSharp.Patterns.Recording Namespace


RecordingServices.RecorderProvider Property

RecordingServicesRecorderProvider Property
Gets or sets the RecorderProvider, which provides the default Recorder for recordable objects that have the AutoRecord property set to true (which is the default value).

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static RecorderProvider RecorderProvider { get; set; }

Property Value

Type: RecorderProvider
Remarks

This property is the head of a chain of responsibility. If you set this property to a new value, you typically have to pass the previous value of this property to the constructor of your custom RecorderProvider.

The default implementation unconditionally returns a single global instance of the Recorder class.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecordingServices Class
PostSharp.Patterns.Recording Namespace


ReplayContext Class

ReplayContext Class
Represents the context of an undo or redo operation. The class gives access to system-defined and user-defined pieces of information.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingReplayContext

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ReplayContext

The ReplayContext type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | CustomContext | Gets a dictionary that user code can use to store arbitrary pieces of information.
Public property | Success | Determines whether the operation was successful. This flag is set only in the OnReplayed(ReplayKind, ReplayContext) method.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


ReplayContext Methods

ReplayContext Methods

The ReplayContext type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReplayContext Class
PostSharp.Patterns.Recording Namespace


ReplayContext Properties

ReplayContext Properties

The ReplayContext type exposes the following members.

Properties
 | Name | Description
Public property | CustomContext | Gets a dictionary that user code can use to store arbitrary pieces of information.
Public property | Success | Determines whether the operation was successful. This flag is set only in the OnReplayed(ReplayKind, ReplayContext) method.
Top
See Also

Reference

ReplayContext Class
PostSharp.Patterns.Recording Namespace


ReplayContext.CustomContext Property

ReplayContextCustomContext Property
Gets a dictionary that user code can use to store arbitrary pieces of information.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IDictionary<Object, Object> CustomContext { get; }

Property Value

Type: IDictionary Object, Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReplayContext Class
PostSharp.Patterns.Recording Namespace


ReplayContext.Success Property

ReplayContextSuccess Property
Determines whether the operation was successful. This flag is set only in the OnReplayed(ReplayKind, ReplayContext) method.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Success { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReplayContext Class
PostSharp.Patterns.Recording Namespace


ReplayKind Enumeration

ReplayKind Enumeration
Enumerates the kind of situations in which the OnReplaying(ReplayKind, ReplayContext) or OnReplayed(ReplayKind, ReplayContext) methods are invoked.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum ReplayKind
Members
Member name | Value | Description
Undo | 0 | Undo operation.
Redo | 1 | Redo operation.
Remarks

Other reasons may be added in the future.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


RestorePoint Class

RestorePoint Class
Represents a point to which operations can be undone or redone. A RestorePoint is a pseudo-Operation that does not represent any change.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.RecordingRestorePoint

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class RestorePoint : Operation

The RestorePoint type exposes the following members.

Methods
 | Name | Description
Public method | Remove | Removes the current RestorePoint from the UndoOperations or RedoOperations.
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Public property | RestorePointName | Gets the name of the current RestorePoint.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording Namespace


RestorePoint Methods

RestorePoint Methods

The RestorePoint type exposes the following members.

Methods
 | Name | Description
Public method | Remove | Removes the current RestorePoint from the UndoOperations or RedoOperations.
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RestorePoint Class
PostSharp.Patterns.Recording Namespace


RestorePoint.Remove Method

RestorePointRemove Method
Removes the current RestorePoint from the UndoOperations or RedoOperations.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Remove()

Return Value

Type: Boolean
true if the RestorePoint was removed, false if it was not present in these collections.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RestorePoint Class
PostSharp.Patterns.Recording Namespace


RestorePoint.VisitAffectedObjects Method

RestorePointVisitAffectedObjects Method
Executes a given action on all recordable objects involved with the current Operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void VisitAffectedObjects(
    Action<Object> action
)

Parameters

action
Type: SystemAction Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RestorePoint Class
PostSharp.Patterns.Recording Namespace


RestorePoint Properties

RestorePoint Properties

The RestorePoint type exposes the following members.

Properties
 | Name | Description
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Public property | RestorePointName | Gets the name of the current RestorePoint.
Top
See Also

Reference

RestorePoint Class
PostSharp.Patterns.Recording Namespace


RestorePoint.OperationKind Property

RestorePointOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RestorePoint Class
PostSharp.Patterns.Recording Namespace


RestorePoint.RestorePointName Property

RestorePointRestorePointName Property
Gets the name of the current RestorePoint.

Namespace: PostSharp.Patterns.Recording
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string RestorePointName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RestorePoint Class
PostSharp.Patterns.Recording Namespace


PostSharp.Patterns.Recording.Operations Namespace

PostSharp.Patterns.Recording.Operations Namespace
The PostSharp.Patterns.Recording.Operations namespace defines recordable operations.
Classes
 | Class | Description
Public class | AddCollectionItemOperationT | Represents a Add(T) or Insert(Int32, T) operation.
Public class | AddDictionaryItemOperationTKey, TValue | Represents a Add(TKey, TValue) operation.
Public class | AttachObjectToRecorderOperation | Encapsulates the Attach(Object) operation.
Public class | ClearCollectionOperationT | Represents the Clear operation.
Public class | ClearDictionaryOperationTKey, TValue | Represents the AdvisableDictionaryTKey, TValue operation.
Public class | CollectionOperationT | Base class for operations on an AdvisableCollectionT.
Public class | CompositeOperation | Represents an Operation composed of other sub-operations.
Public class | DetachObjectFromRecorderOperation | Encapsulates the Detach(Object) operation.
Public class | DictionaryOperationTKey, TValue | Base class for operations on an AdvisableDictionaryTKey, TValue.
Public class | FieldOperationT | Encapsulates a modification of a field value.
Public class | MethodExecutionOperationDescriptor | Represents a call to a method in user code.
Public class | NamedOperationDescriptor | Represents an operation whose named has been set declaratively or imperatively.
Public class | RecorderOperation | An Operation on a Recorder, specifically a base class for AttachObjectToRecorderOperation and DetachObjectFromRecorderOperation.
Public class | RemoveCollectionItemOperationT | Represents a Remove(T) operation.
Public class | RemoveDictionaryItemOperationTKey, TValue | Represents a Remove(TKey) operation.
Public class | SetCollectionItemOperationT | Represents a set_Item(Int32, UTP) operation.
Public class | SetDictionaryItemOperationTKey, TValue | Represents a set_Item(UTP, UTP) operation.
Interfaces
 | Interface | Description
Public interface | ICollectionOperation | Weakly-typed interface for the CollectionOperationT class.
Public interface | IDictionaryOperation | Weakly-typed interface for the DictionaryOperationTKey, TValue class.
Public interface | IFieldOperation | Weakly-typed interface for FieldOperationT.
Public interface | IOperationDescriptor | Encapsulates information that allow implementations of the OperationFormatter class to provide a human-readable description of an Operation.


AddCollectionItemOperation(T) Class

AddCollectionItemOperationT Class
Represents a Add(T) or Insert(Int32, T) operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsCollectionOperation T
PostSharp.Patterns.Recording.OperationsAddCollectionItemOperationT

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AddCollectionItemOperation<T> : CollectionOperation<T>

Type Parameters

T
Type of collection items.

The AddCollectionItemOperationT type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from CollectionOperationT.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed. (Inherited from CollectionOperationT.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewIndex | Gets the index after the operation. (Overrides CollectionOperationTNewIndex.)
Public property | NewItem | Gets the item before the operation. (Overrides CollectionOperationTNewItem.)
Public property | OldIndex | Gets the index before the operation. (Inherited from CollectionOperationT.)
Public property | OldItem | Gets the item after the operation. (Inherited from CollectionOperationT.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


AddCollectionItemOperation(T) Methods

AddCollectionItemOperationT Methods

The AddCollectionItemOperationT generic type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from CollectionOperationT.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AddCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


AddCollectionItemOperation(T) Properties

AddCollectionItemOperationT Properties

The AddCollectionItemOperationT generic type exposes the following members.

Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed. (Inherited from CollectionOperationT.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewIndex | Gets the index after the operation. (Overrides CollectionOperationTNewIndex.)
Public property | NewItem | Gets the item before the operation. (Overrides CollectionOperationTNewItem.)
Public property | OldIndex | Gets the index before the operation. (Inherited from CollectionOperationT.)
Public property | OldItem | Gets the item after the operation. (Inherited from CollectionOperationT.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
See Also

Reference

AddCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


AddCollectionItemOperation(T).NewIndex Property

AddCollectionItemOperationTNewIndex Property
Gets the index after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int NewIndex { get; }

Property Value

Type: Int32

Implements

ICollectionOperationNewIndex
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AddCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


AddCollectionItemOperation(T).NewItem Property

AddCollectionItemOperationTNewItem Property
Gets the item before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override T NewItem { get; }

Property Value

Type: T
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AddCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


AddCollectionItemOperation(T).OperationKind Property

AddCollectionItemOperationTOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AddCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


AddDictionaryItemOperation(TKey, TValue) Class

AddDictionaryItemOperationTKey, TValue Class
Represents a Add(TKey, TValue) operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsDictionaryOperation TKey, TValue
PostSharp.Patterns.Recording.OperationsAddDictionaryItemOperationTKey, TValue

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AddDictionaryItemOperation<TKey, TValue> : DictionaryOperation<TKey, TValue>

Type Parameters

TKey
Type of dictionary keys.
TValue
Type of dictionary values.

The AddDictionaryItemOperationTKey, TValue type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from DictionaryOperationTKey, TValue.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed. (Inherited from DictionaryOperationTKey, TValue.)
Public property | Key | Gets the key of the dictionary entry affected by the operation. (Overrides DictionaryOperationTKey, TValueKey.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewValue | Gets the value of the dictionary entry after the operation. (Overrides DictionaryOperationTKey, TValueNewValue.)
Public property | OldValue | Gets the value of the dictionary entry before the operation. (Inherited from DictionaryOperationTKey, TValue.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


AddDictionaryItemOperation(TKey, TValue) Methods

AddDictionaryItemOperationTKey, TValue Methods

The AddDictionaryItemOperationTKey, TValue generic type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from DictionaryOperationTKey, TValue.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AddDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


AddDictionaryItemOperation(TKey, TValue) Properties

AddDictionaryItemOperationTKey, TValue Properties

The AddDictionaryItemOperationTKey, TValue generic type exposes the following members.

Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed. (Inherited from DictionaryOperationTKey, TValue.)
Public property | Key | Gets the key of the dictionary entry affected by the operation. (Overrides DictionaryOperationTKey, TValueKey.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewValue | Gets the value of the dictionary entry after the operation. (Overrides DictionaryOperationTKey, TValueNewValue.)
Public property | OldValue | Gets the value of the dictionary entry before the operation. (Inherited from DictionaryOperationTKey, TValue.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
See Also

Reference

AddDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


AddDictionaryItemOperation(TKey, TValue).Key Property

AddDictionaryItemOperationTKey, TValueKey Property
Gets the key of the dictionary entry affected by the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override TKey Key { get; }

Property Value

Type: TKey
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AddDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


AddDictionaryItemOperation(TKey, TValue).NewValue Property

AddDictionaryItemOperationTKey, TValueNewValue Property
Gets the value of the dictionary entry after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override TValue NewValue { get; }

Property Value

Type: TValue
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AddDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


AddDictionaryItemOperation(TKey, TValue).OperationKind Property

AddDictionaryItemOperationTKey, TValueOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AddDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


AttachObjectToRecorderOperation Class

AttachObjectToRecorderOperation Class
Encapsulates the Attach(Object) operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsRecorderOperation
PostSharp.Patterns.Recording.OperationsAttachObjectToRecorderOperation

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AttachObjectToRecorderOperation : RecorderOperation

The AttachObjectToRecorderOperation type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from RecorderOperation.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | Object | Gets the object being attached to the Recorder.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Public property | Recorder | Gets the Recorder to which the current Operation relates. (Inherited from RecorderOperation.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


AttachObjectToRecorderOperation Methods

AttachObjectToRecorderOperation Methods

The AttachObjectToRecorderOperation type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from RecorderOperation.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AttachObjectToRecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


AttachObjectToRecorderOperation Properties

AttachObjectToRecorderOperation Properties

The AttachObjectToRecorderOperation type exposes the following members.

Properties
 | Name | Description
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | Object | Gets the object being attached to the Recorder.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Public property | Recorder | Gets the Recorder to which the current Operation relates. (Inherited from RecorderOperation.)
Top
See Also

Reference

AttachObjectToRecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


AttachObjectToRecorderOperation.Object Property

AttachObjectToRecorderOperationObject Property
Gets the object being attached to the Recorder.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Object { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AttachObjectToRecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


AttachObjectToRecorderOperation.OperationKind Property

AttachObjectToRecorderOperationOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AttachObjectToRecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


ClearCollectionOperation(T) Class

ClearCollectionOperationT Class
Represents the Clear operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsCollectionOperation T
PostSharp.Patterns.Recording.OperationsClearCollectionOperationT

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ClearCollectionOperation<T> : CollectionOperation<T>

Type Parameters

T
Type of items in the collection.

The ClearCollectionOperationT type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from CollectionOperationT.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed. (Inherited from CollectionOperationT.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewIndex | Gets the index after the operation. (Inherited from CollectionOperationT.)
Public property | NewItem | Gets the item before the operation. (Inherited from CollectionOperationT.)
Public property | OldIndex | Gets the index before the operation. (Inherited from CollectionOperationT.)
Public property | OldItem | Gets the item after the operation. (Inherited from CollectionOperationT.)
Public property | OldItems | Gets the items that were in the collection before it was cleared.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


ClearCollectionOperation(T) Methods

ClearCollectionOperationT Methods

The ClearCollectionOperationT generic type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from CollectionOperationT.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ClearCollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


ClearCollectionOperation(T) Properties

ClearCollectionOperationT Properties

The ClearCollectionOperationT generic type exposes the following members.

Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed. (Inherited from CollectionOperationT.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewIndex | Gets the index after the operation. (Inherited from CollectionOperationT.)
Public property | NewItem | Gets the item before the operation. (Inherited from CollectionOperationT.)
Public property | OldIndex | Gets the index before the operation. (Inherited from CollectionOperationT.)
Public property | OldItem | Gets the item after the operation. (Inherited from CollectionOperationT.)
Public property | OldItems | Gets the items that were in the collection before it was cleared.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
See Also

Reference

ClearCollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


ClearCollectionOperation(T).OldItems Property

ClearCollectionOperationTOldItems Property
Gets the items that were in the collection before it was cleared.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ReadOnlyArray<T> OldItems { get; }

Property Value

Type: ReadOnlyArray T
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ClearCollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


ClearCollectionOperation(T).OperationKind Property

ClearCollectionOperationTOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ClearCollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


ClearDictionaryOperation(TKey, TValue) Class

ClearDictionaryOperationTKey, TValue Class
Represents the AdvisableDictionaryTKey, TValue operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsDictionaryOperation TKey, TValue
PostSharp.Patterns.Recording.OperationsClearDictionaryOperationTKey, TValue

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ClearDictionaryOperation<TKey, TValue> : DictionaryOperation<TKey, TValue>

Type Parameters

TKey
Type of keys.
TValue
Type of values.

The ClearDictionaryOperationTKey, TValue type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from DictionaryOperationTKey, TValue.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed. (Inherited from DictionaryOperationTKey, TValue.)
Public property | Key | Gets the key of the dictionary entry affected by the operation. (Inherited from DictionaryOperationTKey, TValue.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewValue | Gets the value of the dictionary entry after the operation. (Inherited from DictionaryOperationTKey, TValue.)
Public property | OldEntries | Gets the items that were in the dictionary before it was cleared.
Public property | OldValue | Gets the value of the dictionary entry before the operation. (Inherited from DictionaryOperationTKey, TValue.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


ClearDictionaryOperation(TKey, TValue) Methods

ClearDictionaryOperationTKey, TValue Methods

The ClearDictionaryOperationTKey, TValue generic type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from DictionaryOperationTKey, TValue.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ClearDictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


ClearDictionaryOperation(TKey, TValue) Properties

ClearDictionaryOperationTKey, TValue Properties

The ClearDictionaryOperationTKey, TValue generic type exposes the following members.

Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed. (Inherited from DictionaryOperationTKey, TValue.)
Public property | Key | Gets the key of the dictionary entry affected by the operation. (Inherited from DictionaryOperationTKey, TValue.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewValue | Gets the value of the dictionary entry after the operation. (Inherited from DictionaryOperationTKey, TValue.)
Public property | OldEntries | Gets the items that were in the dictionary before it was cleared.
Public property | OldValue | Gets the value of the dictionary entry before the operation. (Inherited from DictionaryOperationTKey, TValue.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
See Also

Reference

ClearDictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


ClearDictionaryOperation(TKey, TValue).OldEntries Property

ClearDictionaryOperationTKey, TValueOldEntries Property
Gets the items that were in the dictionary before it was cleared.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ReadOnlyArray<KeyValuePair<TKey, TValue>> OldEntries { get; }

Property Value

Type: ReadOnlyArray KeyValuePair TKey, TValue
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ClearDictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


ClearDictionaryOperation(TKey, TValue).OperationKind Property

ClearDictionaryOperationTKey, TValueOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ClearDictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


CollectionOperation(T) Class

CollectionOperationT Class
Base class for operations on an AdvisableCollectionT.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsCollectionOperationT
PostSharp.Patterns.Recording.OperationsAddCollectionItemOperationT
PostSharp.Patterns.Recording.OperationsClearCollectionOperationT
PostSharp.Patterns.Recording.OperationsRemoveCollectionItemOperationT
PostSharp.Patterns.Recording.OperationsSetCollectionItemOperationT

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class CollectionOperation<T> : Operation,
    ICollectionOperation, IOperationDescriptor

Type Parameters

T
Type of collection items.

The CollectionOperationT type exposes the following members.

Methods
 | Name | Description
Protected method | GetMergeStatus | Determines how a given Operation can be merged with the current Operation. (Inherited from Operation.)
Protected method | Merge | Merges a given Operation into the current Operation. (Inherited from Operation.)
Protected method | Redo | Redo the current operation. (Inherited from Operation.)
Protected method | Undo | Undo the current operation. (Inherited from Operation.)
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed.
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewIndex | Gets the index after the operation.
Public property | NewItem | Gets the item before the operation.
Public property | OldIndex | Gets the index before the operation.
Public property | OldItem | Gets the item after the operation.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Inherited from Operation.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


CollectionOperation(T) Methods

CollectionOperationT Methods

The CollectionOperationT generic type exposes the following members.

Methods
 | Name | Description
Protected method | GetMergeStatus | Determines how a given Operation can be merged with the current Operation. (Inherited from Operation.)
Protected method | Merge | Merges a given Operation into the current Operation. (Inherited from Operation.)
Protected method | Redo | Redo the current operation. (Inherited from Operation.)
Protected method | Undo | Undo the current operation. (Inherited from Operation.)
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


CollectionOperation(T).VisitAffectedObjects Method

CollectionOperationTVisitAffectedObjects Method
Executes a given action on all recordable objects involved with the current Operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void VisitAffectedObjects(
    Action<Object> action
)

Parameters

action
Type: SystemAction Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

CollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


CollectionOperation(T) Properties

CollectionOperationT Properties

The CollectionOperationT generic type exposes the following members.

Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed.
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewIndex | Gets the index after the operation.
Public property | NewItem | Gets the item before the operation.
Public property | OldIndex | Gets the index before the operation.
Public property | OldItem | Gets the item after the operation.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Inherited from Operation.)
Top
See Also

Reference

CollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


CollectionOperation(T).Collection Property

CollectionOperationTCollection Property
Gets the collection on which the operation was performed.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableCollection<T> Collection { get; }

Property Value

Type: AdvisableCollection T
Version Information

Supported in: 4.1, 4.0

See Also

Reference

CollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


CollectionOperation(T).NewIndex Property

CollectionOperationTNewIndex Property
Gets the index after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual int NewIndex { get; }

Property Value

Type: Int32

Implements

ICollectionOperationNewIndex
Version Information

Supported in: 4.1, 4.0

See Also

Reference

CollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


CollectionOperation(T).NewItem Property

CollectionOperationTNewItem Property
Gets the item before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual T NewItem { get; }

Property Value

Type: T
Version Information

Supported in: 4.1, 4.0

See Also

Reference

CollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


CollectionOperation(T).OldIndex Property

CollectionOperationTOldIndex Property
Gets the index before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual int OldIndex { get; }

Property Value

Type: Int32

Implements

ICollectionOperationOldIndex
Version Information

Supported in: 4.1, 4.0

See Also

Reference

CollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


CollectionOperation(T).OldItem Property

CollectionOperationTOldItem Property
Gets the item after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual T OldItem { get; }

Property Value

Type: T
Version Information

Supported in: 4.1, 4.0

See Also

Reference

CollectionOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


CompositeOperation Class

CompositeOperation Class
Represents an Operation composed of other sub-operations.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsCompositeOperation

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class CompositeOperation : Operation

The CompositeOperation type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Overrides OperationOperationDescriptor.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
Remarks

The OperationDescriptor is typically not identical to the CompositeOperation itself.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


CompositeOperation Methods

CompositeOperation Methods

The CompositeOperation type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CompositeOperation Class
PostSharp.Patterns.Recording.Operations Namespace


CompositeOperation.VisitAffectedObjects Method

CompositeOperationVisitAffectedObjects Method
Executes a given action on all recordable objects involved with the current Operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void VisitAffectedObjects(
    Action<Object> action
)

Parameters

action
Type: SystemAction Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

CompositeOperation Class
PostSharp.Patterns.Recording.Operations Namespace


CompositeOperation Properties

CompositeOperation Properties

The CompositeOperation type exposes the following members.

Properties
 | Name | Description
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Overrides OperationOperationDescriptor.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
See Also

Reference

CompositeOperation Class
PostSharp.Patterns.Recording.Operations Namespace


CompositeOperation.OperationDescriptor Property

CompositeOperationOperationDescriptor Property
Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override IOperationDescriptor OperationDescriptor { get; }

Property Value

Type: IOperationDescriptor
Remarks

By default, the OperationDescriptor property returns the current Operation.

When the Operation represents a user-defined scope, the property evaluates to an instance of the NamedOperationDescriptor class. When it represents a method scope, it evaluates to an instance of the MethodExecutionOperationDescriptor class.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

CompositeOperation Class
PostSharp.Patterns.Recording.Operations Namespace


CompositeOperation.OperationKind Property

CompositeOperationOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

CompositeOperation Class
PostSharp.Patterns.Recording.Operations Namespace


DetachObjectFromRecorderOperation Class

DetachObjectFromRecorderOperation Class
Encapsulates the Detach(Object) operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsRecorderOperation
PostSharp.Patterns.Recording.OperationsDetachObjectFromRecorderOperation

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class DetachObjectFromRecorderOperation : RecorderOperation

The DetachObjectFromRecorderOperation type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from RecorderOperation.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | Object | Gets the object being attached to the Recorder.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Public property | Recorder | Gets the Recorder to which the current Operation relates. (Inherited from RecorderOperation.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


DetachObjectFromRecorderOperation Methods

DetachObjectFromRecorderOperation Methods

The DetachObjectFromRecorderOperation type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from RecorderOperation.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DetachObjectFromRecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


DetachObjectFromRecorderOperation Properties

DetachObjectFromRecorderOperation Properties

The DetachObjectFromRecorderOperation type exposes the following members.

Properties
 | Name | Description
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | Object | Gets the object being attached to the Recorder.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Public property | Recorder | Gets the Recorder to which the current Operation relates. (Inherited from RecorderOperation.)
Top
See Also

Reference

DetachObjectFromRecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


DetachObjectFromRecorderOperation.Object Property

DetachObjectFromRecorderOperationObject Property
Gets the object being attached to the Recorder.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Object { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DetachObjectFromRecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


DetachObjectFromRecorderOperation.OperationKind Property

DetachObjectFromRecorderOperationOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DetachObjectFromRecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


DictionaryOperation(TKey, TValue) Class

DictionaryOperationTKey, TValue Class
Base class for operations on an AdvisableDictionaryTKey, TValue.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsDictionaryOperationTKey, TValue
PostSharp.Patterns.Recording.OperationsAddDictionaryItemOperationTKey, TValue
PostSharp.Patterns.Recording.OperationsClearDictionaryOperationTKey, TValue
PostSharp.Patterns.Recording.OperationsRemoveDictionaryItemOperationTKey, TValue
PostSharp.Patterns.Recording.OperationsSetDictionaryItemOperationTKey, TValue

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class DictionaryOperation<TKey, TValue> : Operation,
    IDictionaryOperation, IOperationDescriptor

Type Parameters

TKey
Type of keys.
TValue
Type of values.

The DictionaryOperationTKey, TValue type exposes the following members.

Methods
 | Name | Description
Protected method | GetMergeStatus | Determines how a given Operation can be merged with the current Operation. (Inherited from Operation.)
Protected method | Merge | Merges a given Operation into the current Operation. (Inherited from Operation.)
Protected method | Redo | Redo the current operation. (Inherited from Operation.)
Protected method | Undo | Undo the current operation. (Inherited from Operation.)
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed.
Public property | Key | Gets the key of the dictionary entry affected by the operation.
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewValue | Gets the value of the dictionary entry after the operation.
Public property | OldValue | Gets the value of the dictionary entry before the operation.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Inherited from Operation.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


DictionaryOperation(TKey, TValue) Methods

DictionaryOperationTKey, TValue Methods

The DictionaryOperationTKey, TValue generic type exposes the following members.

Methods
 | Name | Description
Protected method | GetMergeStatus | Determines how a given Operation can be merged with the current Operation. (Inherited from Operation.)
Protected method | Merge | Merges a given Operation into the current Operation. (Inherited from Operation.)
Protected method | Redo | Redo the current operation. (Inherited from Operation.)
Protected method | Undo | Undo the current operation. (Inherited from Operation.)
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


DictionaryOperation(TKey, TValue).VisitAffectedObjects Method

DictionaryOperationTKey, TValueVisitAffectedObjects Method
Executes a given action on all recordable objects involved with the current Operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void VisitAffectedObjects(
    Action<Object> action
)

Parameters

action
Type: SystemAction Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


DictionaryOperation(TKey, TValue) Properties

DictionaryOperationTKey, TValue Properties

The DictionaryOperationTKey, TValue generic type exposes the following members.

Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed.
Public property | Key | Gets the key of the dictionary entry affected by the operation.
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewValue | Gets the value of the dictionary entry after the operation.
Public property | OldValue | Gets the value of the dictionary entry before the operation.
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Inherited from Operation.)
Top
See Also

Reference

DictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


DictionaryOperation(TKey, TValue).Dictionary Property

DictionaryOperationTKey, TValueDictionary Property
Gets the collection on which the operation was performed.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AdvisableDictionary<TKey, TValue> Dictionary { get; }

Property Value

Type: AdvisableDictionary TKey, TValue
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


DictionaryOperation(TKey, TValue).Key Property

DictionaryOperationTKey, TValueKey Property
Gets the key of the dictionary entry affected by the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual TKey Key { get; }

Property Value

Type: TKey
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


DictionaryOperation(TKey, TValue).NewValue Property

DictionaryOperationTKey, TValueNewValue Property
Gets the value of the dictionary entry after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual TValue NewValue { get; }

Property Value

Type: TValue
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


DictionaryOperation(TKey, TValue).OldValue Property

DictionaryOperationTKey, TValueOldValue Property
Gets the value of the dictionary entry before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual TValue OldValue { get; }

Property Value

Type: TValue
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DictionaryOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


FieldOperation(T) Class

FieldOperationT Class
Encapsulates a modification of a field value.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsFieldOperationT

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class FieldOperation<T> : Operation,
    IFieldOperation

Type Parameters

T

The FieldOperationT type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Location | Gets the LocationInfo of the modified field.
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Public property | Target | Gets the this instance.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


FieldOperation(T) Methods

FieldOperationT Methods

The FieldOperationT generic type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

FieldOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


FieldOperation(T).VisitAffectedObjects Method

FieldOperationTVisitAffectedObjects Method
Executes a given action on all recordable objects involved with the current Operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void VisitAffectedObjects(
    Action<Object> action
)

Parameters

action
Type: SystemAction Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

FieldOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


FieldOperation(T) Properties

FieldOperationT Properties

The FieldOperationT generic type exposes the following members.

Properties
 | Name | Description
Public property | Location | Gets the LocationInfo of the modified field.
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Public property | Target | Gets the this instance.
Top
See Also

Reference

FieldOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


FieldOperation(T).Location Property

FieldOperationTLocation Property
Gets the LocationInfo of the modified field.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LocationInfo Location { get; }

Property Value

Type: LocationInfo

Implements

IFieldOperationLocation
Version Information

Supported in: 4.1, 4.0

See Also

Reference

FieldOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


FieldOperation(T).OperationKind Property

FieldOperationTOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

FieldOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


FieldOperation(T).Target Property

FieldOperationTTarget Property
Gets the this instance.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Target { get; }

Property Value

Type: Object

Implements

IFieldOperationTarget
Version Information

Supported in: 4.1, 4.0

See Also

Reference

FieldOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


ICollectionOperation Interface

ICollectionOperation Interface
Weakly-typed interface for the CollectionOperationT class.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ICollectionOperation : IOperationDescriptor

The ICollectionOperation type exposes the following members.

Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed.
Public property | NewIndex | Gets the index after the operation.
Public property | NewItem | Gets the item after the operation.
Public property | OldIndex | Gets the index before the operation.
Public property | OldItem | Gets the item before the operation.
Public property | OperationKind | Gets the kind of operation. (Inherited from IOperationDescriptor.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


ICollectionOperation Properties

ICollectionOperation Properties

The ICollectionOperation type exposes the following members.

Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed.
Public property | NewIndex | Gets the index after the operation.
Public property | NewItem | Gets the item after the operation.
Public property | OldIndex | Gets the index before the operation.
Public property | OldItem | Gets the item before the operation.
Public property | OperationKind | Gets the kind of operation. (Inherited from IOperationDescriptor.)
Top
See Also

Reference

ICollectionOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


ICollectionOperation.Collection Property

ICollectionOperationCollection Property
Gets the collection on which the operation was performed.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ICollection Collection { get; }

Property Value

Type: ICollection
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ICollectionOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


ICollectionOperation.NewIndex Property

ICollectionOperationNewIndex Property
Gets the index after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
int NewIndex { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ICollectionOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


ICollectionOperation.NewItem Property

ICollectionOperationNewItem Property
Gets the item after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object NewItem { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ICollectionOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


ICollectionOperation.OldIndex Property

ICollectionOperationOldIndex Property
Gets the index before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
int OldIndex { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ICollectionOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


ICollectionOperation.OldItem Property

ICollectionOperationOldItem Property
Gets the item before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object OldItem { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ICollectionOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IDictionaryOperation Interface

IDictionaryOperation Interface
Weakly-typed interface for the DictionaryOperationTKey, TValue class.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IDictionaryOperation : IOperationDescriptor

The IDictionaryOperation type exposes the following members.

Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed.
Public property | Key | Gets the key of the dictionary entry affected by the operation.
Public property | NewValue | Gets the value of the dictionary entry after the operation.
Public property | OldValue | Gets the value of the dictionary entry before the operation.
Public property | OperationKind | Gets the kind of operation. (Inherited from IOperationDescriptor.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


IDictionaryOperation Properties

IDictionaryOperation Properties

The IDictionaryOperation type exposes the following members.

Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed.
Public property | Key | Gets the key of the dictionary entry affected by the operation.
Public property | NewValue | Gets the value of the dictionary entry after the operation.
Public property | OldValue | Gets the value of the dictionary entry before the operation.
Public property | OperationKind | Gets the kind of operation. (Inherited from IOperationDescriptor.)
Top
See Also

Reference

IDictionaryOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IDictionaryOperation.Dictionary Property

IDictionaryOperationDictionary Property
Gets the collection on which the operation was performed.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IDictionary Dictionary { get; }

Property Value

Type: IDictionary
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IDictionaryOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IDictionaryOperation.Key Property

IDictionaryOperationKey Property
Gets the key of the dictionary entry affected by the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object Key { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IDictionaryOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IDictionaryOperation.NewValue Property

IDictionaryOperationNewValue Property
Gets the value of the dictionary entry after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object NewValue { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IDictionaryOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IDictionaryOperation.OldValue Property

IDictionaryOperationOldValue Property
Gets the value of the dictionary entry before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object OldValue { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IDictionaryOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IFieldOperation Interface

IFieldOperation Interface
Weakly-typed interface for FieldOperationT.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IFieldOperation

The IFieldOperation type exposes the following members.

Properties
 | Name | Description
Public property | Location | Gets the LocationInfo of the modified field.
Public property | NewValue | Gets the value of the field after the operation.
Public property | OldValue | Gets the value of the field before the operation.
Public property | Target | Gets the this instance.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


IFieldOperation Properties

IFieldOperation Properties

The IFieldOperation type exposes the following members.

Properties
 | Name | Description
Public property | Location | Gets the LocationInfo of the modified field.
Public property | NewValue | Gets the value of the field after the operation.
Public property | OldValue | Gets the value of the field before the operation.
Public property | Target | Gets the this instance.
Top
See Also

Reference

IFieldOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IFieldOperation.Location Property

IFieldOperationLocation Property
Gets the LocationInfo of the modified field.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
LocationInfo Location { get; }

Property Value

Type: LocationInfo
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IFieldOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IFieldOperation.NewValue Property

IFieldOperationNewValue Property
Gets the value of the field after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object NewValue { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IFieldOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IFieldOperation.OldValue Property

IFieldOperationOldValue Property
Gets the value of the field before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object OldValue { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IFieldOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IFieldOperation.Target Property

IFieldOperationTarget Property
Gets the this instance.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object Target { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IFieldOperation Interface
PostSharp.Patterns.Recording.Operations Namespace


IOperationDescriptor Interface

IOperationDescriptor Interface
Encapsulates information that allow implementations of the OperationFormatter class to provide a human-readable description of an Operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IOperationDescriptor

The IOperationDescriptor type exposes the following members.

Properties
 | Name | Description
Public property | OperationKind | Gets the kind of operation.
Top
Remarks

If you implement your own OperationFormatter, you can also implement your own IOperationDescriptor and assign it to the OperationDescriptor property of the RecordingScope returned by OpenScope(RecordingScopeOption).

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


IOperationDescriptor Properties

IOperationDescriptor Properties

The IOperationDescriptor type exposes the following members.

Properties
 | Name | Description
Public property | OperationKind | Gets the kind of operation.
Top
See Also

Reference

IOperationDescriptor Interface
PostSharp.Patterns.Recording.Operations Namespace


IOperationDescriptor.OperationKind Property

IOperationDescriptorOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
OperationKind OperationKind { get; }

Property Value

Type: OperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IOperationDescriptor Interface
PostSharp.Patterns.Recording.Operations Namespace


MethodExecutionOperationDescriptor Class

MethodExecutionOperationDescriptor Class
Represents a call to a method in user code.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.Recording.OperationsMethodExecutionOperationDescriptor

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class MethodExecutionOperationDescriptor : IOperationDescriptor

The MethodExecutionOperationDescriptor type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Arguments | Gets the method arguments.
Public property | Method | Gets the executed method.
Public property | MethodName | Gets the name of the method. This property is set even if the Method property is null.
Public property | OperationKind | Gets the kind of operation.
Public property | Target | Gets the this instance.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


MethodExecutionOperationDescriptor Methods

MethodExecutionOperationDescriptor Methods

The MethodExecutionOperationDescriptor type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MethodExecutionOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


MethodExecutionOperationDescriptor Properties

MethodExecutionOperationDescriptor Properties

The MethodExecutionOperationDescriptor type exposes the following members.

Properties
 | Name | Description
Public property | Arguments | Gets the method arguments.
Public property | Method | Gets the executed method.
Public property | MethodName | Gets the name of the method. This property is set even if the Method property is null.
Public property | OperationKind | Gets the kind of operation.
Public property | Target | Gets the this instance.
Top
See Also

Reference

MethodExecutionOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


MethodExecutionOperationDescriptor.Arguments Property

MethodExecutionOperationDescriptorArguments Property
Gets the method arguments.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IList<Object> Arguments { get; }

Property Value

Type: IList Object
Remarks

This property is null unless the ProvideMethodContext property is set to true for the target class.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

MethodExecutionOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


MethodExecutionOperationDescriptor.Method Property

MethodExecutionOperationDescriptorMethod Property
Gets the executed method.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MethodInfo Method { get; }

Property Value

Type: MethodInfo
Remarks

This property is null unless the ProvideMethodContext property is set to true for the target class.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

MethodExecutionOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


MethodExecutionOperationDescriptor.MethodName Property

MethodExecutionOperationDescriptorMethodName Property
Gets the name of the method. This property is set even if the Method property is null.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string MethodName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1

See Also

Reference

MethodExecutionOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


MethodExecutionOperationDescriptor.OperationKind Property

MethodExecutionOperationDescriptorOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

MethodExecutionOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


MethodExecutionOperationDescriptor.Target Property

MethodExecutionOperationDescriptorTarget Property
Gets the this instance.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Target { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

MethodExecutionOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


NamedOperationDescriptor Class

NamedOperationDescriptor Class
Represents an operation whose named has been set declaratively or imperatively.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.Recording.OperationsNamedOperationDescriptor

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class NamedOperationDescriptor : IOperationDescriptor

The NamedOperationDescriptor type exposes the following members.

Constructors
 | Name | Description
Public method | NamedOperationDescriptor | Initializes a new NamedOperationDescriptor.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Name | Gets the operation name.
Public property | OperationKind | Gets the kind of operation.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


NamedOperationDescriptor Constructor

NamedOperationDescriptor Constructor
Initializes a new NamedOperationDescriptor.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public NamedOperationDescriptor(
    string name
)

Parameters

name
Type: SystemString
The operation name.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

NamedOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


NamedOperationDescriptor Methods

NamedOperationDescriptor Methods

The NamedOperationDescriptor type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

NamedOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


NamedOperationDescriptor Properties

NamedOperationDescriptor Properties

The NamedOperationDescriptor type exposes the following members.

Properties
 | Name | Description
Public property | Name | Gets the operation name.
Public property | OperationKind | Gets the kind of operation.
Top
See Also

Reference

NamedOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


NamedOperationDescriptor.Name Property

NamedOperationDescriptorName Property
Gets the operation name.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Name { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0

See Also

Reference

NamedOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


NamedOperationDescriptor.OperationKind Property

NamedOperationDescriptorOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

NamedOperationDescriptor Class
PostSharp.Patterns.Recording.Operations Namespace


RecorderOperation Class

RecorderOperation Class
An Operation on a Recorder, specifically a base class for AttachObjectToRecorderOperation and DetachObjectFromRecorderOperation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsRecorderOperation
PostSharp.Patterns.Recording.OperationsAttachObjectToRecorderOperation
PostSharp.Patterns.Recording.OperationsDetachObjectFromRecorderOperation

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class RecorderOperation : Operation

The RecorderOperation type exposes the following members.

Methods
 | Name | Description
Protected method | GetMergeStatus | Determines how a given Operation can be merged with the current Operation. (Inherited from Operation.)
Protected method | Merge | Merges a given Operation into the current Operation. (Inherited from Operation.)
Protected method | Redo | Redo the current operation. (Inherited from Operation.)
Protected method | Undo | Undo the current operation. (Inherited from Operation.)
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Inherited from Operation.)
Public property | Recorder | Gets the Recorder to which the current Operation relates.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


RecorderOperation Methods

RecorderOperation Methods

The RecorderOperation type exposes the following members.

Methods
 | Name | Description
Protected method | GetMergeStatus | Determines how a given Operation can be merged with the current Operation. (Inherited from Operation.)
Protected method | Merge | Merges a given Operation into the current Operation. (Inherited from Operation.)
Protected method | Redo | Redo the current operation. (Inherited from Operation.)
Protected method | Undo | Undo the current operation. (Inherited from Operation.)
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Overrides OperationVisitAffectedObjects(ActionObject).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


RecorderOperation.VisitAffectedObjects Method

RecorderOperationVisitAffectedObjects Method
Executes a given action on all recordable objects involved with the current Operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void VisitAffectedObjects(
    Action<Object> action
)

Parameters

action
Type: SystemAction Object
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


RecorderOperation Properties

RecorderOperation Properties

The RecorderOperation type exposes the following members.

Properties
 | Name | Description
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Inherited from Operation.)
Public property | Recorder | Gets the Recorder to which the current Operation relates.
Top
See Also

Reference

RecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


RecorderOperation.Recorder Property

RecorderOperationRecorder Property
Gets the Recorder to which the current Operation relates.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Recorder Recorder { get; }

Property Value

Type: Recorder
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RecorderOperation Class
PostSharp.Patterns.Recording.Operations Namespace


RemoveCollectionItemOperation(T) Class

RemoveCollectionItemOperationT Class
Represents a Remove(T) operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsCollectionOperation T
PostSharp.Patterns.Recording.OperationsRemoveCollectionItemOperationT

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class RemoveCollectionItemOperation<T> : CollectionOperation<T>

Type Parameters

T
Type of collection items.

The RemoveCollectionItemOperationT type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from CollectionOperationT.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed. (Inherited from CollectionOperationT.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewIndex | Gets the index after the operation. (Inherited from CollectionOperationT.)
Public property | NewItem | Gets the item before the operation. (Inherited from CollectionOperationT.)
Public property | OldIndex | Gets the index before the operation. (Overrides CollectionOperationTOldIndex.)
Public property | OldItem | Gets the item after the operation. (Overrides CollectionOperationTOldItem.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


RemoveCollectionItemOperation(T) Methods

RemoveCollectionItemOperationT Methods

The RemoveCollectionItemOperationT generic type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from CollectionOperationT.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RemoveCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


RemoveCollectionItemOperation(T) Properties

RemoveCollectionItemOperationT Properties

The RemoveCollectionItemOperationT generic type exposes the following members.

Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed. (Inherited from CollectionOperationT.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewIndex | Gets the index after the operation. (Inherited from CollectionOperationT.)
Public property | NewItem | Gets the item before the operation. (Inherited from CollectionOperationT.)
Public property | OldIndex | Gets the index before the operation. (Overrides CollectionOperationTOldIndex.)
Public property | OldItem | Gets the item after the operation. (Overrides CollectionOperationTOldItem.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
See Also

Reference

RemoveCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


RemoveCollectionItemOperation(T).OldIndex Property

RemoveCollectionItemOperationTOldIndex Property
Gets the index before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int OldIndex { get; }

Property Value

Type: Int32

Implements

ICollectionOperationOldIndex
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RemoveCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


RemoveCollectionItemOperation(T).OldItem Property

RemoveCollectionItemOperationTOldItem Property
Gets the item after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override T OldItem { get; }

Property Value

Type: T
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RemoveCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


RemoveCollectionItemOperation(T).OperationKind Property

RemoveCollectionItemOperationTOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RemoveCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


RemoveDictionaryItemOperation(TKey, TValue) Class

RemoveDictionaryItemOperationTKey, TValue Class
Represents a Remove(TKey) operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsDictionaryOperation TKey, TValue
PostSharp.Patterns.Recording.OperationsRemoveDictionaryItemOperationTKey, TValue

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class RemoveDictionaryItemOperation<TKey, TValue> : DictionaryOperation<TKey, TValue>

Type Parameters

TKey
Type of dictionary keys.
TValue
Type of dictionary values.

The RemoveDictionaryItemOperationTKey, TValue type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from DictionaryOperationTKey, TValue.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed. (Inherited from DictionaryOperationTKey, TValue.)
Public property | Key | Gets the key of the dictionary entry affected by the operation. (Overrides DictionaryOperationTKey, TValueKey.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewValue | Gets the value of the dictionary entry after the operation. (Inherited from DictionaryOperationTKey, TValue.)
Public property | OldValue | Gets the value of the dictionary entry before the operation. (Overrides DictionaryOperationTKey, TValueOldValue.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


RemoveDictionaryItemOperation(TKey, TValue) Methods

RemoveDictionaryItemOperationTKey, TValue Methods

The RemoveDictionaryItemOperationTKey, TValue generic type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from DictionaryOperationTKey, TValue.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RemoveDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


RemoveDictionaryItemOperation(TKey, TValue) Properties

RemoveDictionaryItemOperationTKey, TValue Properties

The RemoveDictionaryItemOperationTKey, TValue generic type exposes the following members.

Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed. (Inherited from DictionaryOperationTKey, TValue.)
Public property | Key | Gets the key of the dictionary entry affected by the operation. (Overrides DictionaryOperationTKey, TValueKey.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewValue | Gets the value of the dictionary entry after the operation. (Inherited from DictionaryOperationTKey, TValue.)
Public property | OldValue | Gets the value of the dictionary entry before the operation. (Overrides DictionaryOperationTKey, TValueOldValue.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
See Also

Reference

RemoveDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


RemoveDictionaryItemOperation(TKey, TValue).Key Property

RemoveDictionaryItemOperationTKey, TValueKey Property
Gets the key of the dictionary entry affected by the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override TKey Key { get; }

Property Value

Type: TKey
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RemoveDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


RemoveDictionaryItemOperation(TKey, TValue).OldValue Property

RemoveDictionaryItemOperationTKey, TValueOldValue Property
Gets the value of the dictionary entry before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override TValue OldValue { get; }

Property Value

Type: TValue
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RemoveDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


RemoveDictionaryItemOperation(TKey, TValue).OperationKind Property

RemoveDictionaryItemOperationTKey, TValueOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RemoveDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


SetCollectionItemOperation(T) Class

SetCollectionItemOperationT Class
Represents a set_Item(Int32, UTP) operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsCollectionOperation T
PostSharp.Patterns.Recording.OperationsSetCollectionItemOperationT

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class SetCollectionItemOperation<T> : CollectionOperation<T>

Type Parameters

T
Type of collection items.

The SetCollectionItemOperationT type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from CollectionOperationT.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed. (Inherited from CollectionOperationT.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewIndex | Gets the index after the operation. (Overrides CollectionOperationTNewIndex.)
Public property | NewItem | Gets the item before the operation. (Overrides CollectionOperationTNewItem.)
Public property | OldIndex | Gets the index before the operation. (Overrides CollectionOperationTOldIndex.)
Public property | OldItem | Gets the item after the operation. (Overrides CollectionOperationTOldItem.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


SetCollectionItemOperation(T) Methods

SetCollectionItemOperationT Methods

The SetCollectionItemOperationT generic type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from CollectionOperationT.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SetCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


SetCollectionItemOperation(T) Properties

SetCollectionItemOperationT Properties

The SetCollectionItemOperationT generic type exposes the following members.

Properties
 | Name | Description
Public property | Collection | Gets the collection on which the operation was performed. (Inherited from CollectionOperationT.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewIndex | Gets the index after the operation. (Overrides CollectionOperationTNewIndex.)
Public property | NewItem | Gets the item before the operation. (Overrides CollectionOperationTNewItem.)
Public property | OldIndex | Gets the index before the operation. (Overrides CollectionOperationTOldIndex.)
Public property | OldItem | Gets the item after the operation. (Overrides CollectionOperationTOldItem.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
See Also

Reference

SetCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


SetCollectionItemOperation(T).NewIndex Property

SetCollectionItemOperationTNewIndex Property
Gets the index after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int NewIndex { get; }

Property Value

Type: Int32

Implements

ICollectionOperationNewIndex
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SetCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


SetCollectionItemOperation(T).NewItem Property

SetCollectionItemOperationTNewItem Property
Gets the item before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override T NewItem { get; }

Property Value

Type: T
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SetCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


SetCollectionItemOperation(T).OldIndex Property

SetCollectionItemOperationTOldIndex Property
Gets the index before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int OldIndex { get; }

Property Value

Type: Int32

Implements

ICollectionOperationOldIndex
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SetCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


SetCollectionItemOperation(T).OldItem Property

SetCollectionItemOperationTOldItem Property
Gets the item after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override T OldItem { get; }

Property Value

Type: T
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SetCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


SetCollectionItemOperation(T).OperationKind Property

SetCollectionItemOperationTOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SetCollectionItemOperationT Class
PostSharp.Patterns.Recording.Operations Namespace


SetDictionaryItemOperation(TKey, TValue) Class

SetDictionaryItemOperationTKey, TValue Class
Represents a set_Item(UTP, UTP) operation.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.RecordingOperation
PostSharp.Patterns.Recording.OperationsDictionaryOperation TKey, TValue
PostSharp.Patterns.Recording.OperationsSetDictionaryItemOperationTKey, TValue

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class SetDictionaryItemOperation<TKey, TValue> : DictionaryOperation<TKey, TValue>

Type Parameters

TKey
Type of dictionary keys.
TValue
Type of dictionary values.

The SetDictionaryItemOperationTKey, TValue type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from DictionaryOperationTKey, TValue.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed. (Inherited from DictionaryOperationTKey, TValue.)
Public property | Key | Gets the key of the dictionary entry affected by the operation. (Overrides DictionaryOperationTKey, TValueKey.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewValue | Gets the value of the dictionary entry after the operation. (Overrides DictionaryOperationTKey, TValueNewValue.)
Public property | OldValue | Gets the value of the dictionary entry before the operation. (Overrides DictionaryOperationTKey, TValueOldValue.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Recording.Operations Namespace


SetDictionaryItemOperation(TKey, TValue) Methods

SetDictionaryItemOperationTKey, TValue Methods

The SetDictionaryItemOperationTKey, TValue generic type exposes the following members.

Methods
 | Name | Description
Public method | VisitAffectedObjects | Executes a given action on all recordable objects involved with the current Operation. (Inherited from DictionaryOperationTKey, TValue.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SetDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


SetDictionaryItemOperation(TKey, TValue) Properties

SetDictionaryItemOperationTKey, TValue Properties

The SetDictionaryItemOperationTKey, TValue generic type exposes the following members.

Properties
 | Name | Description
Public property | Dictionary | Gets the collection on which the operation was performed. (Inherited from DictionaryOperationTKey, TValue.)
Public property | Key | Gets the key of the dictionary entry affected by the operation. (Overrides DictionaryOperationTKey, TValueKey.)
Public property | Name | Gets the operation name. (Inherited from Operation.)
Public property | NewValue | Gets the value of the dictionary entry after the operation. (Overrides DictionaryOperationTKey, TValueNewValue.)
Public property | OldValue | Gets the value of the dictionary entry before the operation. (Overrides DictionaryOperationTKey, TValueOldValue.)
Public property | OperationDescriptor | Gets the IOperationDescriptor, which is used by the OperationFormatter to produce a human-readable description of the current operation. (Inherited from Operation.)
Public property | OperationKind | Gets the kind of operation. (Overrides OperationOperationKind.)
Top
See Also

Reference

SetDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


SetDictionaryItemOperation(TKey, TValue).Key Property

SetDictionaryItemOperationTKey, TValueKey Property
Gets the key of the dictionary entry affected by the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override TKey Key { get; }

Property Value

Type: TKey
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SetDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


SetDictionaryItemOperation(TKey, TValue).NewValue Property

SetDictionaryItemOperationTKey, TValueNewValue Property
Gets the value of the dictionary entry after the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override TValue NewValue { get; }

Property Value

Type: TValue
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SetDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


SetDictionaryItemOperation(TKey, TValue).OldValue Property

SetDictionaryItemOperationTKey, TValueOldValue Property
Gets the value of the dictionary entry before the operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override TValue OldValue { get; }

Property Value

Type: TValue
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SetDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


SetDictionaryItemOperation(TKey, TValue).OperationKind Property

SetDictionaryItemOperationTKey, TValueOperationKind Property
Gets the kind of operation.

Namespace: PostSharp.Patterns.Recording.Operations
Assembly: PostSharp.Patterns.Model (in PostSharp.Patterns.Model.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override OperationKind OperationKind { get; }

Property Value

Type: OperationKind

Implements

IOperationDescriptorOperationKind
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SetDictionaryItemOperationTKey, TValue Class
PostSharp.Patterns.Recording.Operations Namespace


PostSharp.Patterns.Threading Namespace

PostSharp.Patterns.Threading Namespace
The PostSharp.Patterns.Threading namespace contains an implementation of several threading models, and other thread dispatching aspects.
Classes
 | Class | Description
Public class | AccessLevelAttribute | Base class for ReaderAttribute, WriterAttribute, YielderAttribute UpgradeableReaderAttribute.
Public class | Actor | Obsolete.
Public class | ActorAttribute | Custom attribute that, when applied to a class, implements the ActorThreadingModel to this class, in which calls to methods are processed asynchronously from a single thread, suppressing concurrency inside each instance of the target class.
Public class | ActorDispatcher | A dispatcher compatible with the ActorThreadingModel threading model, with a message queue based on a [!:ConcurrentQueue<T>]. The queue itself is processed from the ThreadPool.
Public class | ActorExceptionEventArgs | Obsolete.
Public class | AssumeImmutableAttribute | Custom attribute that, when applied to a targetType, means that targetType should be assumed to be immutable. The custom attribute can be applied to an assembly by specifying the Type property using the AssumeImmutableAttribute(Type) constructor.
Public class | BackgroundAttribute | Custom attribute that, when applied on a method, causes the method to execute in the background.
Public class | ConcurrentAccessException | Exception thrown when two threads simultaneously attempt to access a method annotated with the ThreadUnsafeAttribute custom attribute.
Public class | DeadlockDetectedEventArgs | Arguments for the DeadlockDetected event.
Public class | DeadlockDetectionPolicy | Detects deadlocks occurring because of circular wait conditions.
Public class | DeadlockedThreadInfo | Described state of thread that was detected to be in a deadlock.
Public class | DeadlockException | Exception thrown by the DeadlockDetectionPolicy class when a deadlock is detected.
Public class | DeadlockInfo | Describes the detected deadlock.
Public class | DispatchedAttribute | Custom attribute that, when applied on a method, specifies that the method should be executed in UI thread.
Public class | DispatcherFactory | Provides implementations of the IDispatcher interface.
Public class | EntryPointAttribute | Custom attribute that, when applied to a private or protected instance method, causes all threading model aspects (derived from ThreadAwareAttribute to introduce runtime generation code.
Public class | ExplicitlySynchronizedAttribute | Custom attribute that, when applied to a method or field, specifies that threading model aspects (derived from ThreadAwareAttribute) should ignore all verifications for this field or method.
Public class | FreezableAttribute | Custom attribute that, when applied to a class, implements the FreezableThreadingModel to this class. The aspect introduces the IFreezable interface into the target class. After the Freeze method has been invoked, the object can no longer be modified, and can therefore be safely shared between several threads.
Public class | ImmutableAttribute | Custom attribute that, when applied to a class, implements the ImmutableThreadingModel to this class. The aspect introduces the IImmutable interface into the target class. Immutable objects cannot be modified after the constructor exits.
Public class | LockNotHeldException | Obsolete.
Public class | ObjectReadOnlyException | Exception thrown by objects that have the FreezableThreadingModel or ImmutableThreadingModel when an attempt is made to modify the object after it has been made read-only.
Public class | ObserverLockAttribute | Obsolete.
Public class | PrivateThreadAwareAttribute | Custom attribute that, when applied to a class, implement the PrivateThreadingModel into this class, in which the threading model of an object is determined by the parent it is assigned to in a parent-child relationship.
Public class | ReaderAttribute | Custom attribute that, when applied on a method, specifies that the method requires read access to the object.
Public class | ReaderLockAttribute | Obsolete.
Public class | ReaderWriterLockAttribute | Obsolete.
Public class | ReaderWriterSynchronizedAttribute | Custom attribute that, when applied on a class, applies the ReaderWriterSynchronizedThreadingModel model to this class and all derived class. Members of this class must then be annotated with attributes specifying the required access level (ReaderAttribute, WriterAttribute, YielderAttribute or UpgradeableReaderAttribute), otherwise build-time and run-time errors are emitted.
Public class | ReadOnlyThreadAwareAttribute | Base class for aspects FreezableAttribute and ImmutableAttribute.
Public class | ReentrantAttribute | Custom attribute that means that the async method to which it is applied can be safely re-entered on each await statement. In case of lock-based models, it means that the lock is released while awaiting. For the actor model, it means that other methods can be invoked during awaiting.
Public class | RequiresThreadSafeAttribute | Custom attribute that, when applied to a field, property or parameter, checks that the assigned object is thread safe. Otherwise, the assignment results in an ArgumentException/
Public class | SynchronizedAttribute | Custom attribute that, when applied to a class, implements the SynchronizedThreadingModel into this class. In a synchronized object, only a single thread can access the object at a time. If a second thread needs to access the object while it is in used by a first thread, the second thread has to wait until the first thread completes its access.
Public class | ThreadAccessException | Exception thrown when the calling thread does not have access to the object.
Public class | ThreadAffineAttribute | Custom attribute that, when applied on a type, ensures the instances of this type can only be accessed by the thread that created the instance. When a different thread accesses instances of this type, a ThreadMismatchException exception is thrown.
Public class | ThreadAwareAttribute | Base class for all aspects implementing threading models.
Public class | ThreadAwareAttributeTargetClass | Describes the members that are consumed by the ThreadAwareAttribute aspect. You can define one or many of these members in classes that are the target of ThreadAwareAttribute to customize the behavior of the ThreadAwareAttribute aspect.
Public class | ThreadAwareExtensions | Provides extension methods to the IThreadAware interface.
Public class | ThreadingException | Base class for exceptions thrown by the PostSharp.Patterns.Threading component.
Public class | ThreadingModel | Base class for all threading models. Defines properties that describe the characteristics of threading models. All classes derived from ThreadingModel are necessarily singletons.
Public class | ThreadingPatternsAspectRoles | Enumerates the aspect roles (for use with AspectRoleDependencyAttribute) used by the PostSharp.Patterns.Threading component.
Public class | ThreadingServices | Exposes methods to work with the PostSharp.Patterns.Threading namespace.
Public class | ThreadingUnhandledExceptionEventArgs | Arguments of the UnhandledException event.
Public class | ThreadMismatchException | Exception thrown when a thread attempts to access an object that is affined to another thread.
Public class | ThreadUnsafeAttribute | Custom attribute that, when applied on a type, ensures that only one thread executes in methods of this type. When more than one thread accesses methods of this type, a ConcurrentAccessException exception is thrown.
Public class | UpgradeableReaderAttribute | Custom attribute that, when applied on a method, specifies that the method requires read and write access to the object, but other threads are allowed to acquire read (but not write) access to the object until a method with the WriterAttribute custom attribute is executed.
Public class | UpgradeableReaderLockAttribute | Obsolete.
Public class | WriterAttribute | Custom attribute that, when applied on a method, specifies that the method requires write access to the object.
Public class | WriterLockAttribute | Obsolete.
Public class | YielderAttribute | Custom attribute that, when applied on a method, specifies that the method that currently holds write access to the object (see WriterAttribute) allows other threads to read the object during the execution of the target method. This custom attribute is typically used on methods that raise events that must be processed synchronously by other threads.
Structures
 | Structure | Description
Public structure | ConcurrentAccessToken | Token returned by the AcquireAccess(ObjectAccessLevel, ConcurrentAccessToken) method. This token is intended to be used in a using block. Consumers of this method must call Complete on success, and Dispose on exception.
Interfaces
 | Interface | Description
Public interface | IActor | Interface implemented by the ActorAttribute aspect.
Public interface | IActorController | Specific definition of the IConcurrencyController for the ActorThreadingModel.
Public interface | IActorDispatcher | Augments the IDispatcher interface with an Initialize method, which is invoked after the actor constructor has been invoked.
Public interface | IConcurrencyController | Controls access to an entity from possibly several threads.
Public interface | IDispatcher | Defines the semantics of a facility that executes actions synchronously or asynchronously, possibly on a different thread.
Public interface | IDispatcherObject | Interface implemented by objects that are whose access to methods is being controlled by a Dispatcher.
Public interface | IFreezable | Interface implemented by the FreezableAttribute aspect. Defines a Freeze method.
Public interface | IImmutable | Interface implemented by the ImmutableAttribute aspect.
Public interface | IReaderWriterSynchronized | Obsolete.
Public interface | IThreadAware | Interface implemented by objects that are aware of concurrency. Access to thread-aware objects is controlled by a concurrency controller (IConcurrencyController). Any aspect implementing a threading model (ThreadAwareObjectAttribute) introduces this interface to the target class and ensures that accesses to this class go through the controller.
Enumerations
 | Enumeration | Description
Public enumeration | ThreadingUnhandledExceptionSource | Enumeration of components that can raise the UnhandledException event.


AccessLevelAttribute Class

AccessLevelAttribute Class
Base class for ReaderAttribute, WriterAttribute, YielderAttribute UpgradeableReaderAttribute.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingReaderWriterLockAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class AccessLevelAttribute : MulticastAttribute

The AccessLevelAttribute type exposes the following members.

Constructors
 | Name | Description
Protected method | AccessLevelAttribute | Initializes a new instance of the AccessLevelAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


AccessLevelAttribute Constructor

AccessLevelAttribute Constructor
Initializes a new instance of the AccessLevelAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected AccessLevelAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

AccessLevelAttribute Class
PostSharp.Patterns.Threading Namespace


AccessLevelAttribute Methods

AccessLevelAttribute Methods

The AccessLevelAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AccessLevelAttribute Class
PostSharp.Patterns.Threading Namespace


AccessLevelAttribute Properties

AccessLevelAttribute Properties

The AccessLevelAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

AccessLevelAttribute Class
PostSharp.Patterns.Threading Namespace


ActorAttribute Class

ActorAttribute Class
Custom attribute that, when applied to a class, implements the ActorThreadingModel to this class, in which calls to methods are processed asynchronously from a single thread, suppressing concurrency inside each instance of the target class.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
PostSharp.Patterns.ThreadingActorAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ActorAttribute : ThreadAwareAttribute,
    IActor, IDispatcherObject, IThreadAware

The ActorAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ActorAttribute | Initializes a new instance of the ActorAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Overrides AggregatableClientAttributeOnInstanceConstructed.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
Remarks

Calls to public methods of actors are packaged into messages and appended to a message queue. This message queue is processed by a single thread. Therefore, there is never more than one thread accessing the object, which makes the this object thread safe.

Public methods must be void (with no ref or out parameter), or must be async. Other methods cannot be executed asynchronously, and therefore are forbidden in a class following the ActorThreadingModel class unless these methods are annotated with the ExplicitlySynchronizedAttribute custom attribute. This attribute specifies that no dispatching should be done for this method. Using ExplicitlySynchronizedAttribute breaks the thread-safety guarantees of the ActorThreadingModel.

Several actors can share the same message queue by sharing the same instance of IActorDispatcher interface, which the target class can provide by overriding the IDispatcherObject interface.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ActorAttribute Constructor

ActorAttribute Constructor
Initializes a new instance of the ActorAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ActorAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ActorAttribute Class
PostSharp.Patterns.Threading Namespace


ActorAttribute Methods

ActorAttribute Methods

The ActorAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Overrides AggregatableClientAttributeOnInstanceConstructed.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ActorAttribute Class
PostSharp.Patterns.Threading Namespace


ActorAttribute.OnInstanceConstructed Method

ActorAttributeOnInstanceConstructed Method
Executed when the target instance gets fully initialized, i.e. just after all constructors have completed.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void OnInstanceConstructed()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ActorAttribute Class
PostSharp.Patterns.Threading Namespace


ActorAttribute Properties

ActorAttribute Properties

The ActorAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
See Also

Reference

ActorAttribute Class
PostSharp.Patterns.Threading Namespace


ActorDispatcher Class

ActorDispatcher Class
A dispatcher compatible with the ActorThreadingModel threading model, with a message queue based on a [!:ConcurrentQueue<T>]. The queue itself is processed from the ThreadPool.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingActorDispatcher

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class ActorDispatcher : IActorDispatcher,
    IDispatcher

The ActorDispatcher type exposes the following members.

Constructors
 | Name | Description
Public method | ActorDispatcher | Initializes a new ActorDispatcher.
Top
Methods
 | Name | Description
Public method | BeginInvoke | Queues an action for asynchronous execution.
Public method | CheckAccess | Determines whether the current thread has access to the current dispatcher.
Protected method | MustYield | Determines whether the ProcessQueue method should interrupt the processing of the message queue before the queue is empty.
Protected method | ProcessQueue | Processes the message queue synchronously.
Protected method | ScheduleProcessQueue | Schedules the execution of the ProcessQueue, typically on a worker thread or in the ThreadPool. The default implementation uses the ThreadPool.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks

This implementation will append every action (as a result of the BeginInvoke(SendOrPostCallback, Object) method) into a [!:ConcurrentQueue<T>]. If will then create a work item to process the [!:ConcurrentQueue<T>] and schedule the work item to the ThreadPool. The same work item will keep running unless the message queue is empty, then will terminate.

You can use a different scheduling mechanism instead of the ThreadPool by deriving the class and overriding the ScheduleProcessQueue method.

Note that the Invoke(SendOrPostCallback, Object) method of the IDispatcher interface is not supported, because the ActorThreadingModel does not support synchronous calls.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ActorDispatcher Constructor

ActorDispatcher Constructor
Initializes a new ActorDispatcher.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ActorDispatcher()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ActorDispatcher Class
PostSharp.Patterns.Threading Namespace


ActorDispatcher Methods

ActorDispatcher Methods

The ActorDispatcher type exposes the following members.

Methods
 | Name | Description
Public method | BeginInvoke | Queues an action for asynchronous execution.
Public method | CheckAccess | Determines whether the current thread has access to the current dispatcher.
Protected method | MustYield | Determines whether the ProcessQueue method should interrupt the processing of the message queue before the queue is empty.
Protected method | ProcessQueue | Processes the message queue synchronously.
Protected method | ScheduleProcessQueue | Schedules the execution of the ProcessQueue, typically on a worker thread or in the ThreadPool. The default implementation uses the ThreadPool.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ActorDispatcher Class
PostSharp.Patterns.Threading Namespace


ActorDispatcher.BeginInvoke Method

ActorDispatcherBeginInvoke Method
Queues an action for asynchronous execution.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void BeginInvoke(
    SendOrPostCallback action,
    Object state
)

Parameters

action
Type: System.ThreadingSendOrPostCallback
Action to be executed.
state
Type: SystemObject
Parameter passed to action

Implements

IDispatcherBeginInvoke(SendOrPostCallback, Object)
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ActorDispatcher Class
PostSharp.Patterns.Threading Namespace


ActorDispatcher.CheckAccess Method

ActorDispatcherCheckAccess Method
Determines whether the current thread has access to the current dispatcher.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CheckAccess()

Return Value

Type: Boolean
true if the current thread can directly call methods of objects protected by the current dispatcher, or false if methods Invoke(SendOrPostCallback, Object) or BeginInvoke(SendOrPostCallback, Object) must be used.

Implements

IDispatcherCheckAccess
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ActorDispatcher Class
PostSharp.Patterns.Threading Namespace


ActorDispatcher.MustYield Method

ActorDispatcherMustYield Method
Determines whether the ProcessQueue method should interrupt the processing of the message queue before the queue is empty.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual bool MustYield(
    int count
)

Parameters

count
Type: SystemInt32
Number of messages already processed by the current invocation of the ProcessQueue method.

Return Value

Type: Boolean
true if the ProcessQueue method should stop processing messages, false if it should continue.
Remarks

When this method returns true, the ProcessQueue method will immediately invoke the ScheduleProcessQueue method to process remaining messages.

The purpose of this method is to allow custom implementations of the ActorDispatcher class, which may dispatch the message queue execution on a pool composed of a small numbers of threads, to prevent a few actors to consume all available threads.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ActorDispatcher Class
PostSharp.Patterns.Threading Namespace


ActorDispatcher.ProcessQueue Method

ActorDispatcherProcessQueue Method
Processes the message queue synchronously.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected void ProcessQueue()
Remarks

This method can be invoked by an overridden implementation of the ScheduleProcessQueue method.

This method will process all messages until the queue is empty, unless the overridden implementation of MustYield(Int32) returns false.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ActorDispatcher Class
PostSharp.Patterns.Threading Namespace


ActorDispatcher.ScheduleProcessQueue Method

ActorDispatcherScheduleProcessQueue Method
Schedules the execution of the ProcessQueue, typically on a worker thread or in the ThreadPool. The default implementation uses the ThreadPool.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void ScheduleProcessQueue()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ActorDispatcher Class
PostSharp.Patterns.Threading Namespace


AssumeImmutableAttribute Class

AssumeImmutableAttribute Class
Custom attribute that, when applied to a targetType, means that targetType should be assumed to be immutable. The custom attribute can be applied to an assembly by specifying the Type property using the AssumeImmutableAttribute(Type) constructor.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAssumeImmutableAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class AssumeImmutableAttribute : MulticastAttribute

The AssumeImmutableAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | AssumeImmutableAttribute | Initializes a new instance of the AssumeImmutableAttribute custom attribute that can be applied to a specific targetType.
Public method | AssumeImmutableAttribute(Type) | Initializes a new instance of the AssumeImmutableAttribute custom attribute that can be applied to an assembly, passing the immutable as a constructor argument. This constructor allows to add assumptions for types that are not defined in this current assembly.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | TargetType | Gets the targetType that should be assumed immutable, if the AssumeImmutableAttribute(Type) constructor was used.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


AssumeImmutableAttribute Constructor

AssumeImmutableAttribute Constructor
Overload List
 | Name | Description
Public method | AssumeImmutableAttribute | Initializes a new instance of the AssumeImmutableAttribute custom attribute that can be applied to a specific targetType.
Public method | AssumeImmutableAttribute(Type) | Initializes a new instance of the AssumeImmutableAttribute custom attribute that can be applied to an assembly, passing the immutable as a constructor argument. This constructor allows to add assumptions for types that are not defined in this current assembly.
Top
See Also

Reference

AssumeImmutableAttribute Class
PostSharp.Patterns.Threading Namespace


AssumeImmutableAttribute Constructor

AssumeImmutableAttribute Constructor
Initializes a new instance of the AssumeImmutableAttribute custom attribute that can be applied to a specific targetType.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AssumeImmutableAttribute()
Version Information

Supported in: 4.1

See Also

Reference

AssumeImmutableAttribute Class
AssumeImmutableAttribute Overload
PostSharp.Patterns.Threading Namespace


AssumeImmutableAttribute Constructor (Type)

AssumeImmutableAttribute Constructor (Type)
Initializes a new instance of the AssumeImmutableAttribute custom attribute that can be applied to an assembly, passing the immutable as a constructor argument. This constructor allows to add assumptions for types that are not defined in this current assembly.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public AssumeImmutableAttribute(
    Type targetType
)

Parameters

targetType
Type: SystemType
The immutable targetType.
Version Information

Supported in: 4.1

See Also

Reference

AssumeImmutableAttribute Class
AssumeImmutableAttribute Overload
PostSharp.Patterns.Threading Namespace


AssumeImmutableAttribute Methods

AssumeImmutableAttribute Methods

The AssumeImmutableAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

AssumeImmutableAttribute Class
PostSharp.Patterns.Threading Namespace


AssumeImmutableAttribute Properties

AssumeImmutableAttribute Properties

The AssumeImmutableAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | TargetType | Gets the targetType that should be assumed immutable, if the AssumeImmutableAttribute(Type) constructor was used.
Top
See Also

Reference

AssumeImmutableAttribute Class
PostSharp.Patterns.Threading Namespace


AssumeImmutableAttribute.TargetType Property

AssumeImmutableAttributeTargetType Property
Gets the targetType that should be assumed immutable, if the AssumeImmutableAttribute(Type) constructor was used.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type TargetType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1

See Also

Reference

AssumeImmutableAttribute Class
PostSharp.Patterns.Threading Namespace


BackgroundAttribute Class

BackgroundAttribute Class
Custom attribute that, when applied on a method, causes the method to execute in the background.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.AspectsMethodInterceptionAspect
PostSharp.Patterns.ThreadingBackgroundAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class BackgroundAttribute : MethodInterceptionAspect

The BackgroundAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | BackgroundAttribute | Initializes a new instance of the BackgroundAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides MethodLevelAspectCompileTimeValidate(MethodBase).)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnInvoke | Method invoked instead of the method to which the aspect has been applied. (Overrides MethodInterceptionAspectOnInvoke(MethodInterceptionArgs).)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | IsLongRunning | Specifies that the method is long-running and should be executed on its own thread, if that is supported on the target platform. If false, the method will be executed in the thread pool.
Top
Remarks

If the IsLongRunning property is set to true, the method will be executed in a new thread. Otherwise, it will be queued into the ThreadPool.

If the target method results in an exception, the exception can be handled by subscribing to the UnhandledException event. Unhandled exceptions are rethrown, typically causing the application to crash.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


BackgroundAttribute Constructor

BackgroundAttribute Constructor
Initializes a new instance of the BackgroundAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public BackgroundAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

BackgroundAttribute Class
PostSharp.Patterns.Threading Namespace


BackgroundAttribute Methods

BackgroundAttribute Methods

The BackgroundAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides MethodLevelAspectCompileTimeValidate(MethodBase).)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnInvoke | Method invoked instead of the method to which the aspect has been applied. (Overrides MethodInterceptionAspectOnInvoke(MethodInterceptionArgs).)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

BackgroundAttribute Class
PostSharp.Patterns.Threading Namespace


BackgroundAttribute.CompileTimeValidate Method

BackgroundAttributeCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides MethodLevelAspectCompileTimeValidate(MethodBase).)
Top
See Also

Reference

BackgroundAttribute Class
PostSharp.Patterns.Threading Namespace


BackgroundAttribute.CompileTimeValidate Method (MethodBase)

BackgroundAttributeCompileTimeValidate Method (MethodBase)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool CompileTimeValidate(
    MethodBase method
)

Parameters

method
Type: System.ReflectionMethodBase
Method to which the aspect has been applied

Return Value

Type: Boolean
true if the aspect was applied to an acceptable field, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

BackgroundAttribute Class
CompileTimeValidate Overload
PostSharp.Patterns.Threading Namespace

Other Resources

Conceptual Documentation: Validating Aspects


BackgroundAttribute.OnInvoke Method

BackgroundAttributeOnInvoke Method
Method invoked instead of the method to which the aspect has been applied.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void OnInvoke(
    MethodInterceptionArgs args
)

Parameters

args
Type: PostSharp.AspectsMethodInterceptionArgs
Advice arguments.

Implements

IMethodInterceptionAspectOnInvoke(MethodInterceptionArgs)
Remarks

The implementation of OnInvoke(MethodInterceptionArgs) may invoke Proceed, may schedule it for invocation from another thread, or may completely skip its invocation. Alternatively, it may use Binding. Before returning to the caller, the OnInvoke(MethodInterceptionArgs) method must set the return value (property ReturnValue) and all output arguments (property Arguments), otherwise the target method may fail with a NullReferenceException. These are normally set by calling Proceed.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

BackgroundAttribute Class
PostSharp.Patterns.Threading Namespace
PostSharp.AspectsMethodInterceptionArgs


BackgroundAttribute Properties

BackgroundAttribute Properties

The BackgroundAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | IsLongRunning | Specifies that the method is long-running and should be executed on its own thread, if that is supported on the target platform. If false, the method will be executed in the thread pool.
Top
See Also

Reference

BackgroundAttribute Class
PostSharp.Patterns.Threading Namespace


BackgroundAttribute.IsLongRunning Property

BackgroundAttributeIsLongRunning Property
Specifies that the method is long-running and should be executed on its own thread, if that is supported on the target platform. If false, the method will be executed in the thread pool.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsLongRunning { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

BackgroundAttribute Class
PostSharp.Patterns.Threading Namespace


ConcurrentAccessException Class

ConcurrentAccessException Class
Exception thrown when two threads simultaneously attempt to access a method annotated with the ThreadUnsafeAttribute custom attribute.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.Patterns.ThreadingThreadingException
PostSharp.Patterns.ThreadingConcurrentAccessException

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class ConcurrentAccessException : ThreadingException

The ConcurrentAccessException type exposes the following members.

Constructors
 | Name | Description
Public method | ConcurrentAccessException | Initializes a new ConcurrentAccessException.
Public method | ConcurrentAccessException(String) | Initializes a new ConcurrentAccessException and sets the error message.
Public method | ConcurrentAccessException(String, Exception) | Initializes a new ConcurrentAccessException and sets the error message and the inner exception.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ConcurrentAccessException Constructor

ConcurrentAccessException Constructor
Overload List
 | Name | Description
Public method | ConcurrentAccessException | Initializes a new ConcurrentAccessException.
Public method | ConcurrentAccessException(String) | Initializes a new ConcurrentAccessException and sets the error message.
Public method | ConcurrentAccessException(String, Exception) | Initializes a new ConcurrentAccessException and sets the error message and the inner exception.
Top
See Also

Reference

ConcurrentAccessException Class
PostSharp.Patterns.Threading Namespace


ConcurrentAccessException Constructor

ConcurrentAccessException Constructor
Initializes a new ConcurrentAccessException.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ConcurrentAccessException()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ConcurrentAccessException Class
ConcurrentAccessException Overload
PostSharp.Patterns.Threading Namespace


ConcurrentAccessException Constructor (String)

ConcurrentAccessException Constructor (String)
Initializes a new ConcurrentAccessException and sets the error message.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ConcurrentAccessException(
    string message
)

Parameters

message
Type: SystemString
Error message.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ConcurrentAccessException Class
ConcurrentAccessException Overload
PostSharp.Patterns.Threading Namespace


ConcurrentAccessException Constructor (String, Exception)

ConcurrentAccessException Constructor (String, Exception)
Initializes a new ConcurrentAccessException and sets the error message and the inner exception.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ConcurrentAccessException(
    string message,
    Exception inner
)

Parameters

message
Type: SystemString
Error message.
inner
Type: SystemException
Inner exception.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ConcurrentAccessException Class
ConcurrentAccessException Overload
PostSharp.Patterns.Threading Namespace


ConcurrentAccessException Methods

ConcurrentAccessException Methods

The ConcurrentAccessException type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ConcurrentAccessException Class
PostSharp.Patterns.Threading Namespace


ConcurrentAccessToken Structure

ConcurrentAccessToken Structure
Token returned by the AcquireAccess(ObjectAccessLevel, ConcurrentAccessToken) method. This token is intended to be used in a using block. Consumers of this method must call Complete on success, and Dispose on exception.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public struct ConcurrentAccessToken : IDisposable

The ConcurrentAccessToken type exposes the following members.

Methods
 | Name | Description
Public method | CheckContext | Determines whether the current ConcurrentAccessToken is valid in the current context.
Public method | Complete | Indicates that the operation requiring access on an object has successfully completed.
Public method | Dispose | Indicates that the operation requiring access on an object has completed. If the Complete method is not invoked before the Dispose method, the transaction is considered to have failed. Current threading models do not support transactions and therefore this semantic is currently unused, but it may be used in the future.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
Name | Description
Null | Gets a null instance of the ConcurrentAccessToken type.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ConcurrentAccessToken Methods

ConcurrentAccessToken Methods

The ConcurrentAccessToken type exposes the following members.

Methods
 | Name | Description
Public method | CheckContext | Determines whether the current ConcurrentAccessToken is valid in the current context.
Public method | Complete | Indicates that the operation requiring access on an object has successfully completed.
Public method | Dispose | Indicates that the operation requiring access on an object has completed. If the Complete method is not invoked before the Dispose method, the transaction is considered to have failed. Current threading models do not support transactions and therefore this semantic is currently unused, but it may be used in the future.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ConcurrentAccessToken Structure
PostSharp.Patterns.Threading Namespace


ConcurrentAccessToken.CheckContext Method

ConcurrentAccessTokenCheckContext Method
Determines whether the current ConcurrentAccessToken is valid in the current context.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CheckContext(
    bool canBeParentContext = false
)

Parameters

canBeParentContext (Optional)
Type: SystemBoolean
true if the current ConcurrentAccessToken can be the token of a parent token, false if it must be the token of the current context.

Return Value

Type: Boolean
true if the current ConcurrentAccessToken is valid for the current context, otherwise false.
Version Information

Supported in: 4.1

See Also

Reference

ConcurrentAccessToken Structure
PostSharp.Patterns.Threading Namespace


ConcurrentAccessToken.Complete Method

ConcurrentAccessTokenComplete Method
Indicates that the operation requiring access on an object has successfully completed.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Complete()
Version Information

Supported in: 4.1

See Also

Reference

ConcurrentAccessToken Structure
PostSharp.Patterns.Threading Namespace


ConcurrentAccessToken.Dispose Method

ConcurrentAccessTokenDispose Method
Indicates that the operation requiring access on an object has completed. If the Complete method is not invoked before the Dispose method, the transaction is considered to have failed. Current threading models do not support transactions and therefore this semantic is currently unused, but it may be used in the future.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Dispose()

Implements

IDisposableDispose
Version Information

Supported in: 4.1

See Also

Reference

ConcurrentAccessToken Structure
PostSharp.Patterns.Threading Namespace


ConcurrentAccessToken Properties

ConcurrentAccessToken Properties

The ConcurrentAccessToken type exposes the following members.

Properties
Name | Description
Null | Gets a null instance of the ConcurrentAccessToken type.
Top
See Also

Reference

ConcurrentAccessToken Structure
PostSharp.Patterns.Threading Namespace


ConcurrentAccessToken.Null Property

ConcurrentAccessTokenNull Property
Gets a null instance of the ConcurrentAccessToken type.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static ConcurrentAccessToken Null { get; }

Property Value

Type: ConcurrentAccessToken
Version Information

Supported in: 4.1

See Also

Reference

ConcurrentAccessToken Structure
PostSharp.Patterns.Threading Namespace


DeadlockDetectedEventArgs Class

DeadlockDetectedEventArgs Class
Arguments for the DeadlockDetected event.
Inheritance Hierarchy
SystemObject
SystemEventArgs
PostSharp.Patterns.ThreadingDeadlockDetectedEventArgs

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class DeadlockDetectedEventArgs : EventArgs

The DeadlockDetectedEventArgs type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | DeadlockInfo | Gets the deadlock information object.
Public property | Handled | Gets of sets an information indicating whether the event was handled by the user. If the event is not handled, an exception will be thrown on all involved threads.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


DeadlockDetectedEventArgs Methods

DeadlockDetectedEventArgs Methods

The DeadlockDetectedEventArgs type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DeadlockDetectedEventArgs Class
PostSharp.Patterns.Threading Namespace


DeadlockDetectedEventArgs Properties

DeadlockDetectedEventArgs Properties

The DeadlockDetectedEventArgs type exposes the following members.

Properties
 | Name | Description
Public property | DeadlockInfo | Gets the deadlock information object.
Public property | Handled | Gets of sets an information indicating whether the event was handled by the user. If the event is not handled, an exception will be thrown on all involved threads.
Top
See Also

Reference

DeadlockDetectedEventArgs Class
PostSharp.Patterns.Threading Namespace


DeadlockDetectedEventArgs.DeadlockInfo Property

DeadlockDetectedEventArgsDeadlockInfo Property
Gets the deadlock information object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeadlockInfo DeadlockInfo { get; }

Property Value

Type: DeadlockInfo
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockDetectedEventArgs Class
PostSharp.Patterns.Threading Namespace


DeadlockDetectedEventArgs.Handled Property

DeadlockDetectedEventArgsHandled Property
Gets of sets an information indicating whether the event was handled by the user. If the event is not handled, an exception will be thrown on all involved threads.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Handled { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockDetectedEventArgs Class
PostSharp.Patterns.Threading Namespace


DeadlockDetectionPolicy Class

DeadlockDetectionPolicy Class
Detects deadlocks occurring because of circular wait conditions.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsAssemblyLevelAspect
PostSharp.Patterns.ThreadingDeadlockDetectionPolicy

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class DeadlockDetectionPolicy : AssemblyLevelAspect,
    IAspectProvider, IAspect, IService

The DeadlockDetectionPolicy type exposes the following members.

Constructors
 | Name | Description
Public method | DeadlockDetectionPolicy | Initializes a new instance of the DeadlockDetectionPolicy class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AssemblyLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from AssemblyLevelAspect.)
Public method | CompileTimeValidate(Assembly) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AssemblyLevelAspectCompileTimeValidate(Assembly).)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Remarks

The DeadlockDetectionPolicy works by building, in real time, a graph of dependencies between threads and waiting objects. All synchronization aspects of the threading pattern library, additionally to the most common .NET synchronization primitives. The following .NET methods that are supported: Mutex.WaitOne, Mutex.WaitAll, Mutex.Release, Mutex.SignalAndWait, Monitor.Enter, Monitor.Exit, Monitor.TryEnter, Thread.Join, all methods of ReaderWriterLockSlim, all methods of ReaderWriterLock except ReaderWriterLock.ReleaseLock, ReaderWriterLock.RestoreLock, all methods of Dispatcher, Dispatcher.BeginInvoke, Dispatcher.InvokeAsync, DispatcherOperation.Wait, Dispatcher

When synchronization objects wait for more then 200ms, a deadlock detection is performed. The algorithm analyzes the dependency graph for cycles and throws a DeadlockException in all threads involved in the cycle if one is detected.

Some actions on synchronization primitives, such as ReaderWriterLock.RestoreLock and WaitHandle.Handle, make it impossible to track deadlocks. If such methods are called, the synchronization primitive is excluded from the deadlock detection mechanism. If too many objects are excluded, the deadlock detection is automatically turned off.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


DeadlockDetectionPolicy Constructor

DeadlockDetectionPolicy Constructor
Initializes a new instance of the DeadlockDetectionPolicy class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeadlockDetectionPolicy()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DeadlockDetectionPolicy Class
PostSharp.Patterns.Threading Namespace


DeadlockDetectionPolicy Methods

DeadlockDetectionPolicy Methods

The DeadlockDetectionPolicy type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AssemblyLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from AssemblyLevelAspect.)
Public method | CompileTimeValidate(Assembly) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AssemblyLevelAspectCompileTimeValidate(Assembly).)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DeadlockDetectionPolicy Class
PostSharp.Patterns.Threading Namespace


DeadlockDetectionPolicy.CompileTimeValidate Method

DeadlockDetectionPolicyCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from AssemblyLevelAspect.)
Public method | CompileTimeValidate(Assembly) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides AssemblyLevelAspectCompileTimeValidate(Assembly).)
Top
See Also

Reference

DeadlockDetectionPolicy Class
PostSharp.Patterns.Threading Namespace


DeadlockDetectionPolicy.CompileTimeValidate Method (Assembly)

DeadlockDetectionPolicyCompileTimeValidate Method (Assembly)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool CompileTimeValidate(
    Assembly assembly
)

Parameters

assembly
Type: System.ReflectionAssembly
Assembly on which the current aspect is applied.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DeadlockDetectionPolicy Class
CompileTimeValidate Overload
PostSharp.Patterns.Threading Namespace

Other Resources

Conceptual Documentation: Validating Aspects


DeadlockDetectionPolicy Properties

DeadlockDetectionPolicy Properties

The DeadlockDetectionPolicy type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

DeadlockDetectionPolicy Class
PostSharp.Patterns.Threading Namespace


DeadlockedThreadInfo Class

DeadlockedThreadInfo Class
Described state of thread that was detected to be in a deadlock.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingDeadlockedThreadInfo

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class DeadlockedThreadInfo

The DeadlockedThreadInfo type exposes the following members.

Constructors
 | Name | Description
Public method | DeadlockedThreadInfo | Initializes the object.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ManagedThreadId | Gets ID of the managed thread.
Public property | StackTrace | Gets the stack trace of the thread in deadlock or null if it was not possible to obtain the stack trace.
Public property | Thread | Gets the thread in deadlock or null if the object was deserialized.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


DeadlockedThreadInfo Constructor

DeadlockedThreadInfo Constructor
Initializes the object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeadlockedThreadInfo(
    Thread thread,
    StackTrace stackTrace
)

Parameters

thread
Type: System.ThreadingThread
Thread in a deadlock.
stackTrace
Type: System.DiagnosticsStackTrace
Stack trace of the thread or null if it was not possible to obtain it.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockedThreadInfo Class
PostSharp.Patterns.Threading Namespace


DeadlockedThreadInfo Methods

DeadlockedThreadInfo Methods

The DeadlockedThreadInfo type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DeadlockedThreadInfo Class
PostSharp.Patterns.Threading Namespace


DeadlockedThreadInfo Properties

DeadlockedThreadInfo Properties

The DeadlockedThreadInfo type exposes the following members.

Properties
 | Name | Description
Public property | ManagedThreadId | Gets ID of the managed thread.
Public property | StackTrace | Gets the stack trace of the thread in deadlock or null if it was not possible to obtain the stack trace.
Public property | Thread | Gets the thread in deadlock or null if the object was deserialized.
Top
See Also

Reference

DeadlockedThreadInfo Class
PostSharp.Patterns.Threading Namespace


DeadlockedThreadInfo.ManagedThreadId Property

DeadlockedThreadInfoManagedThreadId Property
Gets ID of the managed thread.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int ManagedThreadId { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockedThreadInfo Class
PostSharp.Patterns.Threading Namespace


DeadlockedThreadInfo.StackTrace Property

DeadlockedThreadInfoStackTrace Property
Gets the stack trace of the thread in deadlock or null if it was not possible to obtain the stack trace.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public StackTrace StackTrace { get; }

Property Value

Type: StackTrace
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockedThreadInfo Class
PostSharp.Patterns.Threading Namespace


DeadlockedThreadInfo.Thread Property

DeadlockedThreadInfoThread Property
Gets the thread in deadlock or null if the object was deserialized.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Thread Thread { get; }

Property Value

Type: Thread
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockedThreadInfo Class
PostSharp.Patterns.Threading Namespace


DeadlockException Class

DeadlockException Class
Exception thrown by the DeadlockDetectionPolicy class when a deadlock is detected.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.Patterns.ThreadingThreadingException
PostSharp.Patterns.ThreadingDeadlockException

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class DeadlockException : ThreadingException

The DeadlockException type exposes the following members.

Constructors
 | Name | Description
Public method | DeadlockException | Initializes a new instance of see cref="DeadlockException"/>.
Public method | DeadlockException(String) | Initializes a new instance of see cref="DeadlockException"/>.
Public method | DeadlockException(DeadlockInfo) | Initializes a new instance of DeadlockException and specifies the message and involved threads.
Public method | DeadlockException(String, Exception) | Initializes a new instance of see cref="DeadlockException"/>.
Top
Methods
 | Name | Description
Public method | GetObjectData | When overridden in a derived class, sets the SerializationInfo with information about the exception. (Overrides ExceptionGetObjectData(SerializationInfo, StreamingContext).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | DeadlockInfo | Gets an information about the deadlock.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


DeadlockException Constructor

DeadlockException Constructor
Overload List
 | Name | Description
Public method | DeadlockException | Initializes a new instance of see cref="DeadlockException"/>.
Public method | DeadlockException(String) | Initializes a new instance of see cref="DeadlockException"/>.
Public method | DeadlockException(DeadlockInfo) | Initializes a new instance of DeadlockException and specifies the message and involved threads.
Public method | DeadlockException(String, Exception) | Initializes a new instance of see cref="DeadlockException"/>.
Top
See Also

Reference

DeadlockException Class
PostSharp.Patterns.Threading Namespace


DeadlockException Constructor

DeadlockException Constructor
Initializes a new instance of see cref="DeadlockException"/>.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeadlockException()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DeadlockException Class
DeadlockException Overload
PostSharp.Patterns.Threading Namespace


DeadlockException Constructor (String)

DeadlockException Constructor (String)
Initializes a new instance of see cref="DeadlockException"/>.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeadlockException(
    string message
)

Parameters

message
Type: SystemString
Exception message.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DeadlockException Class
DeadlockException Overload
PostSharp.Patterns.Threading Namespace


DeadlockException Constructor (DeadlockInfo)

DeadlockException Constructor (DeadlockInfo)
Initializes a new instance of DeadlockException and specifies the message and involved threads.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeadlockException(
    DeadlockInfo deadlockInfo
)

Parameters

deadlockInfo
Type: PostSharp.Patterns.ThreadingDeadlockInfo
Information about the deadlock.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockException Class
DeadlockException Overload
PostSharp.Patterns.Threading Namespace


DeadlockException Constructor (String, Exception)

DeadlockException Constructor (String, Exception)
Initializes a new instance of see cref="DeadlockException"/>.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeadlockException(
    string message,
    Exception innerException
)

Parameters

message
Type: SystemString
Exception message.
innerException
Type: SystemException
Inner exception.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DeadlockException Class
DeadlockException Overload
PostSharp.Patterns.Threading Namespace


DeadlockException Methods

DeadlockException Methods

The DeadlockException type exposes the following members.

Methods
 | Name | Description
Public method | GetObjectData | When overridden in a derived class, sets the SerializationInfo with information about the exception. (Overrides ExceptionGetObjectData(SerializationInfo, StreamingContext).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DeadlockException Class
PostSharp.Patterns.Threading Namespace


DeadlockException.GetObjectData Method

DeadlockExceptionGetObjectData Method
When overridden in a derived class, sets the SerializationInfo with information about the exception.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void GetObjectData(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
The SerializationInfo that holds the serialized object data about the exception being thrown.
context
Type: System.Runtime.SerializationStreamingContext
The StreamingContext that contains contextual information about the source or destination.

Implements

ISerializableGetObjectData(SerializationInfo, StreamingContext)
_ExceptionGetObjectData(SerializationInfo, StreamingContext)
Exceptions
Exception | Condition
ArgumentNullException | The info parameter is a null reference (Nothing in Visual Basic).
SecurityException | The caller does not have the required permission.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockException Class
PostSharp.Patterns.Threading Namespace


DeadlockException Properties

DeadlockException Properties

The DeadlockException type exposes the following members.

Properties
 | Name | Description
Public property | DeadlockInfo | Gets an information about the deadlock.
Top
See Also

Reference

DeadlockException Class
PostSharp.Patterns.Threading Namespace


DeadlockException.DeadlockInfo Property

DeadlockExceptionDeadlockInfo Property
Gets an information about the deadlock.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeadlockInfo DeadlockInfo { get; }

Property Value

Type: DeadlockInfo
Remarks
This property is not serialized and therefore can be potentially null.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockException Class
PostSharp.Patterns.Threading Namespace


DeadlockInfo Class

DeadlockInfo Class
Describes the detected deadlock.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingDeadlockInfo

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class DeadlockInfo

The DeadlockInfo type exposes the following members.

Constructors
 | Name | Description
Public method | DeadlockInfo | Initializes the object.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | DeadlockedThreads | Gets a collection of objects describing each thread in the deadlock.
Public property | Description | Gets textual description of the deadlock.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


DeadlockInfo Constructor

DeadlockInfo Constructor
Initializes the object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeadlockInfo(
    string description,
    IList<DeadlockedThreadInfo> deadlockedThreads
)

Parameters

description
Type: SystemString
Textual description of the detected deadlock.
deadlockedThreads
Type: System.Collections.GenericIList DeadlockedThreadInfo
List of objects describing each thread in the deadlock.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockInfo Class
PostSharp.Patterns.Threading Namespace


DeadlockInfo Methods

DeadlockInfo Methods

The DeadlockInfo type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DeadlockInfo Class
PostSharp.Patterns.Threading Namespace


DeadlockInfo Properties

DeadlockInfo Properties

The DeadlockInfo type exposes the following members.

Properties
 | Name | Description
Public property | DeadlockedThreads | Gets a collection of objects describing each thread in the deadlock.
Public property | Description | Gets textual description of the deadlock.
Top
See Also

Reference

DeadlockInfo Class
PostSharp.Patterns.Threading Namespace


DeadlockInfo.DeadlockedThreads Property

DeadlockInfoDeadlockedThreads Property
Gets a collection of objects describing each thread in the deadlock.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ReadOnlyCollection<DeadlockedThreadInfo> DeadlockedThreads { get; }

Property Value

Type: ReadOnlyCollection DeadlockedThreadInfo
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockInfo Class
PostSharp.Patterns.Threading Namespace


DeadlockInfo.Description Property

DeadlockInfoDescription Property
Gets textual description of the deadlock.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Description { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeadlockInfo Class
PostSharp.Patterns.Threading Namespace


DispatchedAttribute Class

DispatchedAttribute Class
Custom attribute that, when applied on a method, specifies that the method should be executed in UI thread.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsMethodLevelAspect
PostSharp.Patterns.ThreadingDispatchedAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class DispatchedAttribute : MethodLevelAspect,
    IAspectProvider, IAspect, IService

The DispatchedAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | DispatchedAttribute | Initializes a new DispatchedAttribute.
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides MethodLevelAspectCompileTimeValidate(MethodBase).)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | IsAsync | Determines whether the target method is invoked asynchronously or asynchronously.
Top
Remarks

Execution of the method can be synchronous or asynchronous according to the value of the IsAsync property.

This aspect can be applied to instance methods of UI controls (WinForms or WPF), or to any class implementing the IDispatcherObject manually.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


DispatchedAttribute Constructor

DispatchedAttribute Constructor
Initializes a new DispatchedAttribute.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DispatchedAttribute(
    bool isAsync = false
)

Parameters

isAsync (Optional)
Type: SystemBoolean
true if the target method must be invoked asynchronously, or false if the target method must be invoked synchronously, that is, if the caller must wait for the dispatched method to complete.
Remarks

Method that have a non-void return type or ref or out parameters cannot be dispatched asynchronously.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DispatchedAttribute Class
PostSharp.Patterns.Threading Namespace


DispatchedAttribute Methods

DispatchedAttribute Methods

The DispatchedAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides MethodLevelAspectCompileTimeValidate(MethodBase).)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from MethodLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DispatchedAttribute Class
PostSharp.Patterns.Threading Namespace


DispatchedAttribute.CompileTimeValidate Method

DispatchedAttributeCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from MethodLevelAspect.)
Public method | CompileTimeValidate(MethodBase) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides MethodLevelAspectCompileTimeValidate(MethodBase).)
Top
See Also

Reference

DispatchedAttribute Class
PostSharp.Patterns.Threading Namespace


DispatchedAttribute.CompileTimeValidate Method (MethodBase)

DispatchedAttributeCompileTimeValidate Method (MethodBase)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool CompileTimeValidate(
    MethodBase method
)

Parameters

method
Type: System.ReflectionMethodBase
Method to which the aspect has been applied

Return Value

Type: Boolean
true if the aspect was applied to an acceptable field, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DispatchedAttribute Class
CompileTimeValidate Overload
PostSharp.Patterns.Threading Namespace

Other Resources

Conceptual Documentation: Validating Aspects


DispatchedAttribute Properties

DispatchedAttribute Properties

The DispatchedAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | IsAsync | Determines whether the target method is invoked asynchronously or asynchronously.
Top
See Also

Reference

DispatchedAttribute Class
PostSharp.Patterns.Threading Namespace


DispatchedAttribute.IsAsync Property

DispatchedAttributeIsAsync Property
Determines whether the target method is invoked asynchronously or asynchronously.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsAsync { get; set; }

Property Value

Type: Boolean
true if the target method must be invoked asynchronously, or false if the target method must be invoked synchronously, that is, if the caller must wait for the dispatched method to complete.
Remarks

Method that have a non-void return type or ref or out parameters cannot be dispatched asynchronously.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DispatchedAttribute Class
PostSharp.Patterns.Threading Namespace


DispatcherFactory Class

DispatcherFactory Class
Provides implementations of the IDispatcher interface.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingDispatcherFactory

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class DispatcherFactory

The DispatcherFactory type exposes the following members.

Methods
Name | Description
GetDispatcherForCurrentContext | Gets an implementation of the IDispatcher interface that is suitable for dispatching to the current context. This method requires that the current thread is associated to a SynchronizationContext or a WPF Dispatcher.
GetDispatcherForSynchronizationContext | Gets an implementation of the IDispatcher interface for a given SynchronizationContext.
GetDispatcherForWindowsDispatcher | Gets an implementation of the IDispatcher interface for a given instance of the System.Windows.Threading.Dispatcher class.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


DispatcherFactory Methods

DispatcherFactory Methods

The DispatcherFactory type exposes the following members.

Methods
Name | Description
GetDispatcherForCurrentContext | Gets an implementation of the IDispatcher interface that is suitable for dispatching to the current context. This method requires that the current thread is associated to a SynchronizationContext or a WPF Dispatcher.
GetDispatcherForSynchronizationContext | Gets an implementation of the IDispatcher interface for a given SynchronizationContext.
GetDispatcherForWindowsDispatcher | Gets an implementation of the IDispatcher interface for a given instance of the System.Windows.Threading.Dispatcher class.
Top
See Also

Reference

DispatcherFactory Class
PostSharp.Patterns.Threading Namespace


DispatcherFactory.GetDispatcherForCurrentContext Method

DispatcherFactoryGetDispatcherForCurrentContext Method
Gets an implementation of the IDispatcher interface that is suitable for dispatching to the current context. This method requires that the current thread is associated to a SynchronizationContext or a WPF Dispatcher.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static IDispatcher GetDispatcherForCurrentContext()

Return Value

Type: IDispatcher
An implementation of the IDispatcher for the current context, or null if the current thread is not associated with any SynchronizationContext or a WPF Dispatcher.
Remarks

Subsequent calls to this method in the same context will return the same instance.

If this method is invoke in the contact of an actor (see ActorAttribute), this method will return a dispatcher that allows to dispatch to the actor queue.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

DispatcherFactory Class
PostSharp.Patterns.Threading Namespace


DispatcherFactory.GetDispatcherForSynchronizationContext Method

DispatcherFactoryGetDispatcherForSynchronizationContext Method
Gets an implementation of the IDispatcher interface for a given SynchronizationContext.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static IDispatcher GetDispatcherForSynchronizationContext(
    SynchronizationContext synchronizationContext
)

Parameters

synchronizationContext
Type: System.ThreadingSynchronizationContext
A SynchronizationContext.

Return Value

Type: IDispatcher
An implementation of IDispatcher that dispatches using synchronizationContext.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DispatcherFactory Class
PostSharp.Patterns.Threading Namespace


DispatcherFactory.GetDispatcherForWindowsDispatcher Method

DispatcherFactoryGetDispatcherForWindowsDispatcher Method
Gets an implementation of the IDispatcher interface for a given instance of the System.Windows.Threading.Dispatcher class.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static IDispatcher GetDispatcherForWindowsDispatcher(
    Object dispatcher
)

Parameters

dispatcher
Type: SystemObject
An instance of the System.Windows.Threading.Dispatcher class.

Return Value

Type: IDispatcher
An implementation of IDispatcher wrapping the functionality of dispatcher.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DispatcherFactory Class
PostSharp.Patterns.Threading Namespace


EntryPointAttribute Class

EntryPointAttribute Class
Custom attribute that, when applied to a private or protected instance method, causes all threading model aspects (derived from ThreadAwareAttribute to introduce runtime generation code.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingEntryPointAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class EntryPointAttribute : MulticastAttribute

The EntryPointAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | EntryPointAttribute | Initializes a new instance of the EntryPointAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


EntryPointAttribute Constructor

EntryPointAttribute Constructor
Initializes a new instance of the EntryPointAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public EntryPointAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

EntryPointAttribute Class
PostSharp.Patterns.Threading Namespace


EntryPointAttribute Methods

EntryPointAttribute Methods

The EntryPointAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

EntryPointAttribute Class
PostSharp.Patterns.Threading Namespace


EntryPointAttribute Properties

EntryPointAttribute Properties

The EntryPointAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

EntryPointAttribute Class
PostSharp.Patterns.Threading Namespace


ExplicitlySynchronizedAttribute Class

ExplicitlySynchronizedAttribute Class
Custom attribute that, when applied to a method or field, specifies that threading model aspects (derived from ThreadAwareAttribute) should ignore all verifications for this field or method.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingExplicitlySynchronizedAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ExplicitlySynchronizedAttribute : MulticastAttribute

The ExplicitlySynchronizedAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ExplicitlySynchronizedAttribute | Initializes a new instance of the ExplicitlySynchronizedAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Remarks

When the custom attribute is applied to a field, accesses to this field are never checked.

When the custom attribute is applied to a method, checking of accesses to all fields is disabled during the whole method execution, for the current thread.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ExplicitlySynchronizedAttribute Constructor

ExplicitlySynchronizedAttribute Constructor
Initializes a new instance of the ExplicitlySynchronizedAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ExplicitlySynchronizedAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ExplicitlySynchronizedAttribute Class
PostSharp.Patterns.Threading Namespace


ExplicitlySynchronizedAttribute Methods

ExplicitlySynchronizedAttribute Methods

The ExplicitlySynchronizedAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ExplicitlySynchronizedAttribute Class
PostSharp.Patterns.Threading Namespace


ExplicitlySynchronizedAttribute Properties

ExplicitlySynchronizedAttribute Properties

The ExplicitlySynchronizedAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

ExplicitlySynchronizedAttribute Class
PostSharp.Patterns.Threading Namespace


FreezableAttribute Class

FreezableAttribute Class
Custom attribute that, when applied to a class, implements the FreezableThreadingModel to this class. The aspect introduces the IFreezable interface into the target class. After the Freeze method has been invoked, the object can no longer be modified, and can therefore be safely shared between several threads.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
PostSharp.Patterns.ThreadingReadOnlyThreadAwareAttribute
PostSharp.Patterns.ThreadingFreezableAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class FreezableAttribute : ReadOnlyThreadAwareAttribute,
    IFreezable, IThreadAware

The FreezableAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | FreezableAttribute | Initializes a new instance of the FreezableAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Overrides InstanceLevelAspectOnCloned(ICloneAwareAspect).)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from ReadOnlyThreadAwareAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Overrides InstanceLevelAspectRuntimeInitializeInstance.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
Remarks

Accessing a freezable object from a different thread than the one that created before the Freeze method has been invoked it will result in a ThreadMismatchException.

Attempts to modify a freezable object after the Freeze method has been invoked will result in an ObjectReadOnlyException.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


FreezableAttribute Constructor

FreezableAttribute Constructor
Initializes a new instance of the FreezableAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public FreezableAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

FreezableAttribute Class
PostSharp.Patterns.Threading Namespace


FreezableAttribute Methods

FreezableAttribute Methods

The FreezableAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Overrides InstanceLevelAspectOnCloned(ICloneAwareAspect).)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from ReadOnlyThreadAwareAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Overrides InstanceLevelAspectRuntimeInitializeInstance.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

FreezableAttribute Class
PostSharp.Patterns.Threading Namespace


FreezableAttribute.OnCloned Method

FreezableAttributeOnCloned Method
Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void OnCloned(
    ICloneAwareAspect source
)

Parameters

source
Type: PostSharp.AspectsICloneAwareAspect
Aspect instance corresponding to the current aspect instance in the cloned target object.

Implements

ICloneAwareAspectOnCloned(ICloneAwareAspect)
Remarks

Prior to calling the current method, the aspect framework initializes the source object using CreateInstance(AdviceArgs) and RuntimeInitializeInstance. That is, the aspect instance in the cloned object is not cloned from the source aspect instance, but from the prototype aspect instance.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

FreezableAttribute Class
PostSharp.Patterns.Threading Namespace


FreezableAttribute.RuntimeInitializeInstance Method

FreezableAttributeRuntimeInitializeInstance Method
Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void RuntimeInitializeInstance()

Implements

IInstanceScopedAspectRuntimeInitializeInstance
Version Information

Supported in: 4.1, 4.0

See Also

Reference

FreezableAttribute Class
PostSharp.Patterns.Threading Namespace
PostSharp.Aspects.AdvicesInitializeAspectInstanceAdvice


FreezableAttribute Properties

FreezableAttribute Properties

The FreezableAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
See Also

Reference

FreezableAttribute Class
PostSharp.Patterns.Threading Namespace


IActor Interface

IActor Interface
Interface implemented by the ActorAttribute aspect.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IActor : IDispatcherObject, IThreadAware

The IActor type exposes the following members.

Methods
 | Name | Description
Public method | OnParentControllerChanged | Notifies the object that the effective controller of it's parent has changed. The new parent controller or null. (Inherited from IThreadAware.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Top
Properties
 | Name | Description
Public property | ConcurrencyController | Gets the concurrency controller for the current object. (Inherited from IThreadAware.)
Public property | Dispatcher | Gets the IActorDispatcher for the current actor.
Top
Remarks
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


IActor Methods

IActor Methods

The IActor type exposes the following members.

Methods
 | Name | Description
Public method | OnParentControllerChanged | Notifies the object that the effective controller of it's parent has changed. The new parent controller or null. (Inherited from IThreadAware.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Top
See Also

Reference

IActor Interface
PostSharp.Patterns.Threading Namespace


IActor Properties

IActor Properties

The IActor type exposes the following members.

Properties
 | Name | Description
Public property | ConcurrencyController | Gets the concurrency controller for the current object. (Inherited from IThreadAware.)
Public property | Dispatcher | Gets the IActorDispatcher for the current actor.
Top
See Also

Reference

IActor Interface
PostSharp.Patterns.Threading Namespace


IActor.Dispatcher Property

IActorDispatcher Property
Gets the IActorDispatcher for the current actor.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IActorDispatcher Dispatcher { get; }

Property Value

Type: IActorDispatcher
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IActor Interface
PostSharp.Patterns.Threading Namespace


IActorController Interface

IActorController Interface
Specific definition of the IConcurrencyController for the ActorThreadingModel.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IActorController : IConcurrencyController,
    IDispatcherObject

The IActorController type exposes the following members.

Methods
 | Name | Description
Public method | AcquireAccess | Acquires access on the entity for the current thread. (Inherited from IConcurrencyController.)
Public method | CheckAccess | Determines whether the current thread has a specified level of access to the entity. (Inherited from IConcurrencyController.)
Public method | RequireAccess | Determines whether the current thread has a specified level of access to the entity and throws an exception if not. (Inherited from IConcurrencyController.)
Top
Properties
 | Name | Description
Public property | Dispatcher | Gets the IActorDispatcher for the current actor.
Public property | IsReadOnly | Determines whether the entity is currently read-only. (Inherited from IConcurrencyController.)
Public property | IsSharable | Determines whether the entity can currently be accessed concurrently by several threads. (Inherited from IConcurrencyController.)
Public property | ThreadingModel | Gets the ThreadingModel implemented by the current controller. (Inherited from IConcurrencyController.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


IActorController Methods

IActorController Methods

The IActorController type exposes the following members.

Methods
 | Name | Description
Public method | AcquireAccess | Acquires access on the entity for the current thread. (Inherited from IConcurrencyController.)
Public method | CheckAccess | Determines whether the current thread has a specified level of access to the entity. (Inherited from IConcurrencyController.)
Public method | RequireAccess | Determines whether the current thread has a specified level of access to the entity and throws an exception if not. (Inherited from IConcurrencyController.)
Top
See Also

Reference

IActorController Interface
PostSharp.Patterns.Threading Namespace


IActorController Properties

IActorController Properties

The IActorController type exposes the following members.

Properties
 | Name | Description
Public property | Dispatcher | Gets the IActorDispatcher for the current actor.
Public property | IsReadOnly | Determines whether the entity is currently read-only. (Inherited from IConcurrencyController.)
Public property | IsSharable | Determines whether the entity can currently be accessed concurrently by several threads. (Inherited from IConcurrencyController.)
Public property | ThreadingModel | Gets the ThreadingModel implemented by the current controller. (Inherited from IConcurrencyController.)
Top
See Also

Reference

IActorController Interface
PostSharp.Patterns.Threading Namespace


IActorController.Dispatcher Property

IActorControllerDispatcher Property
Gets the IActorDispatcher for the current actor.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IActorDispatcher Dispatcher { get; }

Property Value

Type: IActorDispatcher
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IActorController Interface
PostSharp.Patterns.Threading Namespace


IActorDispatcher Interface

IActorDispatcher Interface
Augments the IDispatcher interface with an Initialize method, which is invoked after the actor constructor has been invoked.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IActorDispatcher : IDispatcher

The IActorDispatcher type exposes the following members.

Methods
 | Name | Description
Public method | BeginInvoke | Queues an action for asynchronous execution. (Inherited from IDispatcher.)
Public method | CheckAccess | Determines whether the current thread has access to the current dispatcher. (Inherited from IDispatcher.)
Public method | Initialize | Indicates that the controller should start enforcing access. Before this method is invoked, the CheckAccess method should always return true, allowing any access to the object. This mechanism allows the actor constructor to have full access on itself.
Public method | Invoke | Executes an action synchronously. (Inherited from IDispatcher.)
Top
Properties
 | Name | Description
Public property | IsInvokeSupported | Determines whether the Invoke(SendOrPostCallback, Object) method is supported. (Inherited from IDispatcher.)
Public property | SynchronizationContext | Gets the SynchronizationContext associated with the current dispatcher. (Inherited from IDispatcher.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


IActorDispatcher Methods

IActorDispatcher Methods

The IActorDispatcher type exposes the following members.

Methods
 | Name | Description
Public method | BeginInvoke | Queues an action for asynchronous execution. (Inherited from IDispatcher.)
Public method | CheckAccess | Determines whether the current thread has access to the current dispatcher. (Inherited from IDispatcher.)
Public method | Initialize | Indicates that the controller should start enforcing access. Before this method is invoked, the CheckAccess method should always return true, allowing any access to the object. This mechanism allows the actor constructor to have full access on itself.
Public method | Invoke | Executes an action synchronously. (Inherited from IDispatcher.)
Top
See Also

Reference

IActorDispatcher Interface
PostSharp.Patterns.Threading Namespace


IActorDispatcher.Initialize Method

IActorDispatcherInitialize Method
Indicates that the controller should start enforcing access. Before this method is invoked, the CheckAccess method should always return true, allowing any access to the object. This mechanism allows the actor constructor to have full access on itself.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void Initialize()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IActorDispatcher Interface
PostSharp.Patterns.Threading Namespace


IActorDispatcher Properties

IActorDispatcher Properties

The IActorDispatcher type exposes the following members.

Properties
 | Name | Description
Public property | IsInvokeSupported | Determines whether the Invoke(SendOrPostCallback, Object) method is supported. (Inherited from IDispatcher.)
Public property | SynchronizationContext | Gets the SynchronizationContext associated with the current dispatcher. (Inherited from IDispatcher.)
Top
See Also

Reference

IActorDispatcher Interface
PostSharp.Patterns.Threading Namespace


IConcurrencyController Interface

IConcurrencyController Interface
Controls access to an entity from possibly several threads.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IConcurrencyController

The IConcurrencyController type exposes the following members.

Methods
 | Name | Description
Public method | AcquireAccess | Acquires access on the entity for the current thread.
Public method | CheckAccess | Determines whether the current thread has a specified level of access to the entity.
Public method | RequireAccess | Determines whether the current thread has a specified level of access to the entity and throws an exception if not.
Top
Properties
 | Name | Description
Public property | IsReadOnly | Determines whether the entity is currently read-only.
Public property | IsSharable | Determines whether the entity can currently be accessed concurrently by several threads.
Public property | ThreadingModel | Gets the ThreadingModel implemented by the current controller.
Top
Remarks

An entity, for the sake of this documentation article, is a group of objects that share the same concurrency controller.

Objects that are controlled by a concurrency controller implement the IThreadAware interface.

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


IConcurrencyController Methods

IConcurrencyController Methods

The IConcurrencyController type exposes the following members.

Methods
 | Name | Description
Public method | AcquireAccess | Acquires access on the entity for the current thread.
Public method | CheckAccess | Determines whether the current thread has a specified level of access to the entity.
Public method | RequireAccess | Determines whether the current thread has a specified level of access to the entity and throws an exception if not.
Top
See Also

Reference

IConcurrencyController Interface
PostSharp.Patterns.Threading Namespace


IConcurrencyController.AcquireAccess Method

IConcurrencyControllerAcquireAccess Method
Acquires access on the entity for the current thread.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void AcquireAccess(
    ObjectAccessLevel objectAccessLevel,
    ref ConcurrentAccessToken concurrencyAccessToken
)

Parameters

objectAccessLevel
Type: PostSharp.Patterns.ModelObjectAccessLevel
The required access level on the entity.
concurrencyAccessToken
Type: PostSharp.Patterns.ThreadingConcurrentAccessToken

Return Value

Type:
An opaque ConcurrentAccessToken, typically used in a using block. Consumers must invoke the Complete method upon success before exiting the using block.
Version Information

Supported in: 4.1

See Also

Reference

IConcurrencyController Interface
PostSharp.Patterns.Threading Namespace


IConcurrencyController.CheckAccess Method

IConcurrencyControllerCheckAccess Method
Determines whether the current thread has a specified level of access to the entity.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool CheckAccess(
    ObjectAccessLevel objectAccessLevel
)

Parameters

objectAccessLevel
Type: PostSharp.Patterns.ModelObjectAccessLevel
The required access level on the entity.

Return Value

Type: Boolean
true if the current thread has the required level of access, otherwise false.
Version Information

Supported in: 4.1

See Also

Reference

IConcurrencyController Interface
PostSharp.Patterns.Threading Namespace


IConcurrencyController.RequireAccess Method

IConcurrencyControllerRequireAccess Method
Determines whether the current thread has a specified level of access to the entity and throws an exception if not.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void RequireAccess(
    ObjectAccessLevel objectAccessLevel
)

Parameters

objectAccessLevel
Type: PostSharp.Patterns.ModelObjectAccessLevel
The required access level on the entity.
Version Information

Supported in: 4.1

See Also

Reference

IConcurrencyController Interface
PostSharp.Patterns.Threading Namespace


IConcurrencyController Properties

IConcurrencyController Properties

The IConcurrencyController type exposes the following members.

Properties
 | Name | Description
Public property | IsReadOnly | Determines whether the entity is currently read-only.
Public property | IsSharable | Determines whether the entity can currently be accessed concurrently by several threads.
Public property | ThreadingModel | Gets the ThreadingModel implemented by the current controller.
Top
See Also

Reference

IConcurrencyController Interface
PostSharp.Patterns.Threading Namespace


IConcurrencyController.IsReadOnly Property

IConcurrencyControllerIsReadOnly Property
Determines whether the entity is currently read-only.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsReadOnly { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

IConcurrencyController Interface
PostSharp.Patterns.Threading Namespace


IConcurrencyController.IsSharable Property

IConcurrencyControllerIsSharable Property
Determines whether the entity can currently be accessed concurrently by several threads.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsSharable { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

IConcurrencyController Interface
PostSharp.Patterns.Threading Namespace


IConcurrencyController.ThreadingModel Property

IConcurrencyControllerThreadingModel Property
Gets the ThreadingModel implemented by the current controller.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ThreadingModel ThreadingModel { get; }

Property Value

Type: ThreadingModel
Version Information

Supported in: 4.1

See Also

Reference

IConcurrencyController Interface
PostSharp.Patterns.Threading Namespace


IDispatcher Interface

IDispatcher Interface
Defines the semantics of a facility that executes actions synchronously or asynchronously, possibly on a different thread.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IDispatcher

The IDispatcher type exposes the following members.

Methods
 | Name | Description
Public method | BeginInvoke | Queues an action for asynchronous execution.
Public method | CheckAccess | Determines whether the current thread has access to the current dispatcher.
Public method | Invoke | Executes an action synchronously.
Top
Properties
 | Name | Description
Public property | IsInvokeSupported | Determines whether the Invoke(SendOrPostCallback, Object) method is supported.
Public property | SynchronizationContext | Gets the SynchronizationContext associated with the current dispatcher.
Top
Remarks

Use the DispatcherFactory class to get implementations of this interface. You can also create a custom implementation.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace
PostSharp.Patterns.ThreadingIDispatcherObject
PostSharp.Patterns.ThreadingDispatcherFactory


IDispatcher Methods

IDispatcher Methods

The IDispatcher type exposes the following members.

Methods
 | Name | Description
Public method | BeginInvoke | Queues an action for asynchronous execution.
Public method | CheckAccess | Determines whether the current thread has access to the current dispatcher.
Public method | Invoke | Executes an action synchronously.
Top
See Also

Reference

IDispatcher Interface
PostSharp.Patterns.Threading Namespace


IDispatcher.BeginInvoke Method

IDispatcherBeginInvoke Method
Queues an action for asynchronous execution.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void BeginInvoke(
    SendOrPostCallback action,
    Object state
)

Parameters

action
Type: System.ThreadingSendOrPostCallback
Action to be executed.
state
Type: SystemObject
Parameter passed to action
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IDispatcher Interface
PostSharp.Patterns.Threading Namespace


IDispatcher.CheckAccess Method

IDispatcherCheckAccess Method
Determines whether the current thread has access to the current dispatcher.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool CheckAccess()

Return Value

Type: Boolean
true if the current thread can directly call methods of objects protected by the current dispatcher, or false if methods Invoke(SendOrPostCallback, Object) or BeginInvoke(SendOrPostCallback, Object) must be used.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IDispatcher Interface
PostSharp.Patterns.Threading Namespace


IDispatcher.Invoke Method

IDispatcherInvoke Method
Executes an action synchronously.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void Invoke(
    SendOrPostCallback action,
    Object state
)

Parameters

action
Type: System.ThreadingSendOrPostCallback
Action to be executed.
state
Type: SystemObject
Parameter passed to action.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IDispatcher Interface
PostSharp.Patterns.Threading Namespace


IDispatcher Properties

IDispatcher Properties

The IDispatcher type exposes the following members.

Properties
 | Name | Description
Public property | IsInvokeSupported | Determines whether the Invoke(SendOrPostCallback, Object) method is supported.
Public property | SynchronizationContext | Gets the SynchronizationContext associated with the current dispatcher.
Top
See Also

Reference

IDispatcher Interface
PostSharp.Patterns.Threading Namespace


IDispatcher.IsInvokeSupported Property

IDispatcherIsInvokeSupported Property
Determines whether the Invoke(SendOrPostCallback, Object) method is supported.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsInvokeSupported { get; }

Property Value

Type: Boolean
Remarks
If false, the dispatcher only supports asynchronous invocation (BeginInvoke(SendOrPostCallback, Object)).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IDispatcher Interface
PostSharp.Patterns.Threading Namespace


IDispatcher.SynchronizationContext Property

IDispatcherSynchronizationContext Property
Gets the SynchronizationContext associated with the current dispatcher.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
SynchronizationContext SynchronizationContext { get; }

Property Value

Type: SynchronizationContext
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IDispatcher Interface
PostSharp.Patterns.Threading Namespace


IDispatcherObject Interface

IDispatcherObject Interface
Interface implemented by objects that are whose access to methods is being controlled by a Dispatcher.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IDispatcherObject

The IDispatcherObject type exposes the following members.

Properties
 | Name | Description
Public property | Dispatcher | Gets the IDispatcher that controls access to methods of the current object.
Top
Remarks

If you need to implement the IDispatcherObject interface in a class, consider using the DispatcherFactory class to get an implementation of the IDispatcher interface in your instance constructor.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace
PostSharp.Patterns.ThreadingDispatcherFactory


IDispatcherObject Properties

IDispatcherObject Properties

The IDispatcherObject type exposes the following members.

Properties
 | Name | Description
Public property | Dispatcher | Gets the IDispatcher that controls access to methods of the current object.
Top
See Also

Reference

IDispatcherObject Interface
PostSharp.Patterns.Threading Namespace


IDispatcherObject.Dispatcher Property

IDispatcherObjectDispatcher Property
Gets the IDispatcher that controls access to methods of the current object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IDispatcher Dispatcher { get; }

Property Value

Type: IDispatcher
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IDispatcherObject Interface
PostSharp.Patterns.Threading Namespace


IFreezable Interface

IFreezable Interface
Interface implemented by the FreezableAttribute aspect. Defines a Freeze method.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IFreezable : IThreadAware

The IFreezable type exposes the following members.

Methods
 | Name | Description
Public method | Freeze | Prevents the current object to be modified.
Public method | OnParentControllerChanged | Notifies the object that the effective controller of it's parent has changed. The new parent controller or null. (Inherited from IThreadAware.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Top
Properties
 | Name | Description
Public property | ConcurrencyController | Gets the concurrency controller for the current object. (Inherited from IThreadAware.)
Top
Remarks

To determine whether the object has been frozen, use the IsReadOnly property of the ConcurrencyController of this object.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


IFreezable Methods

IFreezable Methods

The IFreezable type exposes the following members.

Methods
 | Name | Description
Public method | Freeze | Prevents the current object to be modified.
Public method | OnParentControllerChanged | Notifies the object that the effective controller of it's parent has changed. The new parent controller or null. (Inherited from IThreadAware.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Top
See Also

Reference

IFreezable Interface
PostSharp.Patterns.Threading Namespace


IFreezable.Freeze Method

IFreezableFreeze Method
Prevents the current object to be modified.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void Freeze()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

IFreezable Interface
PostSharp.Patterns.Threading Namespace


IFreezable Properties

IFreezable Properties

The IFreezable type exposes the following members.

Properties
 | Name | Description
Public property | ConcurrencyController | Gets the concurrency controller for the current object. (Inherited from IThreadAware.)
Top
See Also

Reference

IFreezable Interface
PostSharp.Patterns.Threading Namespace


IImmutable Interface

IImmutable Interface
Interface implemented by the ImmutableAttribute aspect.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IImmutable : IThreadAware

The IImmutable type exposes the following members.

Methods
 | Name | Description
Public method | OnParentControllerChanged | Notifies the object that the effective controller of it's parent has changed. The new parent controller or null. (Inherited from IThreadAware.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Top
Properties
 | Name | Description
Public property | ConcurrencyController | Gets the concurrency controller for the current object. (Inherited from IThreadAware.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


IImmutable Methods

IImmutable Methods

The IImmutable type exposes the following members.

Methods
 | Name | Description
Public method | OnParentControllerChanged | Notifies the object that the effective controller of it's parent has changed. The new parent controller or null. (Inherited from IThreadAware.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Top
See Also

Reference

IImmutable Interface
PostSharp.Patterns.Threading Namespace


IImmutable Properties

IImmutable Properties

The IImmutable type exposes the following members.

Properties
 | Name | Description
Public property | ConcurrencyController | Gets the concurrency controller for the current object. (Inherited from IThreadAware.)
Top
See Also

Reference

IImmutable Interface
PostSharp.Patterns.Threading Namespace


ImmutableAttribute Class

ImmutableAttribute Class
Custom attribute that, when applied to a class, implements the ImmutableThreadingModel to this class. The aspect introduces the IImmutable interface into the target class. Immutable objects cannot be modified after the constructor exits.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
PostSharp.Patterns.ThreadingReadOnlyThreadAwareAttribute
PostSharp.Patterns.ThreadingImmutableAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ImmutableAttribute : ReadOnlyThreadAwareAttribute,
    IImmutable, IThreadAware

The ImmutableAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ImmutableAttribute | Initializes a new instance of the ImmutableAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Overrides ReadOnlyThreadAwareAttributeOnInstanceConstructed.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ImmutableAttribute Constructor

ImmutableAttribute Constructor
Initializes a new instance of the ImmutableAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ImmutableAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImmutableAttribute Class
PostSharp.Patterns.Threading Namespace


ImmutableAttribute Methods

ImmutableAttribute Methods

The ImmutableAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Overrides ReadOnlyThreadAwareAttributeOnInstanceConstructed.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ImmutableAttribute Class
PostSharp.Patterns.Threading Namespace


ImmutableAttribute.OnInstanceConstructed Method

ImmutableAttributeOnInstanceConstructed Method
Executed when the target instance gets fully initialized, i.e. just after all constructors have completed.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void OnInstanceConstructed()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ImmutableAttribute Class
PostSharp.Patterns.Threading Namespace


ImmutableAttribute Properties

ImmutableAttribute Properties

The ImmutableAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
See Also

Reference

ImmutableAttribute Class
PostSharp.Patterns.Threading Namespace


IThreadAware Interface

IThreadAware Interface
Interface implemented by objects that are aware of concurrency. Access to thread-aware objects is controlled by a concurrency controller (IConcurrencyController). Any aspect implementing a threading model (ThreadAwareObjectAttribute) introduces this interface to the target class and ensures that accesses to this class go through the controller.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IThreadAware

The IThreadAware type exposes the following members.

Methods
 | Name | Description
Public method | OnParentControllerChanged | Notifies the object that the effective controller of it's parent has changed. The new parent controller or null.
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Top
Properties
 | Name | Description
Public property | ConcurrencyController | Gets the concurrency controller for the current object.
Top
Remarks

Thread-aware does not thread-safe. Check the IsSharable property of ConcurrencyController to check if the current object can be shared between different threads.

Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


IThreadAware Methods

IThreadAware Methods

The IThreadAware type exposes the following members.

Methods
 | Name | Description
Public method | OnParentControllerChanged | Notifies the object that the effective controller of it's parent has changed. The new parent controller or null.
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Top
See Also

Reference

IThreadAware Interface
PostSharp.Patterns.Threading Namespace


IThreadAware.OnParentControllerChanged Method

IThreadAwareOnParentControllerChanged Method
Notifies the object that the effective controller of it's parent has changed. The new parent controller or null.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnParentControllerChanged(
    IConcurrencyController parentController
)

Parameters

parentController
Type: PostSharp.Patterns.ThreadingIConcurrencyController
Version Information

Supported in: 4.1

See Also

Reference

IThreadAware Interface
PostSharp.Patterns.Threading Namespace


IThreadAware Properties

IThreadAware Properties

The IThreadAware type exposes the following members.

Properties
 | Name | Description
Public property | ConcurrencyController | Gets the concurrency controller for the current object.
Top
See Also

Reference

IThreadAware Interface
PostSharp.Patterns.Threading Namespace


IThreadAware.ConcurrencyController Property

IThreadAwareConcurrencyController Property
Gets the concurrency controller for the current object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IConcurrencyController ConcurrencyController { get; }

Property Value

Type: IConcurrencyController
Version Information

Supported in: 4.1

See Also

Reference

IThreadAware Interface
PostSharp.Patterns.Threading Namespace


ObjectReadOnlyException Class

ObjectReadOnlyException Class
Exception thrown by objects that have the FreezableThreadingModel or ImmutableThreadingModel when an attempt is made to modify the object after it has been made read-only.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.Patterns.ThreadingObjectReadOnlyException

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class ObjectReadOnlyException : Exception

The ObjectReadOnlyException type exposes the following members.

Constructors
 | Name | Description
Public method | ObjectReadOnlyException | Initializes a new instance of the ObjectReadOnlyException class with the default error message.
Public method | ObjectReadOnlyException(String) | Initializes a new instance of the ObjectReadOnlyException class with a given error message.
Public method | ObjectReadOnlyException(String, Exception) | Initializes a new instance of the ObjectReadOnlyException class with a given error message and inner exception.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ObjectReadOnlyException Constructor

ObjectReadOnlyException Constructor
Overload List
 | Name | Description
Public method | ObjectReadOnlyException | Initializes a new instance of the ObjectReadOnlyException class with the default error message.
Public method | ObjectReadOnlyException(String) | Initializes a new instance of the ObjectReadOnlyException class with a given error message.
Public method | ObjectReadOnlyException(String, Exception) | Initializes a new instance of the ObjectReadOnlyException class with a given error message and inner exception.
Top
See Also

Reference

ObjectReadOnlyException Class
PostSharp.Patterns.Threading Namespace


ObjectReadOnlyException Constructor

ObjectReadOnlyException Constructor
Initializes a new instance of the ObjectReadOnlyException class with the default error message.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectReadOnlyException()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ObjectReadOnlyException Class
ObjectReadOnlyException Overload
PostSharp.Patterns.Threading Namespace


ObjectReadOnlyException Constructor (String)

ObjectReadOnlyException Constructor (String)
Initializes a new instance of the ObjectReadOnlyException class with a given error message.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectReadOnlyException(
    string message
)

Parameters

message
Type: SystemString
The error message.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ObjectReadOnlyException Class
ObjectReadOnlyException Overload
PostSharp.Patterns.Threading Namespace


ObjectReadOnlyException Constructor (String, Exception)

ObjectReadOnlyException Constructor (String, Exception)
Initializes a new instance of the ObjectReadOnlyException class with a given error message and inner exception.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectReadOnlyException(
    string message,
    Exception inner
)

Parameters

message
Type: SystemString
The inner message.
inner
Type: SystemException
The exception wrapped by the new ObjectReadOnlyException.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ObjectReadOnlyException Class
ObjectReadOnlyException Overload
PostSharp.Patterns.Threading Namespace


ObjectReadOnlyException Methods

ObjectReadOnlyException Methods

The ObjectReadOnlyException type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ObjectReadOnlyException Class
PostSharp.Patterns.Threading Namespace


PrivateThreadAwareAttribute Class

PrivateThreadAwareAttribute Class
Custom attribute that, when applied to a class, implement the PrivateThreadingModel into this class, in which the threading model of an object is determined by the parent it is assigned to in a parent-child relationship.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
PostSharp.Patterns.ThreadingPrivateThreadAwareAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class PrivateThreadAwareAttribute : ThreadAwareAttribute

The PrivateThreadAwareAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | PrivateThreadAwareAttribute | Initializes a new instance of the PrivateThreadAwareAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


PrivateThreadAwareAttribute Constructor

PrivateThreadAwareAttribute Constructor
Initializes a new instance of the PrivateThreadAwareAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PrivateThreadAwareAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PrivateThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


PrivateThreadAwareAttribute Methods

PrivateThreadAwareAttribute Methods

The PrivateThreadAwareAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PrivateThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


PrivateThreadAwareAttribute Properties

PrivateThreadAwareAttribute Properties

The PrivateThreadAwareAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
See Also

Reference

PrivateThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ReaderAttribute Class

ReaderAttribute Class
Custom attribute that, when applied on a method, specifies that the method requires read access to the object.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingReaderWriterLockAttribute
PostSharp.Patterns.ThreadingReaderAttribute
PostSharp.Patterns.ThreadingReaderLockAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class ReaderAttribute : ReaderWriterLockAttribute

The ReaderAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ReaderAttribute | Initializes a new instance of the ReaderAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace
PostSharp.Patterns.ThreadingWriterAttribute
PostSharp.Patterns.ThreadingUpgradeableReaderAttribute
PostSharp.Patterns.ThreadingYielderAttribute


ReaderAttribute Constructor

ReaderAttribute Constructor
Initializes a new instance of the ReaderAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ReaderAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReaderAttribute Class
PostSharp.Patterns.Threading Namespace


ReaderAttribute Methods

ReaderAttribute Methods

The ReaderAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReaderAttribute Class
PostSharp.Patterns.Threading Namespace


ReaderAttribute Properties

ReaderAttribute Properties

The ReaderAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

ReaderAttribute Class
PostSharp.Patterns.Threading Namespace


ReaderWriterSynchronizedAttribute Class

ReaderWriterSynchronizedAttribute Class
Custom attribute that, when applied on a class, applies the ReaderWriterSynchronizedThreadingModel model to this class and all derived class. Members of this class must then be annotated with attributes specifying the required access level (ReaderAttribute, WriterAttribute, YielderAttribute or UpgradeableReaderAttribute), otherwise build-time and run-time errors are emitted.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
PostSharp.Patterns.ThreadingReaderWriterSynchronizedAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ReaderWriterSynchronizedAttribute : ThreadAwareAttribute

The ReaderWriterSynchronizedAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ReaderWriterSynchronizedAttribute | Initializes a new instance of the ReaderWriterSynchronizedAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ReaderWriterSynchronizedAttribute Constructor

ReaderWriterSynchronizedAttribute Constructor
Initializes a new instance of the ReaderWriterSynchronizedAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ReaderWriterSynchronizedAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReaderWriterSynchronizedAttribute Class
PostSharp.Patterns.Threading Namespace


ReaderWriterSynchronizedAttribute Methods

ReaderWriterSynchronizedAttribute Methods

The ReaderWriterSynchronizedAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReaderWriterSynchronizedAttribute Class
PostSharp.Patterns.Threading Namespace


ReaderWriterSynchronizedAttribute Properties

ReaderWriterSynchronizedAttribute Properties

The ReaderWriterSynchronizedAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
See Also

Reference

ReaderWriterSynchronizedAttribute Class
PostSharp.Patterns.Threading Namespace


ReadOnlyThreadAwareAttribute Class

ReadOnlyThreadAwareAttribute Class
Base class for aspects FreezableAttribute and ImmutableAttribute.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
PostSharp.Patterns.ThreadingReadOnlyThreadAwareAttribute
PostSharp.Patterns.ThreadingFreezableAttribute
PostSharp.Patterns.ThreadingImmutableAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class ReadOnlyThreadAwareAttribute : ThreadAwareAttribute,
    IConcurrencyController

The ReadOnlyThreadAwareAttribute type exposes the following members.

Constructors
 | Name | Description
Protected method | ReadOnlyThreadAwareAttribute | Initializes a new instance of the ReadOnlyThreadAwareAttribute class
Top
Methods
 | Name | Description
Protected method | Advise | Injects the advice into the child object. (Overrides ThreadAwareAttributeAdvise(Object).)
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from InstanceLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | IsEligibleChild | Determines if an object is eligible to be a child of the target instance of the current aspect. (Inherited from ThreadAwareAttribute.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Overrides AggregatableClientAttributeOnInstanceConstructed.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Protected method | ProvideAspects | (Inherited from AggregatableClientAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Protected property | AppliedToCurrentType | Determines if the current custom attribute instance has been applied to the type of the target instance. This value is false if the custom attribute has been applied to a base type. (Inherited from AggregatableClientAttribute.)
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Protected property | IsInitialized | Determines whether the target instance is fully initialized, i.e. if all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ReadOnlyThreadAwareAttribute Constructor

ReadOnlyThreadAwareAttribute Constructor
Initializes a new instance of the ReadOnlyThreadAwareAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected ReadOnlyThreadAwareAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReadOnlyThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ReadOnlyThreadAwareAttribute Methods

ReadOnlyThreadAwareAttribute Methods

The ReadOnlyThreadAwareAttribute type exposes the following members.

Methods
 | Name | Description
Protected method | Advise | Injects the advice into the child object. (Overrides ThreadAwareAttributeAdvise(Object).)
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from InstanceLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | IsEligibleChild | Determines if an object is eligible to be a child of the target instance of the current aspect. (Inherited from ThreadAwareAttribute.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Overrides AggregatableClientAttributeOnInstanceConstructed.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Protected method | ProvideAspects | (Inherited from AggregatableClientAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReadOnlyThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ReadOnlyThreadAwareAttribute.Advise Method

ReadOnlyThreadAwareAttributeAdvise Method
Injects the advice into the child object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override bool Advise(
    Object obj
)

Parameters

obj
Type: SystemObject

Return Value

Type: Boolean
true if the children of obj have to be advised as well, false otherwise.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReadOnlyThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ReadOnlyThreadAwareAttribute.OnInstanceConstructed Method

ReadOnlyThreadAwareAttributeOnInstanceConstructed Method
Executed when the target instance gets fully initialized, i.e. just after all constructors have completed.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void OnInstanceConstructed()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReadOnlyThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ReadOnlyThreadAwareAttribute Properties

ReadOnlyThreadAwareAttribute Properties

The ReadOnlyThreadAwareAttribute type exposes the following members.

Properties
 | Name | Description
Protected property | AppliedToCurrentType | Determines if the current custom attribute instance has been applied to the type of the target instance. This value is false if the custom attribute has been applied to a base type. (Inherited from AggregatableClientAttribute.)
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Protected property | IsInitialized | Determines whether the target instance is fully initialized, i.e. if all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

ReadOnlyThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ReentrantAttribute Class

ReentrantAttribute Class
Custom attribute that means that the async method to which it is applied can be safely re-entered on each await statement. In case of lock-based models, it means that the lock is released while awaiting. For the actor model, it means that other methods can be invoked during awaiting.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingReentrantAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ReentrantAttribute : MulticastAttribute,
    IValidableAnnotation

The ReentrantAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ReentrantAttribute | Initializes a new instance of the ReentrantAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeValidate |
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ReentrantAttribute Constructor

ReentrantAttribute Constructor
Initializes a new instance of the ReentrantAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ReentrantAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReentrantAttribute Class
PostSharp.Patterns.Threading Namespace


ReentrantAttribute Methods

ReentrantAttribute Methods

The ReentrantAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate |
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReentrantAttribute Class
PostSharp.Patterns.Threading Namespace


ReentrantAttribute.CompileTimeValidate Method

ReentrantAttributeCompileTimeValidate Method

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject

Return Value

Type: Boolean

Implements

IValidableAnnotationCompileTimeValidate(Object)
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReentrantAttribute Class
PostSharp.Patterns.Threading Namespace


ReentrantAttribute Properties

ReentrantAttribute Properties

The ReentrantAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

ReentrantAttribute Class
PostSharp.Patterns.Threading Namespace


RequiresThreadSafeAttribute Class

RequiresThreadSafeAttribute Class
Custom attribute that, when applied to a field, property or parameter, checks that the assigned object is thread safe. Otherwise, the assignment results in an ArgumentException/
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsLocationLevelAspect
PostSharp.Patterns.ThreadingRequiresThreadSafeAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class RequiresThreadSafeAttribute : LocationLevelAspect,
    ILocationValidationAspect<Object>, ILocationValidationAspect, IAspect

The RequiresThreadSafeAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | RequiresThreadSafeAttribute | Initializes a new instance of the RequiresThreadSafeAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from LocationLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from LocationLevelAspect.)
Public method | CompileTimeValidate(LocationInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from LocationLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from LocationLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


RequiresThreadSafeAttribute Constructor

RequiresThreadSafeAttribute Constructor
Initializes a new instance of the RequiresThreadSafeAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public RequiresThreadSafeAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

RequiresThreadSafeAttribute Class
PostSharp.Patterns.Threading Namespace


RequiresThreadSafeAttribute Methods

RequiresThreadSafeAttribute Methods

The RequiresThreadSafeAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from LocationLevelAspect.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from LocationLevelAspect.)
Public method | CompileTimeValidate(LocationInfo) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from LocationLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from LocationLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

RequiresThreadSafeAttribute Class
PostSharp.Patterns.Threading Namespace


RequiresThreadSafeAttribute Properties

RequiresThreadSafeAttribute Properties

The RequiresThreadSafeAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

RequiresThreadSafeAttribute Class
PostSharp.Patterns.Threading Namespace


SynchronizedAttribute Class

SynchronizedAttribute Class
Custom attribute that, when applied to a class, implements the SynchronizedThreadingModel into this class. In a synchronized object, only a single thread can access the object at a time. If a second thread needs to access the object while it is in used by a first thread, the second thread has to wait until the first thread completes its access.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
PostSharp.Patterns.ThreadingSynchronizedAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class SynchronizedAttribute : ThreadAwareAttribute

The SynchronizedAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | SynchronizedAttribute | Initializes a new instance of the SynchronizedAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


SynchronizedAttribute Constructor

SynchronizedAttribute Constructor
Initializes a new instance of the SynchronizedAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SynchronizedAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SynchronizedAttribute Class
PostSharp.Patterns.Threading Namespace


SynchronizedAttribute Methods

SynchronizedAttribute Methods

The SynchronizedAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SynchronizedAttribute Class
PostSharp.Patterns.Threading Namespace


SynchronizedAttribute Properties

SynchronizedAttribute Properties

The SynchronizedAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
See Also

Reference

SynchronizedAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAccessException Class

ThreadAccessException Class
Exception thrown when the calling thread does not have access to the object.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.Patterns.ThreadingThreadingException
PostSharp.Patterns.ThreadingLockNotHeldException
PostSharp.Patterns.ThreadingThreadAccessException

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public class ThreadAccessException : LockNotHeldException

The ThreadAccessException type exposes the following members.

Constructors
 | Name | Description
Public method | ThreadAccessException | Initializes a new instance of the ThreadAccessException class with the default error message.
Public method | ThreadAccessException(String) | Initializes a new instance of the ThreadAccessException class with a given error message.
Protected method | ThreadAccessException(SerializationInfo, StreamingContext) | Deserialization constructor.
Public method | ThreadAccessException(String, Exception) | Initializes a new instance of the ThreadAccessException class with a given error message and inner exception.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks

This exception is raised when the calling thread accesses the object without going through a public method.

For the ReaderWriterSynchronizedThreadingModel, the exception may mean that a public method was not annotated with an access custom attribute (ReaderAttribute, WriterAttribute and others).

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadAccessException Constructor

ThreadAccessException Constructor
Overload List
 | Name | Description
Public method | ThreadAccessException | Initializes a new instance of the ThreadAccessException class with the default error message.
Public method | ThreadAccessException(String) | Initializes a new instance of the ThreadAccessException class with a given error message.
Protected method | ThreadAccessException(SerializationInfo, StreamingContext) | Deserialization constructor.
Public method | ThreadAccessException(String, Exception) | Initializes a new instance of the ThreadAccessException class with a given error message and inner exception.
Top
See Also

Reference

ThreadAccessException Class
PostSharp.Patterns.Threading Namespace


ThreadAccessException Constructor

ThreadAccessException Constructor
Initializes a new instance of the ThreadAccessException class with the default error message.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ThreadAccessException()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAccessException Class
ThreadAccessException Overload
PostSharp.Patterns.Threading Namespace


ThreadAccessException Constructor (String)

ThreadAccessException Constructor (String)
Initializes a new instance of the ThreadAccessException class with a given error message.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ThreadAccessException(
    string message
)

Parameters

message
Type: SystemString
The error message.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAccessException Class
ThreadAccessException Overload
PostSharp.Patterns.Threading Namespace


ThreadAccessException Constructor (SerializationInfo, StreamingContext)

ThreadAccessException Constructor (SerializationInfo, StreamingContext)
Deserialization constructor.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected ThreadAccessException(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
context
Type: System.Runtime.SerializationStreamingContext
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAccessException Class
ThreadAccessException Overload
PostSharp.Patterns.Threading Namespace


ThreadAccessException Constructor (String, Exception)

ThreadAccessException Constructor (String, Exception)
Initializes a new instance of the ThreadAccessException class with a given error message and inner exception.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ThreadAccessException(
    string message,
    Exception inner
)

Parameters

message
Type: SystemString
The error message.
inner
Type: SystemException
The Exception wrapped by the new ThreadAccessException.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAccessException Class
ThreadAccessException Overload
PostSharp.Patterns.Threading Namespace


ThreadAccessException Methods

ThreadAccessException Methods

The ThreadAccessException type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ThreadAccessException Class
PostSharp.Patterns.Threading Namespace


ThreadAffineAttribute Class

ThreadAffineAttribute Class
Custom attribute that, when applied on a type, ensures the instances of this type can only be accessed by the thread that created the instance. When a different thread accesses instances of this type, a ThreadMismatchException exception is thrown.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
PostSharp.Patterns.ThreadingThreadAffineAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ThreadAffineAttribute : ThreadAwareAttribute

The ThreadAffineAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ThreadAffineAttribute | Initializes a new instance of the ThreadAffineAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Overrides InstanceLevelAspectRuntimeInitializeInstance.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadAffineAttribute Constructor

ThreadAffineAttribute Constructor
Initializes a new instance of the ThreadAffineAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ThreadAffineAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAffineAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAffineAttribute Methods

ThreadAffineAttribute Methods

The ThreadAffineAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from ThreadAwareAttribute.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Overrides InstanceLevelAspectRuntimeInitializeInstance.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ThreadAffineAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAffineAttribute.RuntimeInitializeInstance Method

ThreadAffineAttributeRuntimeInitializeInstance Method
Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void RuntimeInitializeInstance()

Implements

IInstanceScopedAspectRuntimeInitializeInstance
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAffineAttribute Class
PostSharp.Patterns.Threading Namespace
PostSharp.Aspects.AdvicesInitializeAspectInstanceAdvice


ThreadAffineAttribute Properties

ThreadAffineAttribute Properties

The ThreadAffineAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
See Also

Reference

ThreadAffineAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAwareAttribute Class

ThreadAwareAttribute Class
Base class for all aspects implementing threading models.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
More...

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class ThreadAwareAttribute : AggregatableClientAttribute,
    IThreadAware

The ThreadAwareAttribute type exposes the following members.

Methods
 | Name | Description
Protected method | Advise | Injects the advice into the child object. (Overrides AggregatableClientAttributeAdvise(Object).)
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides TypeLevelAspectCompileTimeValidate(Type).)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from InstanceLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | IsEligibleChild | Determines if an object is eligible to be a child of the target instance of the current aspect. (Overrides AggregatableClientAttributeIsEligibleChild(Object, ChildInfo).)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class.
Protected method | ProvideAspects | (Inherited from AggregatableClientAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Protected property | AppliedToCurrentType | Determines if the current custom attribute instance has been applied to the type of the target instance. This value is false if the custom attribute has been applied to a base type. (Inherited from AggregatableClientAttribute.)
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Protected property | IsInitialized | Determines whether the target instance is fully initialized, i.e. if all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration.
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
PostSharp.Patterns.ThreadingActorAttribute
PostSharp.Patterns.ThreadingPrivateThreadAwareAttribute
PostSharp.Patterns.ThreadingReaderWriterSynchronizedAttribute
PostSharp.Patterns.ThreadingReadOnlyThreadAwareAttribute
PostSharp.Patterns.ThreadingSynchronizedAttribute
PostSharp.Patterns.ThreadingThreadAffineAttribute
PostSharp.Patterns.ThreadingThreadUnsafeAttribute


ThreadAwareAttribute Methods

ThreadAwareAttribute Methods

The ThreadAwareAttribute type exposes the following members.

Methods
 | Name | Description
Protected method | Advise | Injects the advice into the child object. (Overrides AggregatableClientAttributeAdvise(Object).)
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides TypeLevelAspectCompileTimeValidate(Type).)
Protected method | CreateAspectConfiguration | Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type. (Inherited from InstanceLevelAspect.)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Protected method | IsEligibleChild | Determines if an object is eligible to be a child of the target instance of the current aspect. (Overrides AggregatableClientAttributeIsEligibleChild(Object, ChildInfo).)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class.
Protected method | ProvideAspects | (Inherited from AggregatableClientAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Inherited from InstanceLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Object) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Protected method | SetAspectConfiguration(AspectConfiguration, Type) | Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect. (Inherited from TypeLevelAspect.)
Top
Extension Methods
 | Name | Description
Public Extension Method | AcquireAccess | Acquires access for a given object. (Defined by ThreadAwareExtensions.)
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAwareAttribute.Advise Method

ThreadAwareAttributeAdvise Method
Injects the advice into the child object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override bool Advise(
    Object obj
)

Parameters

obj
Type: SystemObject

Return Value

Type: Boolean
true if the children of obj have to be advised as well, false otherwise.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAwareAttribute.CompileTimeValidate Method

ThreadAwareAttributeCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides TypeLevelAspectCompileTimeValidate(Type).)
Top
See Also

Reference

ThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAwareAttribute.CompileTimeValidate Method (Type)

ThreadAwareAttributeCompileTimeValidate Method (Type)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool CompileTimeValidate(
    Type type
)

Parameters

type
Type: SystemType
Type to which the aspect has been applied

Return Value

Type: Boolean
true if the aspect was applied to an acceptable field, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAwareAttribute Class
CompileTimeValidate Overload
PostSharp.Patterns.Threading Namespace

Other Resources

Conceptual Documentation: Validating Aspects


ThreadAwareAttribute.IsEligibleChild Method

ThreadAwareAttributeIsEligibleChild Method
Determines if an object is eligible to be a child of the target instance of the current aspect.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected override sealed bool IsEligibleChild(
    Object child,
    ChildInfo childInfo
)

Parameters

child
Type: SystemObject
childInfo
Type: PostSharp.Patterns.ModelChildInfo

Return Value

Type: Boolean
true if child is eligible to be a child without injecting any advice, otherwise false. When this method returns false, the aspect will the invoke the Advise(Object) method.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAwareAttribute.OnSerializing Method

ThreadAwareAttributeOnSerializing Method
Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void OnSerializing(
    StreamingContext streamingContext
)

Parameters

streamingContext
Type: System.Runtime.SerializationStreamingContext
Streaming context.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAwareAttribute Properties

ThreadAwareAttribute Properties

The ThreadAwareAttribute type exposes the following members.

Properties
 | Name | Description
Protected property | AppliedToCurrentType | Determines if the current custom attribute instance has been applied to the type of the target instance. This value is false if the custom attribute has been applied to a base type. (Inherited from AggregatableClientAttribute.)
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Protected property | IsInitialized | Determines whether the target instance is fully initialized, i.e. if all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration.
Protected property | SerializerType | Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime. (Inherited from Aspect.)
Top
See Also

Reference

ThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAwareAttribute.RuntimeVerificationEnabled Property

ThreadAwareAttributeRuntimeVerificationEnabled Property
Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool RuntimeVerificationEnabled { get; set; }

Property Value

Type: Boolean
Remarks

This default value is false if the Optimize compiler setting is enabled, and true if this setting is disabled. The default value can also be modified by setting the PostSharpRuntimeVerificationEnabled MSBuild property, which can be edited from the PostSharp tab of project properties in Visual Studio.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAwareAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadAwareAttributeTargetClass Class

ThreadAwareAttributeTargetClass Class
Describes the members that are consumed by the ThreadAwareAttribute aspect. You can define one or many of these members in classes that are the target of ThreadAwareAttribute to customize the behavior of the ThreadAwareAttribute aspect.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ModelAggregatableAttributeTargetClass
PostSharp.Patterns.ThreadingThreadAwareAttributeTargetClass

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class ThreadAwareAttributeTargetClass : AggregatableAttributeTargetClass

The ThreadAwareAttributeTargetClass type exposes the following members.

Methods
 | Name | Description
Protected method | OnAncestorChanged | Method invoked when an ancestor of the current object has changed. Implement this method only if the target class of AggregatableAttribute implements the IAggregatable interface. For other use cases, subscribe to the AncestorChanged event. (Inherited from AggregatableAttributeTargetClass.)
Protected method | OnChildAttached | Method invoked when a child has been attached to the current object. (Inherited from AggregatableAttributeTargetClass.)
Protected method | OnChildDetached | Method invoked when a child has been detached from the current object. (Inherited from AggregatableAttributeTargetClass.)
Protected method | OnParentChanged | Method invoked when the Parent of the current object has been changed. (Inherited from AggregatableAttributeTargetClass.)
Protected method | UseParentConcurrencyController | Determines whether the current object is should use the controller of the parent object.
Public method | VisitChildren | Executes an action for all direct children of the current object. Implement this method in the target class of AggregatableAttribute if you want to provide children objects that are not managed by the AggregatableAttribute aspect. (Inherited from AggregatableAttributeTargetClass.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
Note Note
This class it for documentation purpose only, and should not be used in code.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadAwareAttributeTargetClass Methods

ThreadAwareAttributeTargetClass Methods

The ThreadAwareAttributeTargetClass type exposes the following members.

Methods
 | Name | Description
Protected method | OnAncestorChanged | Method invoked when an ancestor of the current object has changed. Implement this method only if the target class of AggregatableAttribute implements the IAggregatable interface. For other use cases, subscribe to the AncestorChanged event. (Inherited from AggregatableAttributeTargetClass.)
Protected method | OnChildAttached | Method invoked when a child has been attached to the current object. (Inherited from AggregatableAttributeTargetClass.)
Protected method | OnChildDetached | Method invoked when a child has been detached from the current object. (Inherited from AggregatableAttributeTargetClass.)
Protected method | OnParentChanged | Method invoked when the Parent of the current object has been changed. (Inherited from AggregatableAttributeTargetClass.)
Protected method | UseParentConcurrencyController | Determines whether the current object is should use the controller of the parent object.
Public method | VisitChildren | Executes an action for all direct children of the current object. Implement this method in the target class of AggregatableAttribute if you want to provide children objects that are not managed by the AggregatableAttribute aspect. (Inherited from AggregatableAttributeTargetClass.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ThreadAwareAttributeTargetClass Class
PostSharp.Patterns.Threading Namespace


ThreadAwareAttributeTargetClass.UseParentConcurrencyController Method

ThreadAwareAttributeTargetClassUseParentConcurrencyController Method
Determines whether the current object is should use the controller of the parent object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected bool UseParentConcurrencyController(
    Object parent
)

Parameters

parent
Type: SystemObject
The object to which the current object has been assigned as a child.

Return Value

Type: Boolean
true, if the current object will use the concurrency controller of parent, false, if it will its own concurrency controller.
Remarks

When this method is not implemented in the target class, the ThreadAwareAttribute aspect considers that its return value is always true.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadAwareAttributeTargetClass Class
PostSharp.Patterns.Threading Namespace


ThreadAwareExtensions Class

ThreadAwareExtensions Class
Provides extension methods to the IThreadAware interface.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadAwareExtensions

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class ThreadAwareExtensions

The ThreadAwareExtensions type exposes the following members.

Methods
Name | Description
AcquireAccess | Acquires access for a given object.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadAwareExtensions Methods

ThreadAwareExtensions Methods

The ThreadAwareExtensions type exposes the following members.

Methods
Name | Description
AcquireAccess | Acquires access for a given object.
Top
See Also

Reference

ThreadAwareExtensions Class
PostSharp.Patterns.Threading Namespace


ThreadAwareExtensions.AcquireAccess Method

ThreadAwareExtensionsAcquireAccess Method
Acquires access for a given object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static void AcquireAccess(
    this IThreadAware instance,
    ObjectAccessLevel objectAccessLevel,
    ref ConcurrentAccessToken concurrentAccessToken
)

Parameters

instance
Type: PostSharp.Patterns.ThreadingIThreadAware
The instance for which access is required.
objectAccessLevel
Type: PostSharp.Patterns.ModelObjectAccessLevel
The level of access required.
concurrentAccessToken
Type: PostSharp.Patterns.ThreadingConcurrentAccessToken
At output, a ConcurrentAccessToken that should be disposed when access is no longer required.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IThreadAware. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks

This method is guaranteed to acquire the controller of the instance object. Invoking the AcquireAccess(ObjectAccessLevel, ConcurrentAccessToken) method directly does not offer this guarantee, as the controller can be changed between the moment the ConcurrencyController property is retrieved and the moment the AcquireAccess(ObjectAccessLevel, ConcurrentAccessToken) is invoked.

Version Information

Supported in: 4.1

See Also

Reference

ThreadAwareExtensions Class
PostSharp.Patterns.Threading Namespace


ThreadingException Class

ThreadingException Class
Base class for exceptions thrown by the PostSharp.Patterns.Threading component.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.Patterns.ThreadingThreadingException
PostSharp.Patterns.ThreadingConcurrentAccessException
PostSharp.Patterns.ThreadingDeadlockException
PostSharp.Patterns.ThreadingLockNotHeldException
PostSharp.Patterns.ThreadingThreadMismatchException

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public abstract class ThreadingException : Exception
Version Information

Supported in: 4.1, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadingModel Class

ThreadingModel Class
Base class for all threading models. Defines properties that describe the characteristics of threading models. All classes derived from ThreadingModel are necessarily singletons.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
More...

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class ThreadingModel

The ThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Overrides ObjectToString.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe.
Top
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Threading Namespace
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
PostSharp.Patterns.Threading.ModelsActorThreadingModel
PostSharp.Patterns.Threading.ModelsPrivateThreadingModel
PostSharp.Patterns.Threading.ModelsReaderWriterSynchronizedThreadingModel
PostSharp.Patterns.Threading.ModelsReadOnlyThreadingModel
PostSharp.Patterns.Threading.ModelsSynchronizedThreadingModel
PostSharp.Patterns.Threading.ModelsThreadUnsafeThreadingModel


ThreadingModel Methods

ThreadingModel Methods

The ThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Overrides ObjectToString.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ThreadingModel Class
PostSharp.Patterns.Threading Namespace


ThreadingModel.ToString Method

ThreadingModelToString Method
Returns a string that represents the current object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override string ToString()

Return Value

Type: String
A string that represents the current object.
Version Information

Supported in: 4.1

See Also

Reference

ThreadingModel Class
PostSharp.Patterns.Threading Namespace


ThreadingModel Properties

ThreadingModel Properties

The ThreadingModel type exposes the following members.

Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe.
Top
See Also

Reference

ThreadingModel Class
PostSharp.Patterns.Threading Namespace


ThreadingModel.IsThreadSafe Property

ThreadingModelIsThreadSafe Property
Determines whether the threading model is possibly thread safe.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract bool IsThreadSafe { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1

See Also

Reference

ThreadingModel Class
PostSharp.Patterns.Threading Namespace


ThreadingPatternsAspectRoles Class

ThreadingPatternsAspectRoles Class
Enumerates the aspect roles (for use with AspectRoleDependencyAttribute) used by the PostSharp.Patterns.Threading component.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingPatternsAspectRoles

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class ThreadingPatternsAspectRoles

The ThreadingPatternsAspectRoles type exposes the following members.

Fields
Name | Description
ThreadingModel | Role of an aspect that provides a threading model.
Top
Version Information

Supported in: 4.1, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadingPatternsAspectRoles Fields

ThreadingPatternsAspectRoles Fields

The ThreadingPatternsAspectRoles type exposes the following members.

Fields
Name | Description
ThreadingModel | Role of an aspect that provides a threading model.
Top
See Also

Reference

ThreadingPatternsAspectRoles Class
PostSharp.Patterns.Threading Namespace


ThreadingPatternsAspectRoles.ThreadingModel Field

ThreadingPatternsAspectRolesThreadingModel Field
Role of an aspect that provides a threading model.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const string ThreadingModel

Field Value

Type: String
Version Information

Supported in: 4.1, 3.1

See Also

Reference

ThreadingPatternsAspectRoles Class
PostSharp.Patterns.Threading Namespace


ThreadingServices Class

ThreadingServices Class
Exposes methods to work with the PostSharp.Patterns.Threading namespace.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingServices

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class ThreadingServices

The ThreadingServices type exposes the following members.

Events
Name | Description
DeadlockDetected | Event raised by implementation of the DeadlockDetectionPolicy aspect.
UnhandledException | Event raised by the implementation of the ActorAttribute, DispatchedAttribute and BackgroundAttribute aspects when an unhandled exception is encountered.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadingServices Events

ThreadingServices Events

The ThreadingServices type exposes the following members.

Events
Name | Description
DeadlockDetected | Event raised by implementation of the DeadlockDetectionPolicy aspect.
UnhandledException | Event raised by the implementation of the ActorAttribute, DispatchedAttribute and BackgroundAttribute aspects when an unhandled exception is encountered.
Top
See Also

Reference

ThreadingServices Class
PostSharp.Patterns.Threading Namespace


ThreadingServices.DeadlockDetected Event

ThreadingServicesDeadlockDetected Event
Event raised by implementation of the DeadlockDetectionPolicy aspect.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static event EventHandler<DeadlockDetectedEventArgs> DeadlockDetected

Value

Type: SystemEventHandler DeadlockDetectedEventArgs
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadingServices Class
PostSharp.Patterns.Threading Namespace


ThreadingServices.UnhandledException Event

ThreadingServicesUnhandledException Event
Event raised by the implementation of the ActorAttribute, DispatchedAttribute and BackgroundAttribute aspects when an unhandled exception is encountered.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static event EventHandler<ThreadingUnhandledExceptionEventArgs> UnhandledException

Value

Type: SystemEventHandler ThreadingUnhandledExceptionEventArgs
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadingServices Class
PostSharp.Patterns.Threading Namespace


ThreadingUnhandledExceptionEventArgs Class

ThreadingUnhandledExceptionEventArgs Class
Arguments of the UnhandledException event.
Inheritance Hierarchy
SystemObject
SystemEventArgs
PostSharp.Patterns.ThreadingThreadingUnhandledExceptionEventArgs
PostSharp.Patterns.ThreadingActorExceptionEventArgs

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class ThreadingUnhandledExceptionEventArgs : EventArgs

The ThreadingUnhandledExceptionEventArgs type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Exception | Gets the exception.
Public property | IsHandled | Determines whether the exception has been handled. Clients of the UnhandledException event must set this property to true if they handle the exception. Otherwise, the exception will be rethrown.
Public property | Source | Gets the source component that caught the exception.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadingUnhandledExceptionEventArgs Methods

ThreadingUnhandledExceptionEventArgs Methods

The ThreadingUnhandledExceptionEventArgs type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ThreadingUnhandledExceptionEventArgs Class
PostSharp.Patterns.Threading Namespace


ThreadingUnhandledExceptionEventArgs Properties

ThreadingUnhandledExceptionEventArgs Properties

The ThreadingUnhandledExceptionEventArgs type exposes the following members.

Properties
 | Name | Description
Public property | Exception | Gets the exception.
Public property | IsHandled | Determines whether the exception has been handled. Clients of the UnhandledException event must set this property to true if they handle the exception. Otherwise, the exception will be rethrown.
Public property | Source | Gets the source component that caught the exception.
Top
See Also

Reference

ThreadingUnhandledExceptionEventArgs Class
PostSharp.Patterns.Threading Namespace


ThreadingUnhandledExceptionEventArgs.Exception Property

ThreadingUnhandledExceptionEventArgsException Property
Gets the exception.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Exception Exception { get; }

Property Value

Type: Exception
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadingUnhandledExceptionEventArgs Class
PostSharp.Patterns.Threading Namespace


ThreadingUnhandledExceptionEventArgs.IsHandled Property

ThreadingUnhandledExceptionEventArgsIsHandled Property
Determines whether the exception has been handled. Clients of the UnhandledException event must set this property to true if they handle the exception. Otherwise, the exception will be rethrown.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsHandled { get; set; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadingUnhandledExceptionEventArgs Class
PostSharp.Patterns.Threading Namespace


ThreadingUnhandledExceptionEventArgs.Source Property

ThreadingUnhandledExceptionEventArgsSource Property
Gets the source component that caught the exception.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ThreadingUnhandledExceptionSource Source { get; }

Property Value

Type: ThreadingUnhandledExceptionSource
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadingUnhandledExceptionEventArgs Class
PostSharp.Patterns.Threading Namespace


ThreadingUnhandledExceptionSource Enumeration

ThreadingUnhandledExceptionSource Enumeration
Enumeration of components that can raise the UnhandledException event.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum ThreadingUnhandledExceptionSource
Members
Member name | Value | Description
None | 0 | None.
Background | 1 | BackgroundAttribute.
Dispatch | 2 | DispatchedAttribute or ActorAttribute.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadMismatchException Class

ThreadMismatchException Class
Exception thrown when a thread attempts to access an object that is affined to another thread.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.Patterns.ThreadingThreadingException
PostSharp.Patterns.ThreadingThreadMismatchException

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class ThreadMismatchException : ThreadingException

The ThreadMismatchException type exposes the following members.

Constructors
 | Name | Description
Public method | ThreadMismatchException | Initializes a new ThreadMismatchException.
Public method | ThreadMismatchException(String) | Initializes a new ThreadMismatchException and sets the error message.
Public method | ThreadMismatchException(String, Exception) | Initializes a new ThreadMismatchException and sets the error message and the inner exception.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadMismatchException Constructor

ThreadMismatchException Constructor
Overload List
 | Name | Description
Public method | ThreadMismatchException | Initializes a new ThreadMismatchException.
Public method | ThreadMismatchException(String) | Initializes a new ThreadMismatchException and sets the error message.
Public method | ThreadMismatchException(String, Exception) | Initializes a new ThreadMismatchException and sets the error message and the inner exception.
Top
See Also

Reference

ThreadMismatchException Class
PostSharp.Patterns.Threading Namespace


ThreadMismatchException Constructor

ThreadMismatchException Constructor
Initializes a new ThreadMismatchException.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ThreadMismatchException()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ThreadMismatchException Class
ThreadMismatchException Overload
PostSharp.Patterns.Threading Namespace


ThreadMismatchException Constructor (String)

ThreadMismatchException Constructor (String)
Initializes a new ThreadMismatchException and sets the error message.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ThreadMismatchException(
    string message
)

Parameters

message
Type: SystemString
Error message.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ThreadMismatchException Class
ThreadMismatchException Overload
PostSharp.Patterns.Threading Namespace


ThreadMismatchException Constructor (String, Exception)

ThreadMismatchException Constructor (String, Exception)
Initializes a new ThreadMismatchException and sets the error message and the inner exception.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ThreadMismatchException(
    string message,
    Exception inner
)

Parameters

message
Type: SystemString
Error message.
inner
Type: SystemException
Inner exception.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ThreadMismatchException Class
ThreadMismatchException Overload
PostSharp.Patterns.Threading Namespace


ThreadMismatchException Methods

ThreadMismatchException Methods

The ThreadMismatchException type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ThreadMismatchException Class
PostSharp.Patterns.Threading Namespace


ThreadUnsafeAttribute Class

ThreadUnsafeAttribute Class
Custom attribute that, when applied on a type, ensures that only one thread executes in methods of this type. When more than one thread accesses methods of this type, a ConcurrentAccessException exception is thrown.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.AspectsAspect
PostSharp.AspectsTypeLevelAspect
PostSharp.AspectsInstanceLevelAspect
PostSharp.Patterns.ModelAggregatableClientAttribute
PostSharp.Patterns.ThreadingThreadAwareAttribute
PostSharp.Patterns.ThreadingThreadUnsafeAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ThreadUnsafeAttribute : ThreadAwareAttribute

The ThreadUnsafeAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides ThreadAwareAttributeCompileTimeValidate(Type).)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Overrides InstanceLevelAspectRuntimeInitializeInstance.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Patterns.Threading Namespace


ThreadUnsafeAttribute Methods

ThreadUnsafeAttribute Methods

The ThreadUnsafeAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeInitialize | Method invoked at build time to initialize the instance fields of the current aspect. This method is invoked before any other build-time method. (Inherited from AggregatableClientAttribute.)
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides ThreadAwareAttributeCompileTimeValidate(Type).)
Public method | CreateInstance | Creates a new instance of the aspect based on the current instance, serving as a prototype. (Inherited from InstanceLevelAspect.)
Public method | GetAspectConfiguration | Method invoked at build tome to get the imperative configuration of the current Aspect. (Inherited from Aspect.)
Public method | OnCloned | Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone. The this parameter refers to the new aspect instance in the cloned object. (Inherited from InstanceLevelAspect.)
Public method | OnInstanceConstructed | Executed when the target instance gets fully initialized, i.e. just after all constructors have completed. (Inherited from AggregatableClientAttribute.)
Public method | OnSerializing | Requires read access level to the current object before serialization can proceed. This method will be introduced into the target class. (Inherited from ThreadAwareAttribute.)
Public method | RuntimeInitialize | Initializes the current aspect. (Inherited from TypeLevelAspect.)
Public method | RuntimeInitializeInstance | Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed. (Overrides InstanceLevelAspectRuntimeInitializeInstance.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ThreadUnsafeAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadUnsafeAttribute.CompileTimeValidate Method

ThreadUnsafeAttributeCompileTimeValidate Method
Overload List
 | Name | Description
Public method | CompileTimeValidate(Object) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Inherited from TypeLevelAspect.)
Public method | CompileTimeValidate(Type) | Method invoked at build time to ensure that the aspect has been applied to the right target. (Overrides ThreadAwareAttributeCompileTimeValidate(Type).)
Top
See Also

Reference

ThreadUnsafeAttribute Class
PostSharp.Patterns.Threading Namespace


ThreadUnsafeAttribute.CompileTimeValidate Method (Type)

ThreadUnsafeAttributeCompileTimeValidate Method (Type)
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool CompileTimeValidate(
    Type type
)

Parameters

type
Type: SystemType
Type to which the aspect has been applied

Return Value

Type: Boolean
true if the aspect was applied to an acceptable field, otherwise false.
Remarks
The implementation of this method is expected to emit an error message (see MessageSource) or an exception in case of error. Returning false without emitting an error message or exception causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ThreadUnsafeAttribute Class
CompileTimeValidate Overload
PostSharp.Patterns.Threading Namespace

Other Resources

Conceptual Documentation: Validating Aspects


ThreadUnsafeAttribute.RuntimeInitializeInstance Method

ThreadUnsafeAttributeRuntimeInitializeInstance Method
Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void RuntimeInitializeInstance()

Implements

IInstanceScopedAspectRuntimeInitializeInstance
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadUnsafeAttribute Class
PostSharp.Patterns.Threading Namespace
PostSharp.Aspects.AdvicesInitializeAspectInstanceAdvice


ThreadUnsafeAttribute Properties

ThreadUnsafeAttribute Properties

The ThreadUnsafeAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AspectPriority | Gets or sets the weaving priority of the aspect. (Inherited from Aspect.)
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Public property | Instance | Gets the object to which the current aspect has been applied. (Inherited from InstanceLevelAspect.)
Public property | RuntimeVerificationEnabled | Determines whether the code should be verified against the model at runtime. The default value is true for the debug build configuration and false for the release build configuration. (Inherited from ThreadAwareAttribute.)
Top
See Also

Reference

ThreadUnsafeAttribute Class
PostSharp.Patterns.Threading Namespace


UpgradeableReaderAttribute Class

UpgradeableReaderAttribute Class
Custom attribute that, when applied on a method, specifies that the method requires read and write access to the object, but other threads are allowed to acquire read (but not write) access to the object until a method with the WriterAttribute custom attribute is executed.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingReaderWriterLockAttribute
PostSharp.Patterns.ThreadingUpgradeableReaderAttribute
PostSharp.Patterns.ThreadingUpgradeableReaderLockAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class UpgradeableReaderAttribute : ReaderWriterLockAttribute

The UpgradeableReaderAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | UpgradeableReaderAttribute | Initializes a new instance of the UpgradeableReaderAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace
PostSharp.Patterns.ThreadingReaderAttribute
PostSharp.Patterns.ThreadingWriterAttribute
PostSharp.Patterns.ThreadingYielderAttribute


UpgradeableReaderAttribute Constructor

UpgradeableReaderAttribute Constructor
Initializes a new instance of the UpgradeableReaderAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public UpgradeableReaderAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

UpgradeableReaderAttribute Class
PostSharp.Patterns.Threading Namespace


UpgradeableReaderAttribute Methods

UpgradeableReaderAttribute Methods

The UpgradeableReaderAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

UpgradeableReaderAttribute Class
PostSharp.Patterns.Threading Namespace


UpgradeableReaderAttribute Properties

UpgradeableReaderAttribute Properties

The UpgradeableReaderAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

UpgradeableReaderAttribute Class
PostSharp.Patterns.Threading Namespace


WriterAttribute Class

WriterAttribute Class
Custom attribute that, when applied on a method, specifies that the method requires write access to the object.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingReaderWriterLockAttribute
PostSharp.Patterns.ThreadingWriterAttribute
PostSharp.Patterns.ThreadingWriterLockAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class WriterAttribute : ReaderWriterLockAttribute

The WriterAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | WriterAttribute | Initializes a new instance of the WriterAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace
PostSharp.Patterns.ThreadingReaderAttribute
PostSharp.Patterns.ThreadingUpgradeableReaderAttribute
PostSharp.Patterns.ThreadingYielderAttribute


WriterAttribute Constructor

WriterAttribute Constructor
Initializes a new instance of the WriterAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public WriterAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

WriterAttribute Class
PostSharp.Patterns.Threading Namespace


WriterAttribute Methods

WriterAttribute Methods

The WriterAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

WriterAttribute Class
PostSharp.Patterns.Threading Namespace


WriterAttribute Properties

WriterAttribute Properties

The WriterAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

WriterAttribute Class
PostSharp.Patterns.Threading Namespace


YielderAttribute Class

YielderAttribute Class
Custom attribute that, when applied on a method, specifies that the method that currently holds write access to the object (see WriterAttribute) allows other threads to read the object during the execution of the target method. This custom attribute is typically used on methods that raise events that must be processed synchronously by other threads.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingReaderWriterLockAttribute
PostSharp.Patterns.ThreadingYielderAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class YielderAttribute : ReaderWriterLockAttribute

The YielderAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | YielderAttribute | Initializes a new instance of the YielderAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace
PostSharp.Patterns.ThreadingReaderAttribute
PostSharp.Patterns.ThreadingWriterAttribute
PostSharp.Patterns.ThreadingUpgradeableReaderAttribute


YielderAttribute Constructor

YielderAttribute Constructor
Initializes a new instance of the YielderAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public YielderAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

YielderAttribute Class
PostSharp.Patterns.Threading Namespace


YielderAttribute Methods

YielderAttribute Methods

The YielderAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

YielderAttribute Class
PostSharp.Patterns.Threading Namespace


YielderAttribute Properties

YielderAttribute Properties

The YielderAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

YielderAttribute Class
PostSharp.Patterns.Threading Namespace


PostSharp.Patterns.Threading.Models Namespace

PostSharp.Patterns.Threading.Models Namespace
Classes
 | Class | Description
Public class | ActorThreadingModel | The ActorThreadingModel class describes a threading model in which to methods are processed asynchronously from a single thread, suppressing concurrency inside each instance of the actor. To use the ActorThreadingModel, apply the ActorAttribute to a class.
Public class | FreezableThreadingModel | The FreezableThreadingModel class describes a threading model where changes to an object are forbidden after the Freeze method has been called on this object. To use the FreezableThreadingModel, apply the FreezableAttribute custom attribute to a class.
Public class | ImmutableThreadingModel | The ImmutableThreadingModel class describes a threading model where changes to an object are forbidden after completion of the object constructor. To use the ImmutableThreadingModel, apply the ImmutableAttribute custom attribute to a class.
Public class | PrivateThreadingModel | The PrivateThreadingModel class describes a behavior of objects in which their threading model is determined by the parent they are assigned to in a parent-child relationship. Objects with this threading model are considered a private state of their parent object and cannot be accessed from a different object.
Public class | ReaderWriterSynchronizedThreadingModel | The ReaderWriterSynchronizedThreadingModel class describes a threading model where several threads can have concurrent read-only access, but where writing to the object requires exclusive access. To use the ReaderWriterSynchronizedThreadingModel, apply the ReaderWriterSynchronizedAttribute custom attribute to a class.
Public class | ReadOnlyThreadingModel | Base class for FreezableThreadingModel and ImmutableThreadingModel.
Public class | SynchronizedThreadingModel | The SynchronizedThreadingModel class describes a threading model where only a single thread can access the object at a time. To use the SynchronizedThreadingModel, apply the SynchronizedAttribute custom attribute to a class.
Public class | ThreadAffineThreadingModel | The ThreadAffineThreadingModel class describes a threading model where only the thread that created the object has the right to access this object. To use the ThreadAffineThreadingModel, apply the ThreadAffineAttribute custom attribute to a class.
Public class | ThreadUnsafeThreadingModel | The ThreadUnsafeThreadingModel class describes a threading model an object cannot be accessed concurrently by several threads. In case of concurrent access, a ConcurrentAccessException exception will be thrown. The thread-unsafe threading model is not strictly a model, because it cannot be deterministically verified. To use the ThreadAffineThreadingModel, apply the ThreadUnsafeAttribute custom attribute to a class.


ActorThreadingModel Class

ActorThreadingModel Class

The ActorThreadingModel class describes a threading model in which to methods are processed asynchronously from a single thread, suppressing concurrency inside each instance of the actor. To use the ActorThreadingModel, apply the ActorAttribute to a class.

Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
PostSharp.Patterns.Threading.ModelsActorThreadingModel

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ActorThreadingModel : ThreadingModel

The ActorThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading.Models Namespace


ActorThreadingModel Methods

ActorThreadingModel Methods

The ActorThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ActorThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ActorThreadingModel Properties

ActorThreadingModel Properties

The ActorThreadingModel type exposes the following members.

Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
See Also

Reference

ActorThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ActorThreadingModel.IsThreadSafe Property

ActorThreadingModelIsThreadSafe Property
Determines whether the threading model is possibly thread safe.

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool IsThreadSafe { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ActorThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


FreezableThreadingModel Class

FreezableThreadingModel Class
The FreezableThreadingModel class describes a threading model where changes to an object are forbidden after the Freeze method has been called on this object. To use the FreezableThreadingModel, apply the FreezableAttribute custom attribute to a class.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
PostSharp.Patterns.Threading.ModelsReadOnlyThreadingModel
PostSharp.Patterns.Threading.ModelsFreezableThreadingModel

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class FreezableThreadingModel : ReadOnlyThreadingModel

The FreezableThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Inherited from ReadOnlyThreadingModel.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading.Models Namespace


FreezableThreadingModel Methods

FreezableThreadingModel Methods

The FreezableThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

FreezableThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


FreezableThreadingModel Properties

FreezableThreadingModel Properties

The FreezableThreadingModel type exposes the following members.

Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Inherited from ReadOnlyThreadingModel.)
Top
See Also

Reference

FreezableThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ImmutableThreadingModel Class

ImmutableThreadingModel Class
The ImmutableThreadingModel class describes a threading model where changes to an object are forbidden after completion of the object constructor. To use the ImmutableThreadingModel, apply the ImmutableAttribute custom attribute to a class.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
PostSharp.Patterns.Threading.ModelsReadOnlyThreadingModel
PostSharp.Patterns.Threading.ModelsImmutableThreadingModel

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ImmutableThreadingModel : ReadOnlyThreadingModel

The ImmutableThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Inherited from ReadOnlyThreadingModel.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading.Models Namespace


ImmutableThreadingModel Methods

ImmutableThreadingModel Methods

The ImmutableThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ImmutableThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ImmutableThreadingModel Properties

ImmutableThreadingModel Properties

The ImmutableThreadingModel type exposes the following members.

Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Inherited from ReadOnlyThreadingModel.)
Top
See Also

Reference

ImmutableThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


PrivateThreadingModel Class

PrivateThreadingModel Class
The PrivateThreadingModel class describes a behavior of objects in which their threading model is determined by the parent they are assigned to in a parent-child relationship. Objects with this threading model are considered a private state of their parent object and cannot be accessed from a different object.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
PostSharp.Patterns.Threading.ModelsPrivateThreadingModel

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class PrivateThreadingModel : ThreadingModel

The PrivateThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading.Models Namespace


PrivateThreadingModel Methods

PrivateThreadingModel Methods

The PrivateThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PrivateThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


PrivateThreadingModel Properties

PrivateThreadingModel Properties

The PrivateThreadingModel type exposes the following members.

Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
See Also

Reference

PrivateThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


PrivateThreadingModel.IsThreadSafe Property

PrivateThreadingModelIsThreadSafe Property
Determines whether the threading model is possibly thread safe.

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool IsThreadSafe { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PrivateThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ReaderWriterSynchronizedThreadingModel Class

ReaderWriterSynchronizedThreadingModel Class
The ReaderWriterSynchronizedThreadingModel class describes a threading model where several threads can have concurrent read-only access, but where writing to the object requires exclusive access. To use the ReaderWriterSynchronizedThreadingModel, apply the ReaderWriterSynchronizedAttribute custom attribute to a class.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
PostSharp.Patterns.Threading.ModelsReaderWriterSynchronizedThreadingModel

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ReaderWriterSynchronizedThreadingModel : ThreadingModel

The ReaderWriterSynchronizedThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading.Models Namespace


ReaderWriterSynchronizedThreadingModel Methods

ReaderWriterSynchronizedThreadingModel Methods

The ReaderWriterSynchronizedThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReaderWriterSynchronizedThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ReaderWriterSynchronizedThreadingModel Properties

ReaderWriterSynchronizedThreadingModel Properties

The ReaderWriterSynchronizedThreadingModel type exposes the following members.

Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
See Also

Reference

ReaderWriterSynchronizedThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ReaderWriterSynchronizedThreadingModel.IsThreadSafe Property

ReaderWriterSynchronizedThreadingModelIsThreadSafe Property
Determines whether the threading model is possibly thread safe.

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool IsThreadSafe { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReaderWriterSynchronizedThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ReadOnlyThreadingModel Class

ReadOnlyThreadingModel Class
Base class for FreezableThreadingModel and ImmutableThreadingModel.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
PostSharp.Patterns.Threading.ModelsReadOnlyThreadingModel
PostSharp.Patterns.Threading.ModelsFreezableThreadingModel
PostSharp.Patterns.Threading.ModelsImmutableThreadingModel

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class ReadOnlyThreadingModel : ThreadingModel

The ReadOnlyThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading.Models Namespace


ReadOnlyThreadingModel Methods

ReadOnlyThreadingModel Methods

The ReadOnlyThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReadOnlyThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ReadOnlyThreadingModel Properties

ReadOnlyThreadingModel Properties

The ReadOnlyThreadingModel type exposes the following members.

Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
See Also

Reference

ReadOnlyThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ReadOnlyThreadingModel.IsThreadSafe Property

ReadOnlyThreadingModelIsThreadSafe Property
Determines whether the threading model is possibly thread safe.

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool IsThreadSafe { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReadOnlyThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


SynchronizedThreadingModel Class

SynchronizedThreadingModel Class
The SynchronizedThreadingModel class describes a threading model where only a single thread can access the object at a time. To use the SynchronizedThreadingModel, apply the SynchronizedAttribute custom attribute to a class.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
PostSharp.Patterns.Threading.ModelsSynchronizedThreadingModel

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class SynchronizedThreadingModel : ThreadingModel

The SynchronizedThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading.Models Namespace


SynchronizedThreadingModel Methods

SynchronizedThreadingModel Methods

The SynchronizedThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SynchronizedThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


SynchronizedThreadingModel Properties

SynchronizedThreadingModel Properties

The SynchronizedThreadingModel type exposes the following members.

Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
See Also

Reference

SynchronizedThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


SynchronizedThreadingModel.IsThreadSafe Property

SynchronizedThreadingModelIsThreadSafe Property
Determines whether the threading model is possibly thread safe.

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool IsThreadSafe { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

SynchronizedThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ThreadAffineThreadingModel Class

ThreadAffineThreadingModel Class
The ThreadAffineThreadingModel class describes a threading model where only the thread that created the object has the right to access this object. To use the ThreadAffineThreadingModel, apply the ThreadAffineAttribute custom attribute to a class.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
PostSharp.Patterns.Threading.ModelsThreadUnsafeThreadingModel
PostSharp.Patterns.Threading.ModelsThreadAffineThreadingModel

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ThreadAffineThreadingModel : ThreadUnsafeThreadingModel

The ThreadAffineThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Inherited from ThreadUnsafeThreadingModel.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading.Models Namespace


ThreadAffineThreadingModel Methods

ThreadAffineThreadingModel Methods

The ThreadAffineThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ThreadAffineThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ThreadAffineThreadingModel Properties

ThreadAffineThreadingModel Properties

The ThreadAffineThreadingModel type exposes the following members.

Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Inherited from ThreadUnsafeThreadingModel.)
Top
See Also

Reference

ThreadAffineThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ThreadUnsafeThreadingModel Class

ThreadUnsafeThreadingModel Class
The ThreadUnsafeThreadingModel class describes a threading model an object cannot be accessed concurrently by several threads. In case of concurrent access, a ConcurrentAccessException exception will be thrown. The thread-unsafe threading model is not strictly a model, because it cannot be deterministically verified. To use the ThreadAffineThreadingModel, apply the ThreadUnsafeAttribute custom attribute to a class.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingThreadingModel
PostSharp.Patterns.Threading.ModelsThreadUnsafeThreadingModel
PostSharp.Patterns.Threading.ModelsThreadAffineThreadingModel

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class ThreadUnsafeThreadingModel : ThreadingModel

The ThreadUnsafeThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Patterns.Threading.Models Namespace


ThreadUnsafeThreadingModel Methods

ThreadUnsafeThreadingModel Methods

The ThreadUnsafeThreadingModel type exposes the following members.

Methods
 | Name | Description
Public method | ToString | Returns a string that represents the current object. (Inherited from ThreadingModel.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ThreadUnsafeThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ThreadUnsafeThreadingModel Properties

ThreadUnsafeThreadingModel Properties

The ThreadUnsafeThreadingModel type exposes the following members.

Properties
 | Name | Description
Public property | IsThreadSafe | Determines whether the threading model is possibly thread safe. (Overrides ThreadingModelIsThreadSafe.)
Top
See Also

Reference

ThreadUnsafeThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


ThreadUnsafeThreadingModel.IsThreadSafe Property

ThreadUnsafeThreadingModelIsThreadSafe Property
Determines whether the threading model is possibly thread safe.

Namespace: PostSharp.Patterns.Threading.Models
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool IsThreadSafe { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ThreadUnsafeThreadingModel Class
PostSharp.Patterns.Threading.Models Namespace


PostSharp.Patterns.Utilities Namespace

PostSharp.Patterns.Utilities Namespace
Classes
 | Class | Description
Public class | LocalizedTextProvider | Base class for providers of error messages. Implements chain of responsibility between multiple providers.


LocalizedTextProvider Class

LocalizedTextProvider Class
Base class for providers of error messages. Implements chain of responsibility between multiple providers.
Inheritance Hierarchy
SystemObject
PostSharp.Patterns.UtilitiesLocalizedTextProvider
PostSharp.Patterns.ContractsContractLocalizedTextProvider

Namespace: PostSharp.Patterns.Utilities
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class LocalizedTextProvider

The LocalizedTextProvider type exposes the following members.

Constructors
 | Name | Description
Protected method | LocalizedTextProvider | Initializes a new instance of LocalizedTextProvider class.
Top
Methods
 | Name | Description
Public method | FormatString | Formats a string. An implementation would typically invoke Format(String, Object).
Public method | GetMessage | Gets a message declared by the LocalizedTextProvider or the rest of responsibility chain if applicable.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
Each chain of providers has it's own base class derived from this one, which contains static field Current that points to current provider.
Version Information

Supported in: 4.1

See Also

Reference

PostSharp.Patterns.Utilities Namespace


LocalizedTextProvider Constructor

LocalizedTextProvider Constructor
Initializes a new instance of LocalizedTextProvider class.

Namespace: PostSharp.Patterns.Utilities
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected LocalizedTextProvider(
    LocalizedTextProvider next
)

Parameters

next
Type: PostSharp.Patterns.UtilitiesLocalizedTextProvider
Next LocalizedTextProvider in the responsibility chain.
Version Information

Supported in: 4.1

See Also

Reference

LocalizedTextProvider Class
PostSharp.Patterns.Utilities Namespace


LocalizedTextProvider Methods

LocalizedTextProvider Methods

The LocalizedTextProvider type exposes the following members.

Methods
 | Name | Description
Public method | FormatString | Formats a string. An implementation would typically invoke Format(String, Object).
Public method | GetMessage | Gets a message declared by the LocalizedTextProvider or the rest of responsibility chain if applicable.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LocalizedTextProvider Class
PostSharp.Patterns.Utilities Namespace


LocalizedTextProvider.FormatString Method

LocalizedTextProviderFormatString Method
Formats a string. An implementation would typically invoke Format(String, Object).

Namespace: PostSharp.Patterns.Utilities
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual string FormatString(
    string format,
    Object[] arguments
)

Parameters

format
Type: SystemString
Formatting string. Typically (but not necessarily) the string returned by GetMessage(String).
arguments
Type: SystemObject
Arguments.

Return Value

Type: String
The formatted string.
Version Information

Supported in: 4.1

See Also

Reference

LocalizedTextProvider Class
PostSharp.Patterns.Utilities Namespace


LocalizedTextProvider.GetMessage Method

LocalizedTextProviderGetMessage Method
Gets a message declared by the LocalizedTextProvider or the rest of responsibility chain if applicable.

Namespace: PostSharp.Patterns.Utilities
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual string GetMessage(
    string messageId
)

Parameters

messageId
Type: SystemString
Identifier of the message.

Return Value

Type: String
Message represented by messageId. Returning null is not allowed.
Remarks

An implementation must call the base implementation if it does not provide the requested message. The base implementation is responsible to invoke the next provider in the chain of responsibility.

Version Information

Supported in: 4.1

See Also

Reference

LocalizedTextProvider Class
PostSharp.Patterns.Utilities Namespace


PostSharp.Reflection Namespace

PostSharp.Reflection Namespace
The PostSharp.Reflection namespace complements the System.Reflection namespace.
Classes
 | Class | Description
Public class | CustomAttributeInstance | Instance of a custom attribute on a target declaration.
Public class | CustomReflectionBinder | Custom implementation of a reflection Binder that select methods based on exact matches using the ReflectionTypeComparer.
Public class | LocationInfo | Represents a FieldInfo, PropertyInfo or ParameterInfo, which all have the semantics of a location (get value, set value).
Public class | MemberTypeCodeReference | Represents a relationship between a type and a member of this type. A member can be a FieldInfo, PropertyInfo, or ParameterInfo.
Public class | MethodUsageCodeReference | Represents a relationship between a declaration (Type, FieldInfo, MethodInfo or ConstructorInfo) and a method whose instructions (method body) use the declaration.
Public class | ObjectConstruction | Specifies how an object should be constructed, i.e. specifies the constructor to be used, the arguments to be passed to this constructor, and the fields or properties to be set.
Public class | ReflectionExtensions | Provides utility methods to work with the System.Reflection namespace.
Public class | ReflectionHelper | Provides helper methods for work with System.Reflection.
Public class | ReflectionSearch | Set of static methods providing broader access to assembly metadata than the System.Reflection namespace. These methods are only available at build time.
Public class | ReflectionTypeComparer | Comparer of reflection types (Type) based on content, not reference. Supports the unbound generic parameters derived from the GenericArg class.
Public class | SymbolSequencePoint | Maps a point in IL instructions to location in source code.
Public class | TypeInheritanceCodeReference | Represents a inheritance relationship between two types.
Structures
 | Structure | Description
Public structure | DeclarationIdentifier | Encapsulates a unique identifier of a declaration. The identifier does not contain the kind of declaration. Different declarations of different kinds can have the same identifier.
Interfaces
 | Interface | Description
Public interface | IAssemblyName | Defines the semantics of an assembly name.
Public interface | ICodeReference | Represents a reference between two declarations.
Public interface | IMetadataDispenser | Semantics of service that deserializes metadata objects (i.e. reflection objects) that have been serialized by IMetadataEmitter.
Public interface | IMetadataEmitter | Semantics of a service that allows build-time code to serialize references to metadata objects (i.e. reflection objects) in a way that is compatible with obfuscators. References are deserialized at run-time using IMetadataDispenser.
Public interface | ISourceDocument | Represents a file of source code.
Enumerations
 | Enumeration | Description
Public enumeration | CodeReferenceKind | Kinds of code references (ICodeReference).
Public enumeration | LocationKind | Enumerates the kinds of code elements that can be encapsulated by a LocationInfo.
Public enumeration | MethodUsageInstructions | Instructions whose operands can reference a declaration.
Public enumeration | ReflectionSearchOptions |
Public enumeration | StateMachineKind | Enumeration of kinds of state machines.
Public enumeration | Visibility | Visibility of types and type members.


CodeReferenceKind Enumeration

CodeReferenceKind Enumeration
Kinds of code references (ICodeReference).

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum CodeReferenceKind
Members
Member name | Value | Description
None | 0 | No code reference.
TypeInheritance | 1 | Type inheritance. The base type is the ReferencedDeclaration; the child type is the ReferencingDeclaration. See TypeInheritanceCodeReference.
MemberType | 2 | Member type (field or property type, method return type, or parameter type). The member type is the ReferencedDeclaration. See MemberTypeCodeReference.
MethodUsage | 16 | Operand of an instruction in a method body. The ReferencingDeclaration is the method. See MethodUsageCodeReference.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


CustomAttributeInstance Class

CustomAttributeInstance Class
Instance of a custom attribute on a target declaration.
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionCustomAttributeInstance

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class CustomAttributeInstance

The CustomAttributeInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Attribute | Gets the custom attribute.
Public property | Construction | Gets the ObjectConstruction (including given constructor arguments and named arguments) used to construct the Attribute.
Public property | Target | Gets the declaration on which the custom attribute is defined.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


CustomAttributeInstance Methods

CustomAttributeInstance Methods

The CustomAttributeInstance type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CustomAttributeInstance Class
PostSharp.Reflection Namespace


CustomAttributeInstance Properties

CustomAttributeInstance Properties

The CustomAttributeInstance type exposes the following members.

Properties
 | Name | Description
Public property | Attribute | Gets the custom attribute.
Public property | Construction | Gets the ObjectConstruction (including given constructor arguments and named arguments) used to construct the Attribute.
Public property | Target | Gets the declaration on which the custom attribute is defined.
Top
See Also

Reference

CustomAttributeInstance Class
PostSharp.Reflection Namespace


CustomAttributeInstance.Attribute Property

CustomAttributeInstanceAttribute Property
Gets the custom attribute.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Attribute Attribute { get; }

Property Value

Type: Attribute
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomAttributeInstance Class
PostSharp.Reflection Namespace


CustomAttributeInstance.Construction Property

CustomAttributeInstanceConstruction Property
Gets the ObjectConstruction (including given constructor arguments and named arguments) used to construct the Attribute.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectConstruction Construction { get; }

Property Value

Type: ObjectConstruction
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomAttributeInstance Class
PostSharp.Reflection Namespace


CustomAttributeInstance.Target Property

CustomAttributeInstanceTarget Property
Gets the declaration on which the custom attribute is defined.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Target { get; }

Property Value

Type: Object
A reflection object: Assembly, Type, MethodInfo, ConstructorInfo, ParameterInfo, PropertyInfo, EventInfo, FieldInfo.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomAttributeInstance Class
PostSharp.Reflection Namespace


CustomReflectionBinder Class

CustomReflectionBinder Class
Custom implementation of a reflection Binder that select methods based on exact matches using the ReflectionTypeComparer.
Inheritance Hierarchy
SystemObject
System.ReflectionBinder
PostSharp.ReflectionCustomReflectionBinder

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class CustomReflectionBinder : Binder

The CustomReflectionBinder type exposes the following members.

Methods
 | Name | Description
Public method | BindToField | Selects a field from the given set of fields, based on the specified criteria. (Overrides BinderBindToField(BindingFlags, FieldInfo, Object, CultureInfo).)
Public method | BindToMethod | Selects a method to invoke from the given set of methods, based on the supplied arguments. (Overrides BinderBindToMethod(BindingFlags, MethodBase, Object, ParameterModifier, CultureInfo, String, Object).)
Public method | ChangeType | Changes the type of the given Object to the given Type. (Overrides BinderChangeType(Object, Type, CultureInfo).)
Public method | ReorderArgumentArray | Upon returning from BindToMethod(BindingFlags, MethodBase, Object, ParameterModifier, CultureInfo, String, Object), restores the args argument to what it was when it came from BindToMethod. (Overrides BinderReorderArgumentArray(Object, Object).)
Public method | SelectMethod | Selects a method from the given set of methods, based on the argument type. (Overrides BinderSelectMethod(BindingFlags, MethodBase, Type, ParameterModifier).)
Public method | SelectProperty | Selects a property from the given set of properties, based on the specified criteria. (Overrides BinderSelectProperty(BindingFlags, PropertyInfo, Type, Type, ParameterModifier).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
Instance | Singleton instance.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


CustomReflectionBinder Fields

CustomReflectionBinder Fields

The CustomReflectionBinder type exposes the following members.

Fields
Name | Description
Instance | Singleton instance.
Top
See Also

Reference

CustomReflectionBinder Class
PostSharp.Reflection Namespace


CustomReflectionBinder.Instance Field

CustomReflectionBinderInstance Field
Singleton instance.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly CustomReflectionBinder Instance

Field Value

Type: CustomReflectionBinder
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomReflectionBinder Class
PostSharp.Reflection Namespace


CustomReflectionBinder Methods

CustomReflectionBinder Methods

The CustomReflectionBinder type exposes the following members.

Methods
 | Name | Description
Public method | BindToField | Selects a field from the given set of fields, based on the specified criteria. (Overrides BinderBindToField(BindingFlags, FieldInfo, Object, CultureInfo).)
Public method | BindToMethod | Selects a method to invoke from the given set of methods, based on the supplied arguments. (Overrides BinderBindToMethod(BindingFlags, MethodBase, Object, ParameterModifier, CultureInfo, String, Object).)
Public method | ChangeType | Changes the type of the given Object to the given Type. (Overrides BinderChangeType(Object, Type, CultureInfo).)
Public method | ReorderArgumentArray | Upon returning from BindToMethod(BindingFlags, MethodBase, Object, ParameterModifier, CultureInfo, String, Object), restores the args argument to what it was when it came from BindToMethod. (Overrides BinderReorderArgumentArray(Object, Object).)
Public method | SelectMethod | Selects a method from the given set of methods, based on the argument type. (Overrides BinderSelectMethod(BindingFlags, MethodBase, Type, ParameterModifier).)
Public method | SelectProperty | Selects a property from the given set of properties, based on the specified criteria. (Overrides BinderSelectProperty(BindingFlags, PropertyInfo, Type, Type, ParameterModifier).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

CustomReflectionBinder Class
PostSharp.Reflection Namespace


CustomReflectionBinder.BindToField Method

CustomReflectionBinderBindToField Method
Selects a field from the given set of fields, based on the specified criteria.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override FieldInfo BindToField(
    BindingFlags bindingFlags,
    FieldInfo[] match,
    Object value,
    CultureInfo culture
)

Parameters

bindingFlags
Type: System.ReflectionBindingFlags
match
Type: System.ReflectionFieldInfo
The set of fields that are candidates for matching. For example, when a Binder object is used by InvokeMember, this parameter specifies the set of fields that reflection has determined to be possible matches, typically because they have the correct member name. The default implementation provided by DefaultBinder changes the order of this array.
value
Type: SystemObject
The field value used to locate a matching field.
culture
Type: System.GlobalizationCultureInfo
An instance of CultureInfo that is used to control the coercion of data types, in binder implementations that coerce types. If culture is null, the CultureInfo for the current thread is used.Note For example, if a binder implementation allows coercion of string values to numeric types, this parameter is necessary to convert a String that represents 1000 to a Double value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions.

Return Value

Type: FieldInfo
The matching field.
Exceptions
Exception | Condition
AmbiguousMatchException | For the default binder, bindingAttr includes SetField, and match contains multiple fields that are equally good matches for value. For example, value contains a MyClass object that implements the IMyClass interface, and match contains a field of type MyClass and a field of type IMyClass.
MissingFieldException | For the default binder, bindingAttr includes SetField, and match contains no fields that can accept value.
NullReferenceException | For the default binder, bindingAttr includes SetField, and match is null or an empty array.-or-bindingAttr includes SetField, and value is null.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomReflectionBinder Class
PostSharp.Reflection Namespace


CustomReflectionBinder.BindToMethod Method

CustomReflectionBinderBindToMethod Method
Selects a method to invoke from the given set of methods, based on the supplied arguments.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override MethodBase BindToMethod(
    BindingFlags bindingFlags,
    MethodBase[] match,
    ref Object[] args,
    ParameterModifier[] modifiers,
    CultureInfo culture,
    string[] names,
    out Object state
)

Parameters

bindingFlags
Type: System.ReflectionBindingFlags
match
Type: System.ReflectionMethodBase
The set of methods that are candidates for matching. For example, when a Binder object is used by InvokeMember, this parameter specifies the set of methods that reflection has determined to be possible matches, typically because they have the correct member name. The default implementation provided by DefaultBinder changes the order of this array.
args
Type: SystemObject
The arguments that are passed in. The binder can change the order of the arguments in this array; for example, the default binder changes the order of arguments if the names parameter is used to specify an order other than positional order. If a binder implementation coerces argument types, the types and values of the arguments can be changed as well.
modifiers
Type: System.ReflectionParameterModifier
An array of parameter modifiers that enable binding to work with parameter signatures in which the types have been modified. The default binder implementation does not use this parameter.
culture
Type: System.GlobalizationCultureInfo
An instance of CultureInfo that is used to control the coercion of data types, in binder implementations that coerce types. If culture is null, the CultureInfo for the current thread is used. Note For example, if a binder implementation allows coercion of string values to numeric types, this parameter is necessary to convert a String that represents 1000 to a Double value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions.
names
Type: SystemString
The parameter names, if parameter names are to be considered when matching, or null if arguments are to be treated as purely positional. For example, parameter names must be used if arguments are not supplied in positional order.
state
Type: SystemObject
After the method returns, state contains a binder-provided object that keeps track of argument reordering. The binder creates this object, and the binder is the sole consumer of this object. If state is not null when BindToMethod returns, you must pass state to the ReorderArgumentArray(Object, Object) method if you want to restore args to its original order, for example, so that you can retrieve the values of ref parameters (ByRef parameters in Visual Basic).

Return Value

Type: MethodBase
The matching method.
Exceptions
Exception | Condition
AmbiguousMatchException | For the default binder, match contains multiple methods that are equally good matches for args. For example, args contains a MyClass object that implements the IMyClass interface, and match contains a method that takes MyClass and a method that takes IMyClass.
MissingMethodException | For the default binder, match contains no methods that can accept the arguments supplied in args.
ArgumentException | For the default binder, match is null or an empty array.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomReflectionBinder Class
PostSharp.Reflection Namespace


CustomReflectionBinder.ChangeType Method

CustomReflectionBinderChangeType Method
Changes the type of the given Object to the given Type.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object ChangeType(
    Object value,
    Type type,
    CultureInfo culture
)

Parameters

value
Type: SystemObject
The object to change into a new Type.
type
Type: SystemType
The new Type that value will become.
culture
Type: System.GlobalizationCultureInfo
An instance of CultureInfo that is used to control the coercion of data types. If culture is null, the CultureInfo for the current thread is used.Note For example, this parameter is necessary to convert a String that represents 1000 to a Double value, because 1000 is represented differently by different cultures.

Return Value

Type: Object
An object that contains the given value as the new type.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomReflectionBinder Class
PostSharp.Reflection Namespace


CustomReflectionBinder.ReorderArgumentArray Method

CustomReflectionBinderReorderArgumentArray Method
Upon returning from BindToMethod(BindingFlags, MethodBase, Object, ParameterModifier, CultureInfo, String, Object), restores the args argument to what it was when it came from BindToMethod.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override void ReorderArgumentArray(
    ref Object[] args,
    Object state
)

Parameters

args
Type: SystemObject
The actual arguments that are passed in. Both the types and values of the arguments can be changed.
state
Type: SystemObject
A binder-provided object that keeps track of argument reordering.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomReflectionBinder Class
PostSharp.Reflection Namespace


CustomReflectionBinder.SelectMethod Method

CustomReflectionBinderSelectMethod Method
Selects a method from the given set of methods, based on the argument type.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override MethodBase SelectMethod(
    BindingFlags bindingFlags,
    MethodBase[] match,
    Type[] types,
    ParameterModifier[] modifiers
)

Parameters

bindingFlags
Type: System.ReflectionBindingFlags
match
Type: System.ReflectionMethodBase
The set of methods that are candidates for matching. For example, when a Binder object is used by InvokeMember, this parameter specifies the set of methods that reflection has determined to be possible matches, typically because they have the correct member name. The default implementation provided by DefaultBinder changes the order of this array.
types
Type: SystemType
The parameter types used to locate a matching method.
modifiers
Type: System.ReflectionParameterModifier
An array of parameter modifiers that enable binding to work with parameter signatures in which the types have been modified.

Return Value

Type: MethodBase
The matching method, if found; otherwise, null.
Exceptions
Exception | Condition
AmbiguousMatchException | For the default binder, match contains multiple methods that are equally good matches for the parameter types described by types. For example, the array in types contains a Type object for MyClass and the array in match contains a method that takes a base class of MyClass and a method that takes an interface that MyClass implements.
ArgumentException | For the default binder, match is null or an empty array.-or-An element of types derives from Type, but is not of type RuntimeType.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomReflectionBinder Class
PostSharp.Reflection Namespace


CustomReflectionBinder.SelectProperty Method

CustomReflectionBinderSelectProperty Method
Selects a property from the given set of properties, based on the specified criteria.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override PropertyInfo SelectProperty(
    BindingFlags bindingFlags,
    PropertyInfo[] match,
    Type returnType,
    Type[] indexes,
    ParameterModifier[] modifiers
)

Parameters

bindingFlags
Type: System.ReflectionBindingFlags
match
Type: System.ReflectionPropertyInfo
The set of properties that are candidates for matching. For example, when a Binder object is used by InvokeMember, this parameter specifies the set of properties that reflection has determined to be possible matches, typically because they have the correct member name. The default implementation provided by DefaultBinder changes the order of this array.
returnType
Type: SystemType
The return value the matching property must have.
indexes
Type: SystemType
The index types of the property being searched for. Used for index properties such as the indexer for a class.
modifiers
Type: System.ReflectionParameterModifier
An array of parameter modifiers that enable binding to work with parameter signatures in which the types have been modified.

Return Value

Type: PropertyInfo
The matching property.
Exceptions
Exception | Condition
AmbiguousMatchException | For the default binder, match contains multiple properties that are equally good matches for returnType and indexes.
ArgumentException | For the default binder, match is null or an empty array.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

CustomReflectionBinder Class
PostSharp.Reflection Namespace


DeclarationIdentifier Structure

DeclarationIdentifier Structure
Encapsulates a unique identifier of a declaration. The identifier does not contain the kind of declaration. Different declarations of different kinds can have the same identifier.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public struct DeclarationIdentifier : IEquatable<DeclarationIdentifier>

The DeclarationIdentifier type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(DeclarationIdentifier) | Indicates whether the current object is equal to another object of the same type.
 | GetDeclarationIdentifier | Gets the DeclarationIdentifier for a given declaration.
Public method | GetDeclaringTypeIdentifier | Gets the DeclarationIdentifier that represents the declaring type of the declaration represented by the current DeclarationIdentifier.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Top
Operators
Name | Description
Equality | Determines whether two instances of the DeclarationIdentifier type are equal.
Inequality | Determines whether two instances of the DeclarationIdentifier type are different.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
MaxMemberIndex | Maximum number of the same kind in the same type supported by the DeclarationIdentifier class.
MaxTypeIndex | Maximum number of types per assembly supported by the DeclarationIdentifier class.
Top
Properties
 | Name | Description
Public property | AssemblyId | Gets a 29-bit of the name of the assembly containing the declaration represented by the current DeclarationIdentifier.
Public property | IsNull | Determines whether the current DeclarationIdentifier is null.
Public property | MemberIndex | Gets a number that uniquely identifies the member inside its declaring type, for the given member kind.
 | Null | Gets a null instance of the DeclarationIdentifier type/
Public property | TypeIndex | Gets a number that uniquely identifies the type inside its declaring assembly.
Top
Remarks

The DeclarationIdentifier concept provides an efficient mechanism to correlate data that depend on the target declaration of the advice. Typically, such data can be computed at build time and serialized into the aspect, then consumed at run time. Without the DeclarationIdentifier concept, the data would be stored in a dictionary, for instance Dictionary<MethodInfo,MethodData> where MethodData is a custom class. However, relying on a dictionary has some performance costs. Thanks to the the DeclarationIdentifier concept, data can be stored in an array, because the MemberIndex is guarantees to be unique in a given type for a given kind of member (for instance, MemberIndex is unique for all methods in the same type). Array lookups are much faster than dictionary lookups and do not rely on reflection, which gives a significant performance benefit.

Note Note

Although the CIL specification allows for up to 2^24 types in the same assembly and 2^24 methods (or other members) in the same type, the DeclarationIdentifier implementation assumes that there will be no more than 2^16 types in the same assembly and 2^16 members of the same kind in the same type. The AssemblyId property to be coded on 32 bits. The AssemblyId is computed by running the MD5 algorithm on the full assembly name. The probability of hash collision is approximately 10^-6 for an application of 100 assemblies and 10^-5 for an application of 1,000 assemblies. Collisions can be avoided by adding the AssemblyIdAttribute custom attribute to one of the assemblies causing a hash collision. Note that hash collisions are not automatically detected by PostSharp. However, you can build a hash collision detection program by looking at the AssemblyIdAttribute custom attribute on all assemblies of your application after PostSharp has been executed.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Reflection Namespace


DeclarationIdentifier Fields

DeclarationIdentifier Fields

The DeclarationIdentifier type exposes the following members.

Fields
Name | Description
MaxMemberIndex | Maximum number of the same kind in the same type supported by the DeclarationIdentifier class.
MaxTypeIndex | Maximum number of types per assembly supported by the DeclarationIdentifier class.
Top
See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.MaxMemberIndex Field

DeclarationIdentifierMaxMemberIndex Field
Maximum number of the same kind in the same type supported by the DeclarationIdentifier class.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const int MaxMemberIndex

Field Value

Type: Int32
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.MaxTypeIndex Field

DeclarationIdentifierMaxTypeIndex Field
Maximum number of types per assembly supported by the DeclarationIdentifier class.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public const int MaxTypeIndex

Field Value

Type: Int32
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier Methods

DeclarationIdentifier Methods

The DeclarationIdentifier type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(DeclarationIdentifier) | Indicates whether the current object is equal to another object of the same type.
 | GetDeclarationIdentifier | Gets the DeclarationIdentifier for a given declaration.
Public method | GetDeclaringTypeIdentifier | Gets the DeclarationIdentifier that represents the declaring type of the declaration represented by the current DeclarationIdentifier.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.Equals Method

DeclarationIdentifierEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(DeclarationIdentifier) | Indicates whether the current object is equal to another object of the same type.
Top
See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.Equals Method (Object)

DeclarationIdentifierEquals Method (Object)
Indicates whether this instance and a specified object are equal.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool Equals(
    Object obj
)

Parameters

obj
Type: SystemObject
Another object to compare to.

Return Value

Type: Boolean
true if obj and this instance are the same type and represent the same value; otherwise, false.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
Equals Overload
PostSharp.Reflection Namespace


DeclarationIdentifier.Equals Method (DeclarationIdentifier)

DeclarationIdentifierEquals Method (DeclarationIdentifier)
Indicates whether the current object is equal to another object of the same type.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Equals(
    DeclarationIdentifier other
)

Parameters

other
Type: PostSharp.ReflectionDeclarationIdentifier
An object to compare with this object.

Return Value

Type: Boolean
true if the current object is equal to the other parameter; otherwise, false.

Implements

IEquatableTEquals(T)
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
Equals Overload
PostSharp.Reflection Namespace


DeclarationIdentifier.GetDeclarationIdentifier Method

DeclarationIdentifierGetDeclarationIdentifier Method
Gets the DeclarationIdentifier for a given declaration.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static DeclarationIdentifier GetDeclarationIdentifier(
    MemberInfo declaration
)

Parameters

declaration
Type: System.ReflectionMemberInfo
A Type, MethodInfo, ConstructorInfo, FieldInfo, EventInfo or PropertyInfo.

Return Value

Type: DeclarationIdentifier
A DeclarationIdentifier that identifies declaration.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.GetDeclaringTypeIdentifier Method

DeclarationIdentifierGetDeclaringTypeIdentifier Method
Gets the DeclarationIdentifier that represents the declaring type of the declaration represented by the current DeclarationIdentifier.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DeclarationIdentifier GetDeclaringTypeIdentifier()

Return Value

Type: DeclarationIdentifier
The DeclarationIdentifier that represents the declaring type of the declaration represented by the current DeclarationIdentifier. If the current DeclarationIdentifier already represents a type, this method returns the current DeclarationIdentifier.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.GetHashCode Method

DeclarationIdentifierGetHashCode Method
Returns the hash code for this instance.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int GetHashCode()

Return Value

Type: Int32
A 32-bit signed integer that is the hash code for this instance.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier Operators

DeclarationIdentifier Operators

The DeclarationIdentifier type exposes the following members.

Operators
Name | Description
Equality | Determines whether two instances of the DeclarationIdentifier type are equal.
Inequality | Determines whether two instances of the DeclarationIdentifier type are different.
Top
See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.Equality Operator

DeclarationIdentifierEquality Operator
Determines whether two instances of the DeclarationIdentifier type are equal.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator ==(
    DeclarationIdentifier left,
    DeclarationIdentifier right
)

Parameters

left
Type: PostSharp.ReflectionDeclarationIdentifier
right
Type: PostSharp.ReflectionDeclarationIdentifier

Return Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.Inequality Operator

DeclarationIdentifierInequality Operator
Determines whether two instances of the DeclarationIdentifier type are different.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator !=(
    DeclarationIdentifier left,
    DeclarationIdentifier right
)

Parameters

left
Type: PostSharp.ReflectionDeclarationIdentifier
right
Type: PostSharp.ReflectionDeclarationIdentifier

Return Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier Properties

DeclarationIdentifier Properties

The DeclarationIdentifier type exposes the following members.

Properties
 | Name | Description
Public property | AssemblyId | Gets a 29-bit of the name of the assembly containing the declaration represented by the current DeclarationIdentifier.
Public property | IsNull | Determines whether the current DeclarationIdentifier is null.
Public property | MemberIndex | Gets a number that uniquely identifies the member inside its declaring type, for the given member kind.
 | Null | Gets a null instance of the DeclarationIdentifier type/
Public property | TypeIndex | Gets a number that uniquely identifies the type inside its declaring assembly.
Top
See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.AssemblyId Property

DeclarationIdentifierAssemblyId Property
Gets a 29-bit of the name of the assembly containing the declaration represented by the current DeclarationIdentifier.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int AssemblyId { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.IsNull Property

DeclarationIdentifierIsNull Property
Determines whether the current DeclarationIdentifier is null.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsNull { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.MemberIndex Property

DeclarationIdentifierMemberIndex Property
Gets a number that uniquely identifies the member inside its declaring type, for the given member kind.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int MemberIndex { get; }

Property Value

Type: Int32
Remarks

The value of this property is guaranteed to be smaller than the total number of methods in the declaring type.

The value is guaranteed to be unique only in the declaring type, not in the set of base types. Numbering of members restarts at 0 for every derived type.

Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


DeclarationIdentifier.Null Property

DeclarationIdentifierNull Property
Gets a null instance of the DeclarationIdentifier type/

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static DeclarationIdentifier Null { get; }

Property Value

Type: DeclarationIdentifier
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace
DeclarationIdentifierIsNull


DeclarationIdentifier.TypeIndex Property

DeclarationIdentifierTypeIndex Property
Gets a number that uniquely identifies the type inside its declaring assembly.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int TypeIndex { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0

See Also

Reference

DeclarationIdentifier Structure
PostSharp.Reflection Namespace


IAssemblyName Interface

IAssemblyName Interface
Defines the semantics of an assembly name.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAssemblyName

The IAssemblyName type exposes the following members.

Methods
 | Name | Description
Public method | GetPublicKey | Gets the assembly public key.
Public method | GetPublicKeyToken | Gets the assembly public key token.
Top
Properties
 | Name | Description
Public property | Culture | Gets the assembly culture name.
Public property | IsMscorlib | Determines whether the current assembly (or assembly reference) is mscorlib.
Public property | IsRetargetable | Determines whether the reference is retargetable by the CLR, i.e. can be accommodated by an assembly whose identity does not match the current assembly reference.
Public property | IsStronglyNamed | Determines whether the current assembly (or assembly reference) contains a strong name signature.
Public property | Name | Gets the assembly friendly name.
Public property | ProcessorArchitecture | Gets the processor architecture that the current assembly targets.
Public property | Version | Gets the assembly version.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


IAssemblyName Methods

IAssemblyName Methods

The IAssemblyName type exposes the following members.

Methods
 | Name | Description
Public method | GetPublicKey | Gets the assembly public key.
Public method | GetPublicKeyToken | Gets the assembly public key token.
Top
See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


IAssemblyName.GetPublicKey Method

IAssemblyNameGetPublicKey Method
Gets the assembly public key.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
byte[] GetPublicKey()

Field Value

Type: Byte
An array of bytes containing the public key, or null if no public key is specified (for instance if only the public key token is given).

Return Value

Type: Byte
An array of bytes containing the public key, or null if no public key is specified.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


IAssemblyName.GetPublicKeyToken Method

IAssemblyNameGetPublicKeyToken Method
Gets the assembly public key token.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
byte[] GetPublicKeyToken()

Return Value

Type: Byte
An array of bytes containing the public key token, or null if no public key is specified.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


IAssemblyName Properties

IAssemblyName Properties

The IAssemblyName type exposes the following members.

Properties
 | Name | Description
Public property | Culture | Gets the assembly culture name.
Public property | IsMscorlib | Determines whether the current assembly (or assembly reference) is mscorlib.
Public property | IsRetargetable | Determines whether the reference is retargetable by the CLR, i.e. can be accommodated by an assembly whose identity does not match the current assembly reference.
Public property | IsStronglyNamed | Determines whether the current assembly (or assembly reference) contains a strong name signature.
Public property | Name | Gets the assembly friendly name.
Public property | ProcessorArchitecture | Gets the processor architecture that the current assembly targets.
Public property | Version | Gets the assembly version.
Top
See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


IAssemblyName.Culture Property

IAssemblyNameCulture Property
Gets the assembly culture name.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string Culture { get; }

Property Value

Type: String
The standard assembly culture name, or null if the assembly is culture-neutral.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


IAssemblyName.IsMscorlib Property

IAssemblyNameIsMscorlib Property
Determines whether the current assembly (or assembly reference) is mscorlib.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsMscorlib { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


IAssemblyName.IsRetargetable Property

IAssemblyNameIsRetargetable Property
Determines whether the reference is retargetable by the CLR, i.e. can be accommodated by an assembly whose identity does not match the current assembly reference.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsRetargetable { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


IAssemblyName.IsStronglyNamed Property

IAssemblyNameIsStronglyNamed Property
Determines whether the current assembly (or assembly reference) contains a strong name signature.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsStronglyNamed { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


IAssemblyName.Name Property

IAssemblyNameName Property
Gets the assembly friendly name.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string Name { get; }

Property Value

Type: String
The assembly friendly name.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


IAssemblyName.ProcessorArchitecture Property

IAssemblyNameProcessorArchitecture Property
Gets the processor architecture that the current assembly targets.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ProcessorArchitecture ProcessorArchitecture { get; }

Property Value

Type: ProcessorArchitecture
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


IAssemblyName.Version Property

IAssemblyNameVersion Property
Gets the assembly version.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Version Version { get; }

Property Value

Type: Version
A Version.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAssemblyName Interface
PostSharp.Reflection Namespace


ICodeReference Interface

ICodeReference Interface
Represents a reference between two declarations.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ICodeReference

The ICodeReference type exposes the following members.

Properties
 | Name | Description
Public property | ReferencedDeclaration | Gets the declaration referenced by the other.
Public property | ReferenceKind | Gets the kind of code reference.
Public property | ReferencingDeclaration | Gets the declaration referencing the other.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


ICodeReference Properties

ICodeReference Properties

The ICodeReference type exposes the following members.

Properties
 | Name | Description
Public property | ReferencedDeclaration | Gets the declaration referenced by the other.
Public property | ReferenceKind | Gets the kind of code reference.
Public property | ReferencingDeclaration | Gets the declaration referencing the other.
Top
See Also

Reference

ICodeReference Interface
PostSharp.Reflection Namespace


ICodeReference.ReferencedDeclaration Property

ICodeReferenceReferencedDeclaration Property
Gets the declaration referenced by the other.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object ReferencedDeclaration { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ICodeReference Interface
PostSharp.Reflection Namespace


ICodeReference.ReferenceKind Property

ICodeReferenceReferenceKind Property
Gets the kind of code reference.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
CodeReferenceKind ReferenceKind { get; }

Property Value

Type: CodeReferenceKind
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ICodeReference Interface
PostSharp.Reflection Namespace


ICodeReference.ReferencingDeclaration Property

ICodeReferenceReferencingDeclaration Property
Gets the declaration referencing the other.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object ReferencingDeclaration { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ICodeReference Interface
PostSharp.Reflection Namespace


IMetadataDispenser Interface

IMetadataDispenser Interface
Semantics of service that deserializes metadata objects (i.e. reflection objects) that have been serialized by IMetadataEmitter.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMetadataDispenser

The IMetadataDispenser type exposes the following members.

Methods
 | Name | Description
Public method | GetMetadata | Gets the reflection object corresponding to the given index.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


IMetadataDispenser Methods

IMetadataDispenser Methods

The IMetadataDispenser type exposes the following members.

Methods
 | Name | Description
Public method | GetMetadata | Gets the reflection object corresponding to the given index.
Top
See Also

Reference

IMetadataDispenser Interface
PostSharp.Reflection Namespace


IMetadataDispenser.GetMetadata Method

IMetadataDispenserGetMetadata Method
Gets the reflection object corresponding to the given index.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object GetMetadata(
    int index
)

Parameters

index
Type: SystemInt32
Index returned by GetMetadataIndex(Object) at build time.

Return Value

Type: Object
The reflection object corresponding to index.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMetadataDispenser Interface
PostSharp.Reflection Namespace


IMetadataEmitter Interface

IMetadataEmitter Interface
Semantics of a service that allows build-time code to serialize references to metadata objects (i.e. reflection objects) in a way that is compatible with obfuscators. References are deserialized at run-time using IMetadataDispenser.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMetadataEmitter

The IMetadataEmitter type exposes the following members.

Methods
 | Name | Description
Public method | GetMetadataIndex | Gets the index of a serialized metadata reference.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


IMetadataEmitter Methods

IMetadataEmitter Methods

The IMetadataEmitter type exposes the following members.

Methods
 | Name | Description
Public method | GetMetadataIndex | Gets the index of a serialized metadata reference.
Top
See Also

Reference

IMetadataEmitter Interface
PostSharp.Reflection Namespace


IMetadataEmitter.GetMetadataIndex Method

IMetadataEmitterGetMetadataIndex Method
Gets the index of a serialized metadata reference.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
int GetMetadataIndex(
    Object metadata
)

Parameters

metadata
Type: SystemObject
A reflection object.

Return Value

Type: Int32
The index of metadata, to be serialized and deserialized at runtime with GetMetadata(Int32).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMetadataEmitter Interface
PostSharp.Reflection Namespace


ISourceDocument Interface

ISourceDocument Interface
Represents a file of source code.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISourceDocument

The ISourceDocument type exposes the following members.

Properties
 | Name | Description
Public property | DocumentType | Document type (Guid according to Microsoft PDB specification).
Public property | FileName | Full path of the file.
Public property | Language | Language (Guid according to Microsoft PDB specification).
Public property | LanguageVendor | Language vendor (Guid according to Microsoft PDB specification).
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


ISourceDocument Properties

ISourceDocument Properties

The ISourceDocument type exposes the following members.

Properties
 | Name | Description
Public property | DocumentType | Document type (Guid according to Microsoft PDB specification).
Public property | FileName | Full path of the file.
Public property | Language | Language (Guid according to Microsoft PDB specification).
Public property | LanguageVendor | Language vendor (Guid according to Microsoft PDB specification).
Top
See Also

Reference

ISourceDocument Interface
PostSharp.Reflection Namespace


ISourceDocument.DocumentType Property

ISourceDocumentDocumentType Property
Document type (Guid according to Microsoft PDB specification).

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Guid DocumentType { get; }

Property Value

Type: Guid
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISourceDocument Interface
PostSharp.Reflection Namespace


ISourceDocument.FileName Property

ISourceDocumentFileName Property
Full path of the file.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string FileName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISourceDocument Interface
PostSharp.Reflection Namespace


ISourceDocument.Language Property

ISourceDocumentLanguage Property
Language (Guid according to Microsoft PDB specification).

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Guid Language { get; }

Property Value

Type: Guid
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISourceDocument Interface
PostSharp.Reflection Namespace


ISourceDocument.LanguageVendor Property

ISourceDocumentLanguageVendor Property
Language vendor (Guid according to Microsoft PDB specification).

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Guid LanguageVendor { get; }

Property Value

Type: Guid
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISourceDocument Interface
PostSharp.Reflection Namespace


LocationInfo Class

LocationInfo Class
Represents a FieldInfo, PropertyInfo or ParameterInfo, which all have the semantics of a location (get value, set value).
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionLocationInfo

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public sealed class LocationInfo : IEquatable<LocationInfo>,
    ISerializable

The LocationInfo type exposes the following members.

Constructors
 | Name | Description
Public method | LocationInfo(FieldInfo) | Initializes a new LocationInfo from a FieldInfo.
Public method | LocationInfo(ParameterInfo) | Initializes a new LocationInfo from a ParameterInfo.
Public method | LocationInfo(PropertyInfo) | Initializes a new LocationInfo from a PropertyInfo.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Overrides ObjectEquals(Object).)
Public method | Equals(LocationInfo) | Indicates whether the current object is equal to another object of the same type.
Public method | GetHashCode | Serves as a hash function for a particular type. (Overrides ObjectGetHashCode.)
Public method | GetValue(Object) | Returns the value of the field or property represented by the current object.
Public method | GetValue(Object, Object) | Returns the value of the field or property represented by the current object with optional index values for indexed properties.
Public method | SetValue(Object, Object) | Sets the value of the field or property represented by the current object to a given value.
Public method | SetValue(Object, Object, Object) | Sets the value of the field or property represented by the current object to a given value with optional index values for indexed properties.
 | ToLocationInfo | Initializes a new LocationInfo from a FieldInfo, PropertyInfo, or ParameterInfo.
 | ToLocationInfoArray(ICollectionFieldInfo) | Converts a collection of FieldInfo into an array of LocationInfo.
 | ToLocationInfoArray(ICollectionParameterInfo) | Converts a collection of ParameterInfo into an array of LocationInfo.
 | ToLocationInfoArray(ICollectionPropertyInfo) | Converts a collection of PropertyInfo into an array of LocationInfo.
Public method | ToString | Returns a string that represents the current object. (Overrides ObjectToString.)
Top
Operators
Name | Description
Equality | Determines whether two instances of LocationInfo represent the same element of code.
Inequality | Determines whether two instances of LocationInfo represent different elements of code.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | DeclaringType | Gets the declaring type of the underlying field, property, parameter, or return value.
Public property | FieldInfo | Gets the underlying FieldInfo, or null if the underlying code element is not a property.
Public property | IsStatic | Determines whether the underlying field or property is static.
Public property | LocationKind | Gets the location kind (Field, Property, Parameter or ReturnValue).
Public property | LocationType | Gets the type of values that can be stored in the location.
Public property | Name | Gets the name of the underlying field, property, parameter, or return value.
Public property | ParameterInfo | Gets the underlying ParameterInfo, or null if the underlying code element is not a property.
Public property | PropertyInfo | Gets the underlying PropertyInfo, or null if the underlying code element is not a property.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


LocationInfo Constructor

LocationInfo Constructor
Overload List
 | Name | Description
Public method | LocationInfo(FieldInfo) | Initializes a new LocationInfo from a FieldInfo.
Public method | LocationInfo(ParameterInfo) | Initializes a new LocationInfo from a ParameterInfo.
Public method | LocationInfo(PropertyInfo) | Initializes a new LocationInfo from a PropertyInfo.
Top
See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo Constructor (FieldInfo)

LocationInfo Constructor (FieldInfo)
Initializes a new LocationInfo from a FieldInfo.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LocationInfo(
    FieldInfo fieldInfo
)

Parameters

fieldInfo
Type: System.ReflectionFieldInfo
The field represented by the LocationInfo.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
LocationInfo Overload
PostSharp.Reflection Namespace


LocationInfo Constructor (ParameterInfo)

LocationInfo Constructor (ParameterInfo)
Initializes a new LocationInfo from a ParameterInfo.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LocationInfo(
    ParameterInfo parameterInfo
)

Parameters

parameterInfo
Type: System.ReflectionParameterInfo
The parameter represented by the LocationInfo.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
LocationInfo Overload
PostSharp.Reflection Namespace


LocationInfo Constructor (PropertyInfo)

LocationInfo Constructor (PropertyInfo)
Initializes a new LocationInfo from a PropertyInfo.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LocationInfo(
    PropertyInfo propertyInfo
)

Parameters

propertyInfo
Type: System.ReflectionPropertyInfo
The property represented by the LocationInfo.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
LocationInfo Overload
PostSharp.Reflection Namespace


LocationInfo Methods

LocationInfo Methods

The LocationInfo type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Overrides ObjectEquals(Object).)
Public method | Equals(LocationInfo) | Indicates whether the current object is equal to another object of the same type.
Public method | GetHashCode | Serves as a hash function for a particular type. (Overrides ObjectGetHashCode.)
Public method | GetValue(Object) | Returns the value of the field or property represented by the current object.
Public method | GetValue(Object, Object) | Returns the value of the field or property represented by the current object with optional index values for indexed properties.
Public method | SetValue(Object, Object) | Sets the value of the field or property represented by the current object to a given value.
Public method | SetValue(Object, Object, Object) | Sets the value of the field or property represented by the current object to a given value with optional index values for indexed properties.
 | ToLocationInfo | Initializes a new LocationInfo from a FieldInfo, PropertyInfo, or ParameterInfo.
 | ToLocationInfoArray(ICollectionFieldInfo) | Converts a collection of FieldInfo into an array of LocationInfo.
 | ToLocationInfoArray(ICollectionParameterInfo) | Converts a collection of ParameterInfo into an array of LocationInfo.
 | ToLocationInfoArray(ICollectionPropertyInfo) | Converts a collection of PropertyInfo into an array of LocationInfo.
Public method | ToString | Returns a string that represents the current object. (Overrides ObjectToString.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.Equals Method

LocationInfoEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Overrides ObjectEquals(Object).)
Public method | Equals(LocationInfo) | Indicates whether the current object is equal to another object of the same type.
Top
See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.Equals Method (Object)

LocationInfoEquals Method (Object)
Determines whether the specified Object is equal to the current Object.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool Equals(
    Object obj
)

Parameters

obj
Type: SystemObject
The object to compare with the current object.

Return Value

Type: Boolean
true if the specified object is equal to the current object; otherwise, false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
Equals Overload
PostSharp.Reflection Namespace


LocationInfo.Equals Method (LocationInfo)

LocationInfoEquals Method (LocationInfo)
Indicates whether the current object is equal to another object of the same type.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Equals(
    LocationInfo other
)

Parameters

other
Type: PostSharp.ReflectionLocationInfo
An object to compare with this object.

Return Value

Type: Boolean
true if the current object is equal to the other parameter; otherwise, false.

Implements

IEquatableTEquals(T)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
Equals Overload
PostSharp.Reflection Namespace


LocationInfo.GetHashCode Method

LocationInfoGetHashCode Method
Serves as a hash function for a particular type.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int GetHashCode()

Return Value

Type: Int32
A hash code for the current Object.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.GetValue Method

LocationInfoGetValue Method
Overload List
 | Name | Description
Public method | GetValue(Object) | Returns the value of the field or property represented by the current object.
Public method | GetValue(Object, Object) | Returns the value of the field or property represented by the current object with optional index values for indexed properties.
Top
See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.GetValue Method (Object)

LocationInfoGetValue Method (Object)
Returns the value of the field or property represented by the current object.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object GetValue(
    Object instance
)

Parameters

instance
Type: SystemObject
The object whose field or property value will be returned (null if the field or property is static).

Return Value

Type: Object
The value of the field or property.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
GetValue Overload
PostSharp.Reflection Namespace


LocationInfo.GetValue Method (Object, Object[])

LocationInfoGetValue Method (Object, Object)
Returns the value of the field or property represented by the current object with optional index values for indexed properties.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object GetValue(
    Object instance,
    Object[] index
)

Parameters

instance
Type: SystemObject
The object whose field or property value will be returned (null if the field or property is static).
index
Type: SystemObject
Optional index values for indexed properties. null for fields or non-index properties.

Return Value

Type: Object
The value of the field or property.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
GetValue Overload
PostSharp.Reflection Namespace


LocationInfo.SetValue Method

LocationInfoSetValue Method
Overload List
 | Name | Description
Public method | SetValue(Object, Object) | Sets the value of the field or property represented by the current object to a given value.
Public method | SetValue(Object, Object, Object) | Sets the value of the field or property represented by the current object to a given value with optional index values for indexed properties.
Top
See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.SetValue Method (Object, Object)

LocationInfoSetValue Method (Object, Object)
Sets the value of the field or property represented by the current object to a given value.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void SetValue(
    Object instance,
    Object value
)

Parameters

instance
Type: SystemObject
The object whose field or property value will be changed (null if the field or property is static).
value
Type: SystemObject
New value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
SetValue Overload
PostSharp.Reflection Namespace


LocationInfo.SetValue Method (Object, Object, Object[])

LocationInfoSetValue Method (Object, Object, Object)
Sets the value of the field or property represented by the current object to a given value with optional index values for indexed properties.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void SetValue(
    Object instance,
    Object value,
    Object[] index
)

Parameters

instance
Type: SystemObject
The object whose field or property value will be changed (null if the field or property is static).
value
Type: SystemObject
New value.
index
Type: SystemObject
Optional index values for indexed properties. null for fields or non-index properties.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
SetValue Overload
PostSharp.Reflection Namespace


LocationInfo.ToLocationInfo Method

LocationInfoToLocationInfo Method
Initializes a new LocationInfo from a FieldInfo, PropertyInfo, or ParameterInfo.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static LocationInfo ToLocationInfo(
    Object reflectionInfo
)

Parameters

reflectionInfo
Type: SystemObject

Return Value

Type: LocationInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.ToLocationInfoArray Method

LocationInfoToLocationInfoArray Method
Overload List
Name | Description
ToLocationInfoArray(ICollectionFieldInfo) | Converts a collection of FieldInfo into an array of LocationInfo.
ToLocationInfoArray(ICollectionParameterInfo) | Converts a collection of ParameterInfo into an array of LocationInfo.
ToLocationInfoArray(ICollectionPropertyInfo) | Converts a collection of PropertyInfo into an array of LocationInfo.
Top
See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.ToLocationInfoArray Method (ICollection(FieldInfo))

LocationInfoToLocationInfoArray Method (ICollectionFieldInfo)
Converts a collection of FieldInfo into an array of LocationInfo.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static LocationInfo[] ToLocationInfoArray(
    ICollection<FieldInfo> fields
)

Parameters

fields
Type: System.Collections.GenericICollection FieldInfo
A collection of FieldInfo.

Return Value

Type: LocationInfo
An array of LocationInfo.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
ToLocationInfoArray Overload
PostSharp.Reflection Namespace


LocationInfo.ToLocationInfoArray Method (ICollection(ParameterInfo))

LocationInfoToLocationInfoArray Method (ICollectionParameterInfo)
Converts a collection of ParameterInfo into an array of LocationInfo.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static LocationInfo[] ToLocationInfoArray(
    ICollection<ParameterInfo> parameters
)

Parameters

parameters
Type: System.Collections.GenericICollection ParameterInfo
A collection of ParameterInfo.

Return Value

Type: LocationInfo
An array of LocationInfo.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
ToLocationInfoArray Overload
PostSharp.Reflection Namespace


LocationInfo.ToLocationInfoArray Method (ICollection(PropertyInfo))

LocationInfoToLocationInfoArray Method (ICollectionPropertyInfo)
Converts a collection of PropertyInfo into an array of LocationInfo.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static LocationInfo[] ToLocationInfoArray(
    ICollection<PropertyInfo> properties
)

Parameters

properties
Type: System.Collections.GenericICollection PropertyInfo
A collection of PropertyInfo.

Return Value

Type: LocationInfo
An array of LocationInfo.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
ToLocationInfoArray Overload
PostSharp.Reflection Namespace


LocationInfo.ToString Method

LocationInfoToString Method
Returns a string that represents the current object.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override string ToString()

Return Value

Type: String
A string that represents the current object.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo Operators

LocationInfo Operators

The LocationInfo type exposes the following members.

Operators
Name | Description
Equality | Determines whether two instances of LocationInfo represent the same element of code.
Inequality | Determines whether two instances of LocationInfo represent different elements of code.
Top
See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.Equality Operator

LocationInfoEquality Operator
Determines whether two instances of LocationInfo represent the same element of code.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator ==(
    LocationInfo left,
    LocationInfo right
)

Parameters

left
Type: PostSharp.ReflectionLocationInfo
A LocationInfo.
right
Type: PostSharp.ReflectionLocationInfo
A LocationInfo.

Return Value

Type: Boolean
true if left and right are equal, otherwise false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.Inequality Operator

LocationInfoInequality Operator
Determines whether two instances of LocationInfo represent different elements of code.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator !=(
    LocationInfo left,
    LocationInfo right
)

Parameters

left
Type: PostSharp.ReflectionLocationInfo
A LocationInfo.
right
Type: PostSharp.ReflectionLocationInfo
A LocationInfo.

Return Value

Type: Boolean
true if left and right are different, otherwise false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo Properties

LocationInfo Properties

The LocationInfo type exposes the following members.

Properties
 | Name | Description
Public property | DeclaringType | Gets the declaring type of the underlying field, property, parameter, or return value.
Public property | FieldInfo | Gets the underlying FieldInfo, or null if the underlying code element is not a property.
Public property | IsStatic | Determines whether the underlying field or property is static.
Public property | LocationKind | Gets the location kind (Field, Property, Parameter or ReturnValue).
Public property | LocationType | Gets the type of values that can be stored in the location.
Public property | Name | Gets the name of the underlying field, property, parameter, or return value.
Public property | ParameterInfo | Gets the underlying ParameterInfo, or null if the underlying code element is not a property.
Public property | PropertyInfo | Gets the underlying PropertyInfo, or null if the underlying code element is not a property.
Top
See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.DeclaringType Property

LocationInfoDeclaringType Property
Gets the declaring type of the underlying field, property, parameter, or return value.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type DeclaringType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.FieldInfo Property

LocationInfoFieldInfo Property
Gets the underlying FieldInfo, or null if the underlying code element is not a property.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public FieldInfo FieldInfo { get; }

Property Value

Type: FieldInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.IsStatic Property

LocationInfoIsStatic Property
Determines whether the underlying field or property is static.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsStatic { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.LocationKind Property

LocationInfoLocationKind Property
Gets the location kind (Field, Property, Parameter or ReturnValue).

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public LocationKind LocationKind { get; }

Property Value

Type: LocationKind
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.LocationType Property

LocationInfoLocationType Property
Gets the type of values that can be stored in the location.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type LocationType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.Name Property

LocationInfoName Property
Gets the name of the underlying field, property, parameter, or return value.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Name { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.ParameterInfo Property

LocationInfoParameterInfo Property
Gets the underlying ParameterInfo, or null if the underlying code element is not a property.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ParameterInfo ParameterInfo { get; }

Property Value

Type: ParameterInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationInfo.PropertyInfo Property

LocationInfoPropertyInfo Property
Gets the underlying PropertyInfo, or null if the underlying code element is not a property.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PropertyInfo PropertyInfo { get; }

Property Value

Type: PropertyInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

LocationInfo Class
PostSharp.Reflection Namespace


LocationKind Enumeration

LocationKind Enumeration
Enumerates the kinds of code elements that can be encapsulated by a LocationInfo.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum LocationKind
Members
Member name | Value | Description
Field | 0 | FieldInfo.
Property | 1 | PropertyInfo.
Parameter | 2 | A ParameterInfo representing a parameter (not a ReturnValue).
ReturnValue | 3 | A ParameterInfo representing a return value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


MemberTypeCodeReference Class

MemberTypeCodeReference Class
Represents a relationship between a type and a member of this type. A member can be a FieldInfo, PropertyInfo, or ParameterInfo.
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionMemberTypeCodeReference

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class MemberTypeCodeReference : ICodeReference

The MemberTypeCodeReference type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Member | Gets the member (FieldInfo, PropertyInfo, or ParameterInfo).
Public property | Type | Gets the member type.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


MemberTypeCodeReference Methods

MemberTypeCodeReference Methods

The MemberTypeCodeReference type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MemberTypeCodeReference Class
PostSharp.Reflection Namespace


MemberTypeCodeReference Properties

MemberTypeCodeReference Properties

The MemberTypeCodeReference type exposes the following members.

Properties
 | Name | Description
Public property | Member | Gets the member (FieldInfo, PropertyInfo, or ParameterInfo).
Public property | Type | Gets the member type.
Top
See Also

Reference

MemberTypeCodeReference Class
PostSharp.Reflection Namespace


MemberTypeCodeReference.Member Property

MemberTypeCodeReferenceMember Property
Gets the member (FieldInfo, PropertyInfo, or ParameterInfo).

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Member { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MemberTypeCodeReference Class
PostSharp.Reflection Namespace


MemberTypeCodeReference.Type Property

MemberTypeCodeReferenceType Property
Gets the member type.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type Type { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MemberTypeCodeReference Class
PostSharp.Reflection Namespace


MethodUsageCodeReference Class

MethodUsageCodeReference Class
Represents a relationship between a declaration (Type, FieldInfo, MethodInfo or ConstructorInfo) and a method whose instructions (method body) use the declaration.
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionMethodUsageCodeReference

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class MethodUsageCodeReference : ICodeReference

The MethodUsageCodeReference type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Instructions | Gets the instructions that reference UsedDeclaration.
Public property | UsedDeclaration | Gets the declaration (Type, MethodInfo or ConstructorInfo) used by the method.
Public property | UsedType | Gets the Type used by the method. If the current object represents a reference to a MethodInfo or ConstructorInfo, this property returns the declaring type of the method or constructor.
Public property | UsingMethod | Gets the method (MethodInfo or ConstructorInfo) whose body uses the declaration.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


MethodUsageCodeReference Methods

MethodUsageCodeReference Methods

The MethodUsageCodeReference type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

MethodUsageCodeReference Class
PostSharp.Reflection Namespace


MethodUsageCodeReference Properties

MethodUsageCodeReference Properties

The MethodUsageCodeReference type exposes the following members.

Properties
 | Name | Description
Public property | Instructions | Gets the instructions that reference UsedDeclaration.
Public property | UsedDeclaration | Gets the declaration (Type, MethodInfo or ConstructorInfo) used by the method.
Public property | UsedType | Gets the Type used by the method. If the current object represents a reference to a MethodInfo or ConstructorInfo, this property returns the declaring type of the method or constructor.
Public property | UsingMethod | Gets the method (MethodInfo or ConstructorInfo) whose body uses the declaration.
Top
See Also

Reference

MethodUsageCodeReference Class
PostSharp.Reflection Namespace


MethodUsageCodeReference.Instructions Property

MethodUsageCodeReferenceInstructions Property
Gets the instructions that reference UsedDeclaration.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MethodUsageInstructions Instructions { get; }

Property Value

Type: MethodUsageInstructions
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodUsageCodeReference Class
PostSharp.Reflection Namespace


MethodUsageCodeReference.UsedDeclaration Property

MethodUsageCodeReferenceUsedDeclaration Property
Gets the declaration (Type, MethodInfo or ConstructorInfo) used by the method.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MemberInfo UsedDeclaration { get; }

Property Value

Type: MemberInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodUsageCodeReference Class
PostSharp.Reflection Namespace


MethodUsageCodeReference.UsedType Property

MethodUsageCodeReferenceUsedType Property
Gets the Type used by the method. If the current object represents a reference to a MethodInfo or ConstructorInfo, this property returns the declaring type of the method or constructor.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type UsedType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodUsageCodeReference Class
PostSharp.Reflection Namespace


MethodUsageCodeReference.UsingMethod Property

MethodUsageCodeReferenceUsingMethod Property
Gets the method (MethodInfo or ConstructorInfo) whose body uses the declaration.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public MethodBase UsingMethod { get; }

Property Value

Type: MethodBase
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

MethodUsageCodeReference Class
PostSharp.Reflection Namespace


MethodUsageInstructions Enumeration

MethodUsageInstructions Enumeration
Instructions whose operands can reference a declaration.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[FlagsAttribute]
public enum MethodUsageInstructions
Members
Member name | Value | Description
None | 0 | No instruction.
LoadField | 1 | Get field value.
StoreField | 2 | Set field value.
Call | 4 | Call to a static or sealed method.
CallVirtual | 8 | Call to a virtual method.
NewObject | 16 | Creation of a new instance (invoke the constructor).
LoadFieldAddress | 32 | Get field address.
LoadMetadata | 64 | Load the metadata token (for instance typeof).
LoadMethodAddress | 128 | Load the address of a static or sealed method (delegate instantiation).
LoadMethodAddressVirtual | 256 | Load the address of a virtual method (delegate instantiation).
Cast | 512 | Type casting.
IsInstance | 1024 | "Safe" type casting (as or is in C#).
SizeOf | 2048 | Get the size of a value type (sizeof in C#).
NewArray | 4096 | Create a new array of a type.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace
PostSharp.ReflectionMethodUsageCodeReference


ObjectConstruction Class

ObjectConstruction Class
Specifies how an object should be constructed, i.e. specifies the constructor to be used, the arguments to be passed to this constructor, and the fields or properties to be set.
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionObjectConstruction

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ObjectConstruction

The ObjectConstruction type exposes the following members.

Constructors
 | Name | Description
Public method | ObjectConstruction(CustomAttributeData) | Initializes a new type-safe ObjectConstruction from a CustomAttributeData
Public method | ObjectConstruction(ConstructorInfo, Object) | Initializes a new type-safe ObjectConstruction from a ConstructorInfo.
Public method | ObjectConstruction(String, Object) | Initializes a new ObjectConstruction by specifying a type name and a list of constructor arguments.
Public method | ObjectConstruction(Type, Object) | Initializes a new ObjectConstruction by specifying a type name and a list of constructor arguments.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Constructor | Gets the custom attribute constructor.
Public property | ConstructorArguments | Gets the arguments passed to the custom attribute constructor.
Public property | NamedArguments | Gets the collection of named arguments.
Public property | TypeName | Gets the assembly-qualified type name of the object.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


ObjectConstruction Constructor

ObjectConstruction Constructor
Overload List
 | Name | Description
Public method | ObjectConstruction(CustomAttributeData) | Initializes a new type-safe ObjectConstruction from a CustomAttributeData
Public method | ObjectConstruction(ConstructorInfo, Object) | Initializes a new type-safe ObjectConstruction from a ConstructorInfo.
Public method | ObjectConstruction(String, Object) | Initializes a new ObjectConstruction by specifying a type name and a list of constructor arguments.
Public method | ObjectConstruction(Type, Object) | Initializes a new ObjectConstruction by specifying a type name and a list of constructor arguments.
Top
See Also

Reference

ObjectConstruction Class
PostSharp.Reflection Namespace


ObjectConstruction Constructor (CustomAttributeData)

ObjectConstruction Constructor (CustomAttributeData)
Initializes a new type-safe ObjectConstruction from a CustomAttributeData

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectConstruction(
    CustomAttributeData customAttributeData
)

Parameters

customAttributeData
Type: System.ReflectionCustomAttributeData
A CustomAttributeData
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ObjectConstruction Class
ObjectConstruction Overload
PostSharp.Reflection Namespace


ObjectConstruction Constructor (ConstructorInfo, Object[])

ObjectConstruction Constructor (ConstructorInfo, Object)
Initializes a new type-safe ObjectConstruction from a ConstructorInfo.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectConstruction(
    ConstructorInfo constructor,
    params Object[] constructorArguments
)

Parameters

constructor
Type: System.ReflectionConstructorInfo
Constructor.
constructorArguments
Type: SystemObject
Arguments passed to the constructor.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ObjectConstruction Class
ObjectConstruction Overload
PostSharp.Reflection Namespace


ObjectConstruction Constructor (String, Object[])

ObjectConstruction Constructor (String, Object)
Initializes a new ObjectConstruction by specifying a type name and a list of constructor arguments.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectConstruction(
    string typeName,
    params Object[] constructorArguments
)

Parameters

typeName
Type: SystemString
Name of the object type.
constructorArguments
Type: SystemObject
Arguments passed to the constructor.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ObjectConstruction Class
ObjectConstruction Overload
PostSharp.Reflection Namespace


ObjectConstruction Constructor (Type, Object[])

ObjectConstruction Constructor (Type, Object)
Initializes a new ObjectConstruction by specifying a type name and a list of constructor arguments.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObjectConstruction(
    Type type,
    params Object[] constructorArguments
)

Parameters

type
Type: SystemType
Object type.
constructorArguments
Type: SystemObject
Arguments passed to the constructor.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ObjectConstruction Class
ObjectConstruction Overload
PostSharp.Reflection Namespace


ObjectConstruction Methods

ObjectConstruction Methods

The ObjectConstruction type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ObjectConstruction Class
PostSharp.Reflection Namespace


ObjectConstruction Properties

ObjectConstruction Properties

The ObjectConstruction type exposes the following members.

Properties
 | Name | Description
Public property | Constructor | Gets the custom attribute constructor.
Public property | ConstructorArguments | Gets the arguments passed to the custom attribute constructor.
Public property | NamedArguments | Gets the collection of named arguments.
Public property | TypeName | Gets the assembly-qualified type name of the object.
Top
See Also

Reference

ObjectConstruction Class
PostSharp.Reflection Namespace


ObjectConstruction.Constructor Property

ObjectConstructionConstructor Property
Gets the custom attribute constructor.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ConstructorInfo Constructor { get; }

Property Value

Type: ConstructorInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ObjectConstruction Class
PostSharp.Reflection Namespace


ObjectConstruction.ConstructorArguments Property

ObjectConstructionConstructorArguments Property
Gets the arguments passed to the custom attribute constructor.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IList<Object> ConstructorArguments { get; }

Property Value

Type: IList Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ObjectConstruction Class
PostSharp.Reflection Namespace


ObjectConstruction.NamedArguments Property

ObjectConstructionNamedArguments Property
Gets the collection of named arguments.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IDictionary<string, Object> NamedArguments { get; }

Property Value

Type: IDictionary String, Object
Remarks
This collection is a dictionary associating the name of public a field or property of the custom attributes to the value that should be assigned to it.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ObjectConstruction Class
PostSharp.Reflection Namespace


ObjectConstruction.TypeName Property

ObjectConstructionTypeName Property
Gets the assembly-qualified type name of the object.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string TypeName { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ObjectConstruction Class
PostSharp.Reflection Namespace


ReflectionExtensions Class

ReflectionExtensions Class
Provides utility methods to work with the System.Reflection namespace.
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionReflectionExtensions

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class ReflectionExtensions

The ReflectionExtensions type exposes the following members.

Methods
Name | Description
GetAutomaticProperty(FieldInfo) | Gets the PropertyInfo whose a given field is the backing field from the current type or base types.
GetAutomaticProperty(FieldInfo, Boolean) | Gets the PropertyInfo whose a given field is the backing field and specifies whether base types should be considered.
GetBackingField | Gets the backing field of a given property.
GetStateMachineKind | Gets the kind of state machine (typically Async, Enumerable or None) that implements a given method.
IsAutomaticProperty | Determines whether a given property is an automatic property.
Top
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Reflection Namespace


ReflectionExtensions Methods

ReflectionExtensions Methods

The ReflectionExtensions type exposes the following members.

Methods
Name | Description
GetAutomaticProperty(FieldInfo) | Gets the PropertyInfo whose a given field is the backing field from the current type or base types.
GetAutomaticProperty(FieldInfo, Boolean) | Gets the PropertyInfo whose a given field is the backing field and specifies whether base types should be considered.
GetBackingField | Gets the backing field of a given property.
GetStateMachineKind | Gets the kind of state machine (typically Async, Enumerable or None) that implements a given method.
IsAutomaticProperty | Determines whether a given property is an automatic property.
Top
See Also

Reference

ReflectionExtensions Class
PostSharp.Reflection Namespace


ReflectionExtensions.GetAutomaticProperty Method

ReflectionExtensionsGetAutomaticProperty Method
Overload List
Name | Description
GetAutomaticProperty(FieldInfo) | Gets the PropertyInfo whose a given field is the backing field from the current type or base types.
GetAutomaticProperty(FieldInfo, Boolean) | Gets the PropertyInfo whose a given field is the backing field and specifies whether base types should be considered.
Top
See Also

Reference

ReflectionExtensions Class
PostSharp.Reflection Namespace


ReflectionExtensions.GetAutomaticProperty Method (FieldInfo)

ReflectionExtensionsGetAutomaticProperty Method (FieldInfo)
Gets the PropertyInfo whose a given field is the backing field from the current type or base types.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static PropertyInfo GetAutomaticProperty(
    this FieldInfo field
)

Parameters

field
Type: System.ReflectionFieldInfo
A field.

Return Value

Type: PropertyInfo
The PropertyInfo representing the property whose field is the backing field, or null if field is not the backing field of an automatic property.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type FieldInfo. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReflectionExtensions Class
GetAutomaticProperty Overload
PostSharp.Reflection Namespace


ReflectionExtensions.GetAutomaticProperty Method (FieldInfo, Boolean)

ReflectionExtensionsGetAutomaticProperty Method (FieldInfo, Boolean)
Gets the PropertyInfo whose a given field is the backing field and specifies whether base types should be considered.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static PropertyInfo GetAutomaticProperty(
    this FieldInfo field,
    bool inherit
)

Parameters

field
Type: System.ReflectionFieldInfo
A field.
inherit
Type: SystemBoolean
true if the property should be looked for in the base, otherwise false.

Return Value

Type: PropertyInfo
The PropertyInfo representing the property whose field is the backing field, or null if field is not the backing field of an automatic property.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type FieldInfo. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReflectionExtensions Class
GetAutomaticProperty Overload
PostSharp.Reflection Namespace


ReflectionExtensions.GetBackingField Method

ReflectionExtensionsGetBackingField Method
Gets the backing field of a given property.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static FieldInfo GetBackingField(
    this PropertyInfo propertyInfo
)

Parameters

propertyInfo
Type: System.ReflectionPropertyInfo
A property.

Return Value

Type: FieldInfo
The FieldInfo representing the backing field of propertyInfo, or null if propertyInfo is not an automatic property.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type PropertyInfo. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReflectionExtensions Class
PostSharp.Reflection Namespace


ReflectionExtensions.GetStateMachineKind Method

ReflectionExtensionsGetStateMachineKind Method
Gets the kind of state machine (typically Async, Enumerable or None) that implements a given method.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static StateMachineKind GetStateMachineKind(
    this MethodInfo method
)

Parameters

method
Type: System.ReflectionMethodInfo
A method.

Return Value

Type: StateMachineKind
A StateMachineKind value, or None if method is not implemented by a state machine.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type MethodInfo. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReflectionExtensions Class
PostSharp.Reflection Namespace


ReflectionExtensions.IsAutomaticProperty Method

ReflectionExtensionsIsAutomaticProperty Method
Determines whether a given property is an automatic property.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool IsAutomaticProperty(
    this PropertyInfo propertyInfo
)

Parameters

propertyInfo
Type: System.ReflectionPropertyInfo
A property.

Return Value

Type: Boolean
true if propertyInfo represents an automatic property, otherwise false.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type PropertyInfo. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReflectionExtensions Class
PostSharp.Reflection Namespace


ReflectionHelper Class

ReflectionHelper Class
Provides helper methods for work with System.Reflection.
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionReflectionHelper

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class ReflectionHelper

The ReflectionHelper type exposes the following members.

Methods
Name | Description
AreInternalsVisibleTo | Determines whether the InternalsVisibleToAttribute attribute relationship exists between two assemblies.
GetEvent |
GetLocation |
GetProperty(Type, MethodInfo, MethodInfo) |
GetProperty(Type, MethodInfo, MethodInfo, Boolean) |
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


ReflectionHelper Methods

ReflectionHelper Methods

The ReflectionHelper type exposes the following members.

Methods
Name | Description
AreInternalsVisibleTo | Determines whether the InternalsVisibleToAttribute attribute relationship exists between two assemblies.
GetEvent |
GetLocation |
GetProperty(Type, MethodInfo, MethodInfo) |
GetProperty(Type, MethodInfo, MethodInfo, Boolean) |
Top
See Also

Reference

ReflectionHelper Class
PostSharp.Reflection Namespace


ReflectionHelper.AreInternalsVisibleTo Method

ReflectionHelperAreInternalsVisibleTo Method
Determines whether the InternalsVisibleToAttribute attribute relationship exists between two assemblies.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool AreInternalsVisibleTo(
    Assembly definingAssembly,
    Assembly referencingAssembly
)

Parameters

definingAssembly
Type: System.ReflectionAssembly
The assembly defining the InternalsVisibleToAttribute attribute.
referencingAssembly
Type: System.ReflectionAssembly
The assembly referenced by the InternalsVisibleToAttribute attribute.

Return Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReflectionHelper Class
PostSharp.Reflection Namespace


ReflectionHelper.GetEvent Method

ReflectionHelperGetEvent Method

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static EventInfo GetEvent(
    Type declaringType,
    MethodInfo addMethod,
    MethodInfo removeMethod,
    MethodInfo raiseMethod
)

Parameters

declaringType
Type: SystemType
addMethod
Type: System.ReflectionMethodInfo
removeMethod
Type: System.ReflectionMethodInfo
raiseMethod
Type: System.ReflectionMethodInfo

Return Value

Type: EventInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionHelper Class
PostSharp.Reflection Namespace


ReflectionHelper.GetLocation Method

ReflectionHelperGetLocation Method

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static LocationInfo GetLocation(
    Type declaringType,
    MethodInfo getter,
    MethodInfo setter
)

Parameters

declaringType
Type: SystemType
getter
Type: System.ReflectionMethodInfo
setter
Type: System.ReflectionMethodInfo

Return Value

Type: LocationInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionHelper Class
PostSharp.Reflection Namespace


ReflectionHelper.GetProperty Method

ReflectionHelperGetProperty Method
Overload List
Name | Description
GetProperty(Type, MethodInfo, MethodInfo) |
GetProperty(Type, MethodInfo, MethodInfo, Boolean) |
Top
See Also

Reference

ReflectionHelper Class
PostSharp.Reflection Namespace


ReflectionHelper.GetProperty Method (Type, MethodInfo, MethodInfo)

ReflectionHelperGetProperty Method (Type, MethodInfo, MethodInfo)

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static PropertyInfo GetProperty(
    Type declaringType,
    MethodInfo getter,
    MethodInfo setter
)

Parameters

declaringType
Type: SystemType
getter
Type: System.ReflectionMethodInfo
setter
Type: System.ReflectionMethodInfo

Return Value

Type: PropertyInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionHelper Class
GetProperty Overload
PostSharp.Reflection Namespace


ReflectionHelper.GetProperty Method (Type, MethodInfo, MethodInfo, Boolean)

ReflectionHelperGetProperty Method (Type, MethodInfo, MethodInfo, Boolean)

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static PropertyInfo GetProperty(
    Type declaringType,
    MethodInfo getter,
    MethodInfo setter,
    bool throwOnMissingMember
)

Parameters

declaringType
Type: SystemType
getter
Type: System.ReflectionMethodInfo
setter
Type: System.ReflectionMethodInfo
throwOnMissingMember
Type: SystemBoolean

Return Value

Type: PropertyInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionHelper Class
GetProperty Overload
PostSharp.Reflection Namespace


ReflectionSearch Class

ReflectionSearch Class
Set of static methods providing broader access to assembly metadata than the System.Reflection namespace. These methods are only available at build time.
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionReflectionSearch

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class ReflectionSearch

The ReflectionSearch type exposes the following members.

Methods
Name | Description
GetCustomAttributesOfType(Type) | Gets all custom attributes of a given type in the assembly being currently processed.
GetCustomAttributesOfType(Type, ReflectionSearchOptions) | Gets all custom attributes of a given type in the assembly being currently processed and specifies additional options.
GetCustomAttributesOnTarget(Object) | Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute.
GetCustomAttributesOnTarget(Object, ReflectionSearchOptions) | Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute and specifies additional options.
GetCustomAttributesOnTargetT(Object, ReflectionSearchOptions) | Gets all custom attributes of a given type on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute and specifies additional options.
GetDeclarationsUsedByMethod(MethodBase) | Gets all declarations (Type, FieldInfo, MethodInfo or ConstructorInfo) used by the body of a given method or constructor.
GetDeclarationsUsedByMethod(MethodBase, ReflectionSearchOptions) | Gets all declarations (Type, FieldInfo, MethodInfo or ConstructorInfo) used by the body of a given method or constructor and specifies additional options.
GetDerivedTypes(Type) | Gets the set of types derived from a given class or implementing a given interface.
GetDerivedTypes(Type, ReflectionSearchOptions) | Gets the set of types derived from a given class or implementing a given interface. and specifies additional options.
GetMembersOfType(Type) | Gets all members (FieldInfo, PropertyInfo, or ParameterInfo) of the assembly being processed of a given type.
GetMembersOfType(Type, ReflectionSearchOptions) | Gets all members (FieldInfo, PropertyInfo, or ParameterInfo) of the assembly being processed of a given type and specifies additional options.
GetMethodsUsingDeclaration(MemberInfo) | Gets the set of methods and constructors whose body references a given (Type, FieldInfo, MethodInfo or ConstructorInfo).
GetMethodsUsingDeclaration(MemberInfo, ReflectionSearchOptions) | Gets the set of methods and constructors whose body references a given (Type, FieldInfo, MethodInfo or ConstructorInfo) and specifies whether reflection wrappers should be used instead of runtime reflection objects.
HasCustomAttribute | Determines whether a declaration has a custom attribute of a given type, including those who have been added indirectly, for instance through MulticastAttribute.
Top
Remarks

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


ReflectionSearch Methods

ReflectionSearch Methods

The ReflectionSearch type exposes the following members.

Methods
Name | Description
GetCustomAttributesOfType(Type) | Gets all custom attributes of a given type in the assembly being currently processed.
GetCustomAttributesOfType(Type, ReflectionSearchOptions) | Gets all custom attributes of a given type in the assembly being currently processed and specifies additional options.
GetCustomAttributesOnTarget(Object) | Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute.
GetCustomAttributesOnTarget(Object, ReflectionSearchOptions) | Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute and specifies additional options.
GetCustomAttributesOnTargetT(Object, ReflectionSearchOptions) | Gets all custom attributes of a given type on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute and specifies additional options.
GetDeclarationsUsedByMethod(MethodBase) | Gets all declarations (Type, FieldInfo, MethodInfo or ConstructorInfo) used by the body of a given method or constructor.
GetDeclarationsUsedByMethod(MethodBase, ReflectionSearchOptions) | Gets all declarations (Type, FieldInfo, MethodInfo or ConstructorInfo) used by the body of a given method or constructor and specifies additional options.
GetDerivedTypes(Type) | Gets the set of types derived from a given class or implementing a given interface.
GetDerivedTypes(Type, ReflectionSearchOptions) | Gets the set of types derived from a given class or implementing a given interface. and specifies additional options.
GetMembersOfType(Type) | Gets all members (FieldInfo, PropertyInfo, or ParameterInfo) of the assembly being processed of a given type.
GetMembersOfType(Type, ReflectionSearchOptions) | Gets all members (FieldInfo, PropertyInfo, or ParameterInfo) of the assembly being processed of a given type and specifies additional options.
GetMethodsUsingDeclaration(MemberInfo) | Gets the set of methods and constructors whose body references a given (Type, FieldInfo, MethodInfo or ConstructorInfo).
GetMethodsUsingDeclaration(MemberInfo, ReflectionSearchOptions) | Gets the set of methods and constructors whose body references a given (Type, FieldInfo, MethodInfo or ConstructorInfo) and specifies whether reflection wrappers should be used instead of runtime reflection objects.
HasCustomAttribute | Determines whether a declaration has a custom attribute of a given type, including those who have been added indirectly, for instance through MulticastAttribute.
Top
See Also

Reference

ReflectionSearch Class
PostSharp.Reflection Namespace


ReflectionSearch.GetCustomAttributesOfType Method

ReflectionSearchGetCustomAttributesOfType Method
Overload List
Name | Description
GetCustomAttributesOfType(Type) | Gets all custom attributes of a given type in the assembly being currently processed.
GetCustomAttributesOfType(Type, ReflectionSearchOptions) | Gets all custom attributes of a given type in the assembly being currently processed and specifies additional options.
Top
See Also

Reference

ReflectionSearch Class
PostSharp.Reflection Namespace


ReflectionSearch.GetCustomAttributesOfType Method (Type)

ReflectionSearchGetCustomAttributesOfType Method (Type)
Gets all custom attributes of a given type in the assembly being currently processed.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static CustomAttributeInstance[] GetCustomAttributesOfType(
    Type customAttributeType
)

Parameters

customAttributeType
Type: SystemType
Type of the custom attribute.

Return Value

Type: CustomAttributeInstance
The set of all custom attributes of type customAttributeType defined in the assembly being currently processed.
Remarks

Note Note
This method returns custom attributes from the internal annotation repository of PostSharp. This repository contains more than only custom attributes added in source code. For instance, if you use MulticastAttribute to add a custom attribute to several elements of code in a single line of code, this method will return one custom attribute instance for every target of the MulticastAttribute .

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetCustomAttributesOfType Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetCustomAttributesOfType Method (Type, ReflectionSearchOptions)

ReflectionSearchGetCustomAttributesOfType Method (Type, ReflectionSearchOptions)
Gets all custom attributes of a given type in the assembly being currently processed and specifies additional options.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static CustomAttributeInstance[] GetCustomAttributesOfType(
    Type customAttributeType,
    ReflectionSearchOptions options
)

Parameters

customAttributeType
Type: SystemType
Type of the custom attribute.
options
Type: PostSharp.ReflectionReflectionSearchOptions
Any combination of options IncludeDerivedTypes and UseReflectionWrappers.

Return Value

Type: CustomAttributeInstance
The set of all custom attributes of type customAttributeType (or any type derived from customAttributeType, if the option IncludeDerivedTypes is true) defined in the assembly being currently processed.
Remarks

Note Note
This method returns custom attributes from the internal annotation repository of PostSharp. This repository contains more than only custom attributes added in source code. For instance, if you use MulticastAttribute to add a custom attribute to several elements of code in a single line of code, this method will return one custom attribute instance for every target of the MulticastAttribute .

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetCustomAttributesOfType Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetCustomAttributesOnTarget Method

ReflectionSearchGetCustomAttributesOnTarget Method
Overload List
Name | Description
GetCustomAttributesOnTarget(Object) | Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute.
GetCustomAttributesOnTarget(Object, ReflectionSearchOptions) | Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute and specifies additional options.
GetCustomAttributesOnTargetT(Object, ReflectionSearchOptions) | Gets all custom attributes of a given type on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute and specifies additional options.
Top
See Also

Reference

ReflectionSearch Class
PostSharp.Reflection Namespace


ReflectionSearch.GetCustomAttributesOnTarget Method (Object)

ReflectionSearchGetCustomAttributesOnTarget Method (Object)
Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static CustomAttributeInstance[] GetCustomAttributesOnTarget(
    Object target
)

Parameters

target
Type: SystemObject
Element of code (Type, MethodInfo, ...) whose custom attributes are requested.

Return Value

Type: CustomAttributeInstance
The set of all custom attributes added, directly or indirectly, to target.
Remarks

Note Note
This method returns custom attributes from the internal annotation repository of PostSharp. This repository contains more than only custom attributes added in source code. For instance, if you use MulticastAttribute to add a custom attribute to several elements of code in a single line of code, this method will return one custom attribute instance for every target of the MulticastAttribute .

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetCustomAttributesOnTarget Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetCustomAttributesOnTarget Method (Object, ReflectionSearchOptions)

ReflectionSearchGetCustomAttributesOnTarget Method (Object, ReflectionSearchOptions)
Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute and specifies additional options.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static CustomAttributeInstance[] GetCustomAttributesOnTarget(
    Object target,
    ReflectionSearchOptions options
)

Parameters

target
Type: SystemObject
Element of code (Type, MethodInfo, ...) whose custom attributes are requested.
options
Type: PostSharp.ReflectionReflectionSearchOptions
UseReflectionWrappers or None.

Return Value

Type: CustomAttributeInstance
The set of all custom attributes added, directly or indirectly, to target.
Remarks

Note Note
This method returns custom attributes from the internal annotation repository of PostSharp. This repository contains more than only custom attributes added in source code. For instance, if you use MulticastAttribute to add a custom attribute to several elements of code in a single line of code, this method will return one custom attribute instance for every target of the MulticastAttribute .

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetCustomAttributesOnTarget Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetCustomAttributesOnTarget(T) Method (Object, ReflectionSearchOptions)

ReflectionSearchGetCustomAttributesOnTargetT Method (Object, ReflectionSearchOptions)
Gets all custom attributes of a given type on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute and specifies additional options.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static IList<T> GetCustomAttributesOnTarget<T>(
    Object target,
    ReflectionSearchOptions options = ReflectionSearchOptions.IncludeDerivedTypes
)
where T : Attribute

Parameters

target
Type: SystemObject
Element of code (Type, MethodInfo, ...) whose custom attributes are requested.
options (Optional)
Type: PostSharp.ReflectionReflectionSearchOptions
UseReflectionWrappers or None.

Type Parameters

T
Type of the custom attribute.

Return Value

Type: IList T
The set of all custom attributes added, directly or indirectly, to target.
Remarks

Note Note
This method returns custom attributes from the internal annotation repository of PostSharp. This repository contains more than only custom attributes added in source code. For instance, if you use MulticastAttribute to add a custom attribute to several elements of code in a single line of code, this method will return one custom attribute instance for every target of the MulticastAttribute .

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReflectionSearch Class
GetCustomAttributesOnTarget Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetDeclarationsUsedByMethod Method

ReflectionSearchGetDeclarationsUsedByMethod Method
Overload List
Name | Description
GetDeclarationsUsedByMethod(MethodBase) | Gets all declarations (Type, FieldInfo, MethodInfo or ConstructorInfo) used by the body of a given method or constructor.
GetDeclarationsUsedByMethod(MethodBase, ReflectionSearchOptions) | Gets all declarations (Type, FieldInfo, MethodInfo or ConstructorInfo) used by the body of a given method or constructor and specifies additional options.
Top
See Also

Reference

ReflectionSearch Class
PostSharp.Reflection Namespace


ReflectionSearch.GetDeclarationsUsedByMethod Method (MethodBase)

ReflectionSearchGetDeclarationsUsedByMethod Method (MethodBase)
Gets all declarations (Type, FieldInfo, MethodInfo or ConstructorInfo) used by the body of a given method or constructor.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MethodUsageCodeReference[] GetDeclarationsUsedByMethod(
    MethodBase method
)

Parameters

method
Type: System.ReflectionMethodBase
A MethodInfo or ConstructorInfo.

Return Value

Type: MethodUsageCodeReference
An array of MethodUsageCodeReference containing one item for each declaration used by the body of method.
Remarks

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetDeclarationsUsedByMethod Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetDeclarationsUsedByMethod Method (MethodBase, ReflectionSearchOptions)

ReflectionSearchGetDeclarationsUsedByMethod Method (MethodBase, ReflectionSearchOptions)
Gets all declarations (Type, FieldInfo, MethodInfo or ConstructorInfo) used by the body of a given method or constructor and specifies additional options.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MethodUsageCodeReference[] GetDeclarationsUsedByMethod(
    MethodBase method,
    ReflectionSearchOptions options
)

Parameters

method
Type: System.ReflectionMethodBase
A MethodInfo or ConstructorInfo.
options
Type: PostSharp.ReflectionReflectionSearchOptions
UseReflectionWrappers or None.

Return Value

Type: MethodUsageCodeReference
An array of MethodUsageCodeReference containing one item for each declaration used by the body of method.
Remarks

Note Note

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetDeclarationsUsedByMethod Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetDerivedTypes Method

ReflectionSearchGetDerivedTypes Method
Overload List
Name | Description
GetDerivedTypes(Type) | Gets the set of types derived from a given class or implementing a given interface.
GetDerivedTypes(Type, ReflectionSearchOptions) | Gets the set of types derived from a given class or implementing a given interface. and specifies additional options.
Top
See Also

Reference

ReflectionSearch Class
PostSharp.Reflection Namespace


ReflectionSearch.GetDerivedTypes Method (Type)

ReflectionSearchGetDerivedTypes Method (Type)
Gets the set of types derived from a given class or implementing a given interface.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static TypeInheritanceCodeReference[] GetDerivedTypes(
    Type baseType
)

Parameters

baseType
Type: SystemType
A class or interface.

Return Value

Type: TypeInheritanceCodeReference
The set of types derived from or implementing baseType.
Remarks

This method returns only types defined in the assembly being currently processed.

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetDerivedTypes Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetDerivedTypes Method (Type, ReflectionSearchOptions)

ReflectionSearchGetDerivedTypes Method (Type, ReflectionSearchOptions)
Gets the set of types derived from a given class or implementing a given interface. and specifies additional options.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static TypeInheritanceCodeReference[] GetDerivedTypes(
    Type baseType,
    ReflectionSearchOptions options
)

Parameters

baseType
Type: SystemType
A class or interface.
options
Type: PostSharp.ReflectionReflectionSearchOptions
Any valid combination of the options UseReflectionWrappers, IncludeTypeElement (partial type match), and IncludeDerivedTypes (deep search). IncludeTypeElement and IncludeDerivedTypes cannot be used together.

Return Value

Type: TypeInheritanceCodeReference
The set of types derived from or implementing baseType.
Remarks

This method returns only types defined in the assembly being currently processed.

Note Note

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetDerivedTypes Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetMembersOfType Method

ReflectionSearchGetMembersOfType Method
Overload List
Name | Description
GetMembersOfType(Type) | Gets all members (FieldInfo, PropertyInfo, or ParameterInfo) of the assembly being processed of a given type.
GetMembersOfType(Type, ReflectionSearchOptions) | Gets all members (FieldInfo, PropertyInfo, or ParameterInfo) of the assembly being processed of a given type and specifies additional options.
Top
See Also

Reference

ReflectionSearch Class
PostSharp.Reflection Namespace


ReflectionSearch.GetMembersOfType Method (Type)

ReflectionSearchGetMembersOfType Method (Type)
Gets all members (FieldInfo, PropertyInfo, or ParameterInfo) of the assembly being processed of a given type.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MemberTypeCodeReference[] GetMembersOfType(
    Type memberType
)

Parameters

memberType
Type: SystemType
Member type.

Return Value

Type: MemberTypeCodeReference
The set of all members of type memberType in the assembly being processed
Remarks

Note Note

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetMembersOfType Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetMembersOfType Method (Type, ReflectionSearchOptions)

ReflectionSearchGetMembersOfType Method (Type, ReflectionSearchOptions)
Gets all members (FieldInfo, PropertyInfo, or ParameterInfo) of the assembly being processed of a given type and specifies additional options.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MemberTypeCodeReference[] GetMembersOfType(
    Type memberType,
    ReflectionSearchOptions options
)

Parameters

memberType
Type: SystemType
Member type.
options
Type: PostSharp.ReflectionReflectionSearchOptions
Any combination of the options UseReflectionWrappers and IncludeTypeElement (partial type match).

Return Value

Type: MemberTypeCodeReference
The set of all members of type memberType in the assembly being processed
Remarks

Note Note

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetMembersOfType Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetMethodsUsingDeclaration Method

ReflectionSearchGetMethodsUsingDeclaration Method
Overload List
Name | Description
GetMethodsUsingDeclaration(MemberInfo) | Gets the set of methods and constructors whose body references a given (Type, FieldInfo, MethodInfo or ConstructorInfo).
GetMethodsUsingDeclaration(MemberInfo, ReflectionSearchOptions) | Gets the set of methods and constructors whose body references a given (Type, FieldInfo, MethodInfo or ConstructorInfo) and specifies whether reflection wrappers should be used instead of runtime reflection objects.
Top
See Also

Reference

ReflectionSearch Class
PostSharp.Reflection Namespace


ReflectionSearch.GetMethodsUsingDeclaration Method (MemberInfo)

ReflectionSearchGetMethodsUsingDeclaration Method (MemberInfo)
Gets the set of methods and constructors whose body references a given (Type, FieldInfo, MethodInfo or ConstructorInfo).

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MethodUsageCodeReference[] GetMethodsUsingDeclaration(
    MemberInfo declaration
)

Parameters

declaration
Type: System.ReflectionMemberInfo
The Type, FieldInfo, MethodInfo or ConstructorInfo whose references are requested.

Return Value

Type: MethodUsageCodeReference
An array of MethodUsageCodeReference containing one item for each method or constructor whose body references declaration.
Remarks

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetMethodsUsingDeclaration Overload
PostSharp.Reflection Namespace


ReflectionSearch.GetMethodsUsingDeclaration Method (MemberInfo, ReflectionSearchOptions)

ReflectionSearchGetMethodsUsingDeclaration Method (MemberInfo, ReflectionSearchOptions)
Gets the set of methods and constructors whose body references a given (Type, FieldInfo, MethodInfo or ConstructorInfo) and specifies whether reflection wrappers should be used instead of runtime reflection objects.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static MethodUsageCodeReference[] GetMethodsUsingDeclaration(
    MemberInfo declaration,
    ReflectionSearchOptions options
)

Parameters

declaration
Type: System.ReflectionMemberInfo
The Type, FieldInfo, MethodInfo or ConstructorInfo whose references are requested.
options
Type: PostSharp.ReflectionReflectionSearchOptions
Any combination of the options UseReflectionWrappers and IncludeTypeElement (partial type match).

Return Value

Type: MethodUsageCodeReference
An array of MethodUsageCodeReference containing one item for each method or constructor whose body references declaration.
Remarks

Note Note

Note Note
This feature is available only at build time.

Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionSearch Class
GetMethodsUsingDeclaration Overload
PostSharp.Reflection Namespace


ReflectionSearch.HasCustomAttribute Method

ReflectionSearchHasCustomAttribute Method
Determines whether a declaration has a custom attribute of a given type, including those who have been added indirectly, for instance through MulticastAttribute.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool HasCustomAttribute(
    Object target,
    Type type,
    bool inherit = false
)

Parameters

target
Type: SystemObject
Element of code (Type, MethodInfo, ...) whose custom attributes are requested.
type
Type: SystemType
The type of custom attributes.
inherit (Optional)
Type: SystemBoolean
true to consider custom attributes derived from type, false to consider only custom attributes strictly of type type.

Return Value

Type: Boolean
True if type has a custom attribute of type type, otherwise false.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReflectionSearch Class
PostSharp.Reflection Namespace


ReflectionSearchOptions Enumeration

ReflectionSearchOptions Enumeration

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[FlagsAttribute]
public enum ReflectionSearchOptions
Members
Member name | Value | Description
None | 0 | No option.
IncludeDerivedTypes | 1 | Include relationships referencing a derived type (instead of exactly that type).
IncludeTypeElement | 2 | Include relationships referencing a type signature including the given type (instead of only the given type).
UseReflectionWrappers | 4 | Obsolete. Use reflection wrappers instead of runtime reflection objects. Reflection wrappers implement standard reflection classes (Type, MethodInfo, ...), but do not require the CLR to load the type. Reflection wrappers should be used only when the CLR is not able to load the type, for instance because the type is not valid for runtime execution. This happens for instance when the type has an extern method implemented after compilation by PostSharp.
Remarks
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


ReflectionTypeComparer Class

ReflectionTypeComparer Class
Comparer of reflection types (Type) based on content, not reference. Supports the unbound generic parameters derived from the GenericArg class.
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionReflectionTypeComparer

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ReflectionTypeComparer : IEqualityComparer<Type>,
    IEqualityComparer<Type[]>

The ReflectionTypeComparer type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Type, Type) | Determines whether the specified objects are equal.
Public method | Equals(Type, Type) | Determines whether the specified objects are equal.
Public method | GetHashCode(Type) | Returns a hash code for the specified object.
Public method | GetHashCode(Type) | Returns a hash code for the specified object.
 | GetInstance | Gets an instance of ReflectionTypeComparer that does not perform substitution of generic parameters.
 | GetInstance(Type, Type, Type, Type) | Gets an instance of ReflectionTypeComparer that performs substitution of generic parameters.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
Used by the CustomReflectionBinder class.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


ReflectionTypeComparer Methods

ReflectionTypeComparer Methods

The ReflectionTypeComparer type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Type, Type) | Determines whether the specified objects are equal.
Public method | Equals(Type, Type) | Determines whether the specified objects are equal.
Public method | GetHashCode(Type) | Returns a hash code for the specified object.
Public method | GetHashCode(Type) | Returns a hash code for the specified object.
 | GetInstance | Gets an instance of ReflectionTypeComparer that does not perform substitution of generic parameters.
 | GetInstance(Type, Type, Type, Type) | Gets an instance of ReflectionTypeComparer that performs substitution of generic parameters.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReflectionTypeComparer Class
PostSharp.Reflection Namespace


ReflectionTypeComparer.Equals Method

ReflectionTypeComparerEquals Method
Overload List
 | Name | Description
Public method | Equals(Type, Type) | Determines whether the specified objects are equal.
Public method | Equals(Type, Type) | Determines whether the specified objects are equal.
Top
See Also

Reference

ReflectionTypeComparer Class
PostSharp.Reflection Namespace


ReflectionTypeComparer.Equals Method (Type, Type)

ReflectionTypeComparerEquals Method (Type, Type)
Determines whether the specified objects are equal.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Equals(
    Type x,
    Type y
)

Parameters

x
Type: SystemType
The first object of type T to compare.
y
Type: SystemType
The second object of type T to compare.

Return Value

Type: Boolean
true if the specified objects are equal; otherwise, false.

Implements

IEqualityComparerTEquals(T, T)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionTypeComparer Class
Equals Overload
PostSharp.Reflection Namespace


ReflectionTypeComparer.Equals Method (Type[], Type[])

ReflectionTypeComparerEquals Method (Type, Type)
Determines whether the specified objects are equal.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Equals(
    Type[] x,
    Type[] y
)

Parameters

x
Type: SystemType
The first object of type T to compare.
y
Type: SystemType
The second object of type T to compare.

Return Value

Type: Boolean
true if the specified objects are equal; otherwise, false.

Implements

IEqualityComparerTEquals(T, T)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionTypeComparer Class
Equals Overload
PostSharp.Reflection Namespace


ReflectionTypeComparer.GetHashCode Method

ReflectionTypeComparerGetHashCode Method
Overload List
 | Name | Description
Public method | GetHashCode(Type) | Returns a hash code for the specified object.
Public method | GetHashCode(Type) | Returns a hash code for the specified object.
Top
See Also

Reference

ReflectionTypeComparer Class
PostSharp.Reflection Namespace


ReflectionTypeComparer.GetHashCode Method (Type)

ReflectionTypeComparerGetHashCode Method (Type)
Returns a hash code for the specified object.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int GetHashCode(
    Type obj
)

Parameters

obj
Type: SystemType
The Object for which a hash code is to be returned.

Return Value

Type: Int32
A hash code for the specified object.

Implements

IEqualityComparerTGetHashCode(T)
Exceptions
Exception | Condition
ArgumentNullException | The type of obj is a reference type and obj is null.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionTypeComparer Class
GetHashCode Overload
PostSharp.Reflection Namespace


ReflectionTypeComparer.GetHashCode Method (Type[])

ReflectionTypeComparerGetHashCode Method (Type)
Returns a hash code for the specified object.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int GetHashCode(
    Type[] types
)

Parameters

types
Type: SystemType

Return Value

Type: Int32
A hash code for the specified object.

Implements

IEqualityComparerTGetHashCode(T)
Exceptions
Exception | Condition
ArgumentNullException | The type of obj is a reference type and obj is null.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionTypeComparer Class
GetHashCode Overload
PostSharp.Reflection Namespace


ReflectionTypeComparer.GetInstance Method

ReflectionTypeComparerGetInstance Method
Overload List
Name | Description
GetInstance | Gets an instance of ReflectionTypeComparer that does not perform substitution of generic parameters.
GetInstance(Type, Type, Type, Type) | Gets an instance of ReflectionTypeComparer that performs substitution of generic parameters.
Top
See Also

Reference

ReflectionTypeComparer Class
PostSharp.Reflection Namespace


ReflectionTypeComparer.GetInstance Method

ReflectionTypeComparerGetInstance Method
Gets an instance of ReflectionTypeComparer that does not perform substitution of generic parameters.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static ReflectionTypeComparer GetInstance()

Return Value

Type: ReflectionTypeComparer
An instance of ReflectionTypeComparer.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionTypeComparer Class
GetInstance Overload
PostSharp.Reflection Namespace


ReflectionTypeComparer.GetInstance Method (Type[], Type[], Type[], Type[])

ReflectionTypeComparerGetInstance Method (Type, Type, Type, Type)
Gets an instance of ReflectionTypeComparer that performs substitution of generic parameters.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static ReflectionTypeComparer GetInstance(
    Type[] leftGenericTypeParameters,
    Type[] leftGenericMethodParameters,
    Type[] rightGenericTypeParameters,
    Type[] rightGenericMethodParameters
)

Parameters

leftGenericTypeParameters
Type: SystemType
Array of types to be substituted to the generic type parameters of the left member.
leftGenericMethodParameters
Type: SystemType
Array of types to be substituted to the generic method parameters of the left member.
rightGenericTypeParameters
Type: SystemType
Array of types to be substituted to the generic type parameters of the right member.
rightGenericMethodParameters
Type: SystemType
Array of types to be substituted to the generic method parameters of the right member.

Return Value

Type: ReflectionTypeComparer
An instance of ReflectionTypeComparer.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReflectionTypeComparer Class
GetInstance Overload
PostSharp.Reflection Namespace


StateMachineKind Enumeration

StateMachineKind Enumeration
Enumeration of kinds of state machines.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum StateMachineKind
Members
Member name | Value | Description
None | 0 | The method is not implemented by a state machine.
Enumerator | 1 | Iterator method returning an IEnumeratorT.
Enumerable | 2 | Iterator method returning an IEnumerableT.
Async | 3 | Async method.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

PostSharp.Reflection Namespace
ReflectionExtensionsGetStateMachineKind(MethodInfo)


SymbolSequencePoint Class

SymbolSequencePoint Class
Maps a point in IL instructions to location in source code.
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionSymbolSequencePoint

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class SymbolSequencePoint : IComparable<SymbolSequencePoint>,
    IEquatable<SymbolSequencePoint>

The SymbolSequencePoint type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Overrides ObjectEquals(Object).)
Public method | Equals(SymbolSequencePoint) | Indicates whether the current object is equal to another object of the same type.
Public method | GetHashCode | Serves as a hash function for a particular type. (Overrides ObjectGetHashCode.)
Public method | ToString | Returns a string that represents the current object. (Overrides ObjectToString.)
Top
Operators
Name | Description
Equality | Determines whether two sequence points are equal.
Inequality | Determines whether two sequence points are different.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
Hidden | Gets a symbol meaning that the associated instructions have no source code.
Top
Properties
 | Name | Description
Public property | EndColumn | Gets the end column in the source file.
Public property | EndLine | Gets the end line in the source file.
Public property | IsHidden | Determines whether the current symbol means that the associated instructions have no source code.
Public property | SourceDocument | Document (file of source code) containing the current sequence point.
Public property | StartColumn | Gets the start column in the source file.
Public property | StartLine | Gets the start line in the source file.
Top
Remarks
This class implements the IComparableT interface. This allows sorting sequence points according to their IL offsets and performing binary searches in sorted arrays.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


SymbolSequencePoint Fields

SymbolSequencePoint Fields

The SymbolSequencePoint type exposes the following members.

Fields
Name | Description
Hidden | Gets a symbol meaning that the associated instructions have no source code.
Top
See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.Hidden Field

SymbolSequencePointHidden Field
Gets a symbol meaning that the associated instructions have no source code.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly SymbolSequencePoint Hidden

Field Value

Type: SymbolSequencePoint
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint Methods

SymbolSequencePoint Methods

The SymbolSequencePoint type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Overrides ObjectEquals(Object).)
Public method | Equals(SymbolSequencePoint) | Indicates whether the current object is equal to another object of the same type.
Public method | GetHashCode | Serves as a hash function for a particular type. (Overrides ObjectGetHashCode.)
Public method | ToString | Returns a string that represents the current object. (Overrides ObjectToString.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.Equals Method

SymbolSequencePointEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Overrides ObjectEquals(Object).)
Public method | Equals(SymbolSequencePoint) | Indicates whether the current object is equal to another object of the same type.
Top
See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.Equals Method (Object)

SymbolSequencePointEquals Method (Object)
Determines whether the specified Object is equal to the current Object.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool Equals(
    Object obj
)

Parameters

obj
Type: SystemObject
The object to compare with the current object.

Return Value

Type: Boolean
true if the specified object is equal to the current object; otherwise, false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
Equals Overload
PostSharp.Reflection Namespace


SymbolSequencePoint.Equals Method (SymbolSequencePoint)

SymbolSequencePointEquals Method (SymbolSequencePoint)
Indicates whether the current object is equal to another object of the same type.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Equals(
    SymbolSequencePoint other
)

Parameters

other
Type: PostSharp.ReflectionSymbolSequencePoint
An object to compare with this object.

Return Value

Type: Boolean
true if the current object is equal to the other parameter; otherwise, false.

Implements

IEquatableTEquals(T)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
Equals Overload
PostSharp.Reflection Namespace


SymbolSequencePoint.GetHashCode Method

SymbolSequencePointGetHashCode Method
Serves as a hash function for a particular type.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int GetHashCode()

Return Value

Type: Int32
A hash code for the current Object.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.ToString Method

SymbolSequencePointToString Method
Returns a string that represents the current object.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override string ToString()

Return Value

Type: String
A string that represents the current object.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint Operators

SymbolSequencePoint Operators

The SymbolSequencePoint type exposes the following members.

Operators
Name | Description
Equality | Determines whether two sequence points are equal.
Inequality | Determines whether two sequence points are different.
Top
See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.Equality Operator

SymbolSequencePointEquality Operator
Determines whether two sequence points are equal.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator ==(
    SymbolSequencePoint left,
    SymbolSequencePoint right
)

Parameters

left
Type: PostSharp.ReflectionSymbolSequencePoint
A SymbolSequencePoint.
right
Type: PostSharp.ReflectionSymbolSequencePoint
A SymbolSequencePoint.

Return Value

Type: Boolean
true if both sequence points are equal, otherwise false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.Inequality Operator

SymbolSequencePointInequality Operator
Determines whether two sequence points are different.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator !=(
    SymbolSequencePoint left,
    SymbolSequencePoint right
)

Parameters

left
Type: PostSharp.ReflectionSymbolSequencePoint
A SymbolSequencePoint.
right
Type: PostSharp.ReflectionSymbolSequencePoint
A SymbolSequencePoint.

Return Value

Type: Boolean
true if both sequence points are different, otherwise false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint Properties

SymbolSequencePoint Properties

The SymbolSequencePoint type exposes the following members.

Properties
 | Name | Description
Public property | EndColumn | Gets the end column in the source file.
Public property | EndLine | Gets the end line in the source file.
Public property | IsHidden | Determines whether the current symbol means that the associated instructions have no source code.
Public property | SourceDocument | Document (file of source code) containing the current sequence point.
Public property | StartColumn | Gets the start column in the source file.
Public property | StartLine | Gets the start line in the source file.
Top
See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.EndColumn Property

SymbolSequencePointEndColumn Property
Gets the end column in the source file.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int EndColumn { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.EndLine Property

SymbolSequencePointEndLine Property
Gets the end line in the source file.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int EndLine { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.IsHidden Property

SymbolSequencePointIsHidden Property
Determines whether the current symbol means that the associated instructions have no source code.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsHidden { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.SourceDocument Property

SymbolSequencePointSourceDocument Property
Document (file of source code) containing the current sequence point.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ISourceDocument SourceDocument { get; }

Property Value

Type: ISourceDocument
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.StartColumn Property

SymbolSequencePointStartColumn Property
Gets the start column in the source file.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int StartColumn { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


SymbolSequencePoint.StartLine Property

SymbolSequencePointStartLine Property
Gets the start line in the source file.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public int StartLine { get; }

Property Value

Type: Int32
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SymbolSequencePoint Class
PostSharp.Reflection Namespace


TypeInheritanceCodeReference Class

TypeInheritanceCodeReference Class
Represents a inheritance relationship between two types.
Inheritance Hierarchy
SystemObject
PostSharp.ReflectionTypeInheritanceCodeReference

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class TypeInheritanceCodeReference : ICodeReference

The TypeInheritanceCodeReference type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | BaseType | Gets the base type. If the base type is a generic type, this property contains a generic type instance.
Public property | DerivedType | Gets the derived type.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


TypeInheritanceCodeReference Methods

TypeInheritanceCodeReference Methods

The TypeInheritanceCodeReference type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

TypeInheritanceCodeReference Class
PostSharp.Reflection Namespace


TypeInheritanceCodeReference Properties

TypeInheritanceCodeReference Properties

The TypeInheritanceCodeReference type exposes the following members.

Properties
 | Name | Description
Public property | BaseType | Gets the base type. If the base type is a generic type, this property contains a generic type instance.
Public property | DerivedType | Gets the derived type.
Top
See Also

Reference

TypeInheritanceCodeReference Class
PostSharp.Reflection Namespace


TypeInheritanceCodeReference.BaseType Property

TypeInheritanceCodeReferenceBaseType Property
Gets the base type. If the base type is a generic type, this property contains a generic type instance.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type BaseType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeInheritanceCodeReference Class
PostSharp.Reflection Namespace


TypeInheritanceCodeReference.DerivedType Property

TypeInheritanceCodeReferenceDerivedType Property
Gets the derived type.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type DerivedType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

TypeInheritanceCodeReference Class
PostSharp.Reflection Namespace


Visibility Enumeration

Visibility Enumeration
Visibility of types and type members.

Namespace: PostSharp.Reflection
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum Visibility
Members
Member name | Value | Description
Public | 0 | Public.
Family | 1 | Family (protected).
Assembly | 2 | Assembly (internal).
FamilyOrAssembly | 3 | Family or assembly (protected internal).
FamilyAndAssembly | 4 | Family and assembly (no C# equivalent: protected types inside the current assembly).
Private | 5 | Private.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection Namespace


PostSharp.Reflection.Syntax Namespace

PostSharp.Reflection.Syntax Namespace
The PostSharp.Reflection.Syntax namespace contains classes and interfaces that can represent the decompiled abstract syntax tree of method bodies.
Classes
 | Class | Description
Public class | SyntaxTreeFormatter | Formats an ISyntaxElement to a textual representation, for debugging purposes.
Public class | SyntaxTreeVisitor | Abstract implementation of a visitor of method bodies (ISyntaxMethodBody and IExpression).
Interfaces
 | Interface | Description
Public interface | IAddressOfExpression | Expression that takes the address of the operand. Equivalent to the C# operator &.
Public interface | IBinaryExpression | Expression that has two operands, Left and Right.
Public interface | IBlockExpression | Block containing other instructions.
Public interface | IConditionalExpression | Conditional expression, corresponding to the if keyword in C#.
Public interface | IConstantExpression | Expression representing a build-time constant.
Public interface | ICopyBufferExpression | Expression equivalent to the Cpblk instruction.
Public interface | IExpression | Represents an expression or an instruction.
Public interface | IFieldExpression | Expression that represents a field.
Public interface | IGotoExpression | Unconditional branching instruction.
Public interface | IInitBufferExpression | Expression equivalent to the Initblk instruction.
Public interface | ILocalVariableExpression | Expression that represents a local variable.
Public interface | IMetadataExpression | Expression that depends on a metadata declaration. This expression is used when compiling the typeof, sizeof or default keywords of C#, among others.
Public interface | IMethodCallExpression | Expression representing a method call.
Public interface | IMethodPointerExpression | Expression that represents a C-like pointer to a method.
Public interface | INewArrayExpression | Expression that returns a new array.
Public interface | INewObjectExpression | Expression that creates a new object by invoking a constructor.
Public interface | IParameterExpression | Expression that represents a method parameter.
Public interface | ISwitchExpression | Expression that represent a switch (conditional statement with multiple branches).
Public interface | ISyntaxElement | Represents an element of the syntax tree representing a method body.
Public interface | ISyntaxExceptionHandler | Represents an exception handler (either catch, finally or filter) attached to a block.
Public interface | ISyntaxLocalVariable | Expression that represents a local variable.
Public interface | ISyntaxMethodBody | Represents the body of a method.
Public interface | ISyntaxReflectionService | Service that exposes the method GetMethodBody(MethodBase, SyntaxAbstractionLevel), which allows to decompile a method and get a AST representation.
Public interface | IUnaryExpression | Represents an expression with a single operand.
Public interface | IValueOfExpression | Expression that returns the value stored at an address. Equivalent to the C# keyword *.
Public interface | IZeroaryExpression | Expression with no operand.
Enumerations
 | Enumeration | Description
Public enumeration | AddressAlignment | Enumeration of address alignments for access to unmanaged memory represented by ICopyBufferExpression, IFieldExpression or IValueOfExpression.
Public enumeration | SyntaxAbstractionLevel | Enumerates the level of abstraction and the level of details produced by the AST decompiler.
Public enumeration | SyntaxElementKind | Enumeration of kinds of syntax elements (ISyntaxElement).


AddressAlignment Enumeration

AddressAlignment Enumeration
Enumeration of address alignments for access to unmanaged memory represented by ICopyBufferExpression, IFieldExpression or IValueOfExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum AddressAlignment
Members
Member name | Value | Description
Default | 0 | Default alignment (machine word).
Unaligned1 | 1 | 1-byte alignment.
Unaligned2 | 2 | 2-byte alignment.
Unaligned4 | 3 | 4-byte alignment.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IAddressOfExpression Interface

IAddressOfExpression Interface
Expression that takes the address of the operand. Equivalent to the C# operator &.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IAddressOfExpression : IUnaryExpression,
    IExpression, ISyntaxElement

The IAddressOfExpression type exposes the following members.

Properties
 | Name | Description
Public property | IsReadOnly | Determines whether the returned pointer is a read-only pointer.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Value | Operand of the unary expression. (Inherited from IUnaryExpression.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IAddressOfExpression Properties

IAddressOfExpression Properties

The IAddressOfExpression type exposes the following members.

Properties
 | Name | Description
Public property | IsReadOnly | Determines whether the returned pointer is a read-only pointer.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Value | Operand of the unary expression. (Inherited from IUnaryExpression.)
Top
See Also

Reference

IAddressOfExpression Interface
PostSharp.Reflection.Syntax Namespace


IAddressOfExpression.IsReadOnly Property

IAddressOfExpressionIsReadOnly Property
Determines whether the returned pointer is a read-only pointer.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsReadOnly { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IAddressOfExpression Interface
PostSharp.Reflection.Syntax Namespace


IBinaryExpression Interface

IBinaryExpression Interface
Expression that has two operands, Left and Right.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IBinaryExpression : IExpression,
    ISyntaxElement

The IBinaryExpression type exposes the following members.

Properties
 | Name | Description
Public property | Left | Gets the left operand.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | Right | Gets the right operand.
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IBinaryExpression Properties

IBinaryExpression Properties

The IBinaryExpression type exposes the following members.

Properties
 | Name | Description
Public property | Left | Gets the left operand.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | Right | Gets the right operand.
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IBinaryExpression Interface
PostSharp.Reflection.Syntax Namespace


IBinaryExpression.Left Property

IBinaryExpressionLeft Property
Gets the left operand.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Left { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IBinaryExpression Interface
PostSharp.Reflection.Syntax Namespace


IBinaryExpression.Right Property

IBinaryExpressionRight Property
Gets the right operand.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Right { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IBinaryExpression Interface
PostSharp.Reflection.Syntax Namespace


IBlockExpression Interface

IBlockExpression Interface
Block containing other instructions.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IBlockExpression : IExpression,
    ISyntaxElement

The IBlockExpression type exposes the following members.

Properties
 | Name | Description
Public property | ExceptionHandlers | Gets the collection of exception handlers that protect the block.
Public property | Items | Gets the collection of items in the block.
Public property | Label | Gets a string that uniquely identifies the block (inside the current method body) as a possible branching target.
Public property | LocalVariables | Gets the collection of local variables defined for the current block.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IBlockExpression Properties

IBlockExpression Properties

The IBlockExpression type exposes the following members.

Properties
 | Name | Description
Public property | ExceptionHandlers | Gets the collection of exception handlers that protect the block.
Public property | Items | Gets the collection of items in the block.
Public property | Label | Gets a string that uniquely identifies the block (inside the current method body) as a possible branching target.
Public property | LocalVariables | Gets the collection of local variables defined for the current block.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IBlockExpression Interface
PostSharp.Reflection.Syntax Namespace


IBlockExpression.ExceptionHandlers Property

IBlockExpressionExceptionHandlers Property
Gets the collection of exception handlers that protect the block.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IReadOnlyLinkedList<ISyntaxExceptionHandler> ExceptionHandlers { get; }

Property Value

Type: IReadOnlyLinkedList ISyntaxExceptionHandler
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IBlockExpression Interface
PostSharp.Reflection.Syntax Namespace


IBlockExpression.Items Property

IBlockExpressionItems Property
Gets the collection of items in the block.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IReadOnlyLinkedList<IExpression> Items { get; }

Property Value

Type: IReadOnlyLinkedList IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IBlockExpression Interface
PostSharp.Reflection.Syntax Namespace


IBlockExpression.Label Property

IBlockExpressionLabel Property
Gets a string that uniquely identifies the block (inside the current method body) as a possible branching target.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string Label { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IBlockExpression Interface
PostSharp.Reflection.Syntax Namespace


IBlockExpression.LocalVariables Property

IBlockExpressionLocalVariables Property
Gets the collection of local variables defined for the current block.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IList<ISyntaxLocalVariable> LocalVariables { get; }

Property Value

Type: IList ISyntaxLocalVariable
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IBlockExpression Interface
PostSharp.Reflection.Syntax Namespace


IConditionalExpression Interface

IConditionalExpression Interface
Conditional expression, corresponding to the if keyword in C#.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IConditionalExpression : IExpression,
    ISyntaxElement

The IConditionalExpression type exposes the following members.

Properties
 | Name | Description
Public property | Condition | Gets the condition expression (the return type does not need to be bool. Zero and null values are considered false).
Public property | IfFalse | Gets the expression executed when Condition evaluates to false, zero, or null.
Public property | IfTrue | Gets the expression executed when Condition evaluates to true or a non-null and non-zero vale.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IConditionalExpression Properties

IConditionalExpression Properties

The IConditionalExpression type exposes the following members.

Properties
 | Name | Description
Public property | Condition | Gets the condition expression (the return type does not need to be bool. Zero and null values are considered false).
Public property | IfFalse | Gets the expression executed when Condition evaluates to false, zero, or null.
Public property | IfTrue | Gets the expression executed when Condition evaluates to true or a non-null and non-zero vale.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IConditionalExpression Interface
PostSharp.Reflection.Syntax Namespace


IConditionalExpression.Condition Property

IConditionalExpressionCondition Property
Gets the condition expression (the return type does not need to be bool. Zero and null values are considered false).

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Condition { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IConditionalExpression Interface
PostSharp.Reflection.Syntax Namespace


IConditionalExpression.IfFalse Property

IConditionalExpressionIfFalse Property
Gets the expression executed when Condition evaluates to false, zero, or null.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression IfFalse { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IConditionalExpression Interface
PostSharp.Reflection.Syntax Namespace


IConditionalExpression.IfTrue Property

IConditionalExpressionIfTrue Property
Gets the expression executed when Condition evaluates to true or a non-null and non-zero vale.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression IfTrue { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IConditionalExpression Interface
PostSharp.Reflection.Syntax Namespace


IConstantExpression Interface

IConstantExpression Interface
Expression representing a build-time constant.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IConstantExpression : IExpression,
    ISyntaxElement

The IConstantExpression type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Value | Gets the constant value.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IConstantExpression Properties

IConstantExpression Properties

The IConstantExpression type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Value | Gets the constant value.
Top
See Also

Reference

IConstantExpression Interface
PostSharp.Reflection.Syntax Namespace


IConstantExpression.Value Property

IConstantExpressionValue Property
Gets the constant value.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object Value { get; }

Property Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IConstantExpression Interface
PostSharp.Reflection.Syntax Namespace


ICopyBufferExpression Interface

ICopyBufferExpression Interface
Expression equivalent to the Cpblk instruction.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ICopyBufferExpression : IExpression,
    ISyntaxElement

The ICopyBufferExpression type exposes the following members.

Properties
 | Name | Description
Public property | Alignment | Gets the alignment of source and destination buffers.
Public property | Destination | Gets the destination address.
Public property | IsVolatile | Determines whether the buffers can be modified from a different thread.
Public property | Length | Gets the number of bytes to be copied.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | Source | Gets the source address.
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Remarks

This expression type has no equivalent in C#.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


ICopyBufferExpression Properties

ICopyBufferExpression Properties

The ICopyBufferExpression type exposes the following members.

Properties
 | Name | Description
Public property | Alignment | Gets the alignment of source and destination buffers.
Public property | Destination | Gets the destination address.
Public property | IsVolatile | Determines whether the buffers can be modified from a different thread.
Public property | Length | Gets the number of bytes to be copied.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | Source | Gets the source address.
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

ICopyBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


ICopyBufferExpression.Alignment Property

ICopyBufferExpressionAlignment Property
Gets the alignment of source and destination buffers.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
AddressAlignment Alignment { get; }

Property Value

Type: AddressAlignment
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ICopyBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


ICopyBufferExpression.Destination Property

ICopyBufferExpressionDestination Property
Gets the destination address.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Destination { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ICopyBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


ICopyBufferExpression.IsVolatile Property

ICopyBufferExpressionIsVolatile Property
Determines whether the buffers can be modified from a different thread.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsVolatile { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ICopyBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


ICopyBufferExpression.Length Property

ICopyBufferExpressionLength Property
Gets the number of bytes to be copied.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Length { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ICopyBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


ICopyBufferExpression.Source Property

ICopyBufferExpressionSource Property
Gets the source address.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Source { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ICopyBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


IExpression Interface

IExpression Interface
Represents an expression or an instruction.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IExpression : ISyntaxElement

The IExpression type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction).
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IExpression Properties

IExpression Properties

The IExpression type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction).
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IExpression Interface
PostSharp.Reflection.Syntax Namespace


IExpression.ReturnType Property

IExpressionReturnType Property
Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction).

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Type ReturnType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IExpression Interface
PostSharp.Reflection.Syntax Namespace


IFieldExpression Interface

IFieldExpression Interface
Expression that represents a field.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IFieldExpression : IExpression,
    ISyntaxElement

The IFieldExpression type exposes the following members.

Properties
 | Name | Description
Public property | Alignment | Gets the field alignment.
Public property | Field | Gets the field.
Public property | Instance | Gets the object containing the field, or null if the field is static.
Public property | IsVolatile | Determine whether the field is can be written by a different thread than the current one.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IFieldExpression Properties

IFieldExpression Properties

The IFieldExpression type exposes the following members.

Properties
 | Name | Description
Public property | Alignment | Gets the field alignment.
Public property | Field | Gets the field.
Public property | Instance | Gets the object containing the field, or null if the field is static.
Public property | IsVolatile | Determine whether the field is can be written by a different thread than the current one.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IFieldExpression Interface
PostSharp.Reflection.Syntax Namespace


IFieldExpression.Alignment Property

IFieldExpressionAlignment Property
Gets the field alignment.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
AddressAlignment Alignment { get; }

Property Value

Type: AddressAlignment
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IFieldExpression Interface
PostSharp.Reflection.Syntax Namespace


IFieldExpression.Field Property

IFieldExpressionField Property
Gets the field.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
FieldInfo Field { get; }

Property Value

Type: FieldInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IFieldExpression Interface
PostSharp.Reflection.Syntax Namespace


IFieldExpression.Instance Property

IFieldExpressionInstance Property
Gets the object containing the field, or null if the field is static.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Instance { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IFieldExpression Interface
PostSharp.Reflection.Syntax Namespace


IFieldExpression.IsVolatile Property

IFieldExpressionIsVolatile Property
Determine whether the field is can be written by a different thread than the current one.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsVolatile { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IFieldExpression Interface
PostSharp.Reflection.Syntax Namespace


IGotoExpression Interface

IGotoExpression Interface
Unconditional branching instruction.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IGotoExpression : IExpression,
    ISyntaxElement

The IGotoExpression type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Target | Instruction block that must receive control.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IGotoExpression Properties

IGotoExpression Properties

The IGotoExpression type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Target | Instruction block that must receive control.
Top
See Also

Reference

IGotoExpression Interface
PostSharp.Reflection.Syntax Namespace


IGotoExpression.Target Property

IGotoExpressionTarget Property
Instruction block that must receive control.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IBlockExpression Target { get; }

Property Value

Type: IBlockExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IGotoExpression Interface
PostSharp.Reflection.Syntax Namespace


IInitBufferExpression Interface

IInitBufferExpression Interface
Expression equivalent to the Initblk instruction.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IInitBufferExpression : IExpression,
    ISyntaxElement

The IInitBufferExpression type exposes the following members.

Properties
 | Name | Description
Public property | Alignment | Gets the alignment of the buffers.
Public property | Buffer | Gets the address of the buffer to be initialized.
Public property | IsVolatile | Determines whether the buffers can be modified from a different thread.
Public property | Length | Gets the number of bytes to be initialized.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Remarks

This expression type has no equivalent in C#.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IInitBufferExpression Properties

IInitBufferExpression Properties

The IInitBufferExpression type exposes the following members.

Properties
 | Name | Description
Public property | Alignment | Gets the alignment of the buffers.
Public property | Buffer | Gets the address of the buffer to be initialized.
Public property | IsVolatile | Determines whether the buffers can be modified from a different thread.
Public property | Length | Gets the number of bytes to be initialized.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IInitBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


IInitBufferExpression.Alignment Property

IInitBufferExpressionAlignment Property
Gets the alignment of the buffers.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
AddressAlignment Alignment { get; }

Property Value

Type: AddressAlignment
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IInitBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


IInitBufferExpression.Buffer Property

IInitBufferExpressionBuffer Property
Gets the address of the buffer to be initialized.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Buffer { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IInitBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


IInitBufferExpression.IsVolatile Property

IInitBufferExpressionIsVolatile Property
Determines whether the buffers can be modified from a different thread.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsVolatile { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IInitBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


IInitBufferExpression.Length Property

IInitBufferExpressionLength Property
Gets the number of bytes to be initialized.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Length { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IInitBufferExpression Interface
PostSharp.Reflection.Syntax Namespace


ILocalVariableExpression Interface

ILocalVariableExpression Interface
Expression that represents a local variable.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ILocalVariableExpression : IExpression,
    ISyntaxElement

The ILocalVariableExpression type exposes the following members.

Properties
 | Name | Description
Public property | LocalVariable | Gets the local variable.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


ILocalVariableExpression Properties

ILocalVariableExpression Properties

The ILocalVariableExpression type exposes the following members.

Properties
 | Name | Description
Public property | LocalVariable | Gets the local variable.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

ILocalVariableExpression Interface
PostSharp.Reflection.Syntax Namespace


ILocalVariableExpression.LocalVariable Property

ILocalVariableExpressionLocalVariable Property
Gets the local variable.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ISyntaxLocalVariable LocalVariable { get; }

Property Value

Type: ISyntaxLocalVariable
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ILocalVariableExpression Interface
PostSharp.Reflection.Syntax Namespace


IMetadataExpression Interface

IMetadataExpression Interface
Expression that depends on a metadata declaration. This expression is used when compiling the typeof, sizeof or default keywords of C#, among others.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMetadataExpression : IExpression,
    ISyntaxElement

The IMetadataExpression type exposes the following members.

Properties
 | Name | Description
Public property | Declaration | Gets the declaration (Type, FieldInfo, MethodInfo, ConstructorInfo).
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IMetadataExpression Properties

IMetadataExpression Properties

The IMetadataExpression type exposes the following members.

Properties
 | Name | Description
Public property | Declaration | Gets the declaration (Type, FieldInfo, MethodInfo, ConstructorInfo).
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IMetadataExpression Interface
PostSharp.Reflection.Syntax Namespace


IMetadataExpression.Declaration Property

IMetadataExpressionDeclaration Property
Gets the declaration (Type, FieldInfo, MethodInfo, ConstructorInfo).

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
MemberInfo Declaration { get; }

Property Value

Type: MemberInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMetadataExpression Interface
PostSharp.Reflection.Syntax Namespace


IMethodCallExpression Interface

IMethodCallExpression Interface
Expression representing a method call.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMethodCallExpression : IExpression,
    ISyntaxElement

The IMethodCallExpression type exposes the following members.

Properties
 | Name | Description
Public property | Arguments | Gets the method arguments.
Public property | ConstrainedType | Gets the type to which the virtual method call is constrained to (see Constrained).
Public property | Instance | Gets the instance on which the method is called, or null if the method is static.
Public property | IsTail | Determines whether the call is a tail call (see Tailcall).
Public property | IsVirtual | Determines whether the call is a virtual call.
Public property | Method | Gets the called method.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IMethodCallExpression Properties

IMethodCallExpression Properties

The IMethodCallExpression type exposes the following members.

Properties
 | Name | Description
Public property | Arguments | Gets the method arguments.
Public property | ConstrainedType | Gets the type to which the virtual method call is constrained to (see Constrained).
Public property | Instance | Gets the instance on which the method is called, or null if the method is static.
Public property | IsTail | Determines whether the call is a tail call (see Tailcall).
Public property | IsVirtual | Determines whether the call is a virtual call.
Public property | Method | Gets the called method.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IMethodCallExpression Interface
PostSharp.Reflection.Syntax Namespace


IMethodCallExpression.Arguments Property

IMethodCallExpressionArguments Property
Gets the method arguments.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IList<IExpression> Arguments { get; }

Property Value

Type: IList IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodCallExpression Interface
PostSharp.Reflection.Syntax Namespace


IMethodCallExpression.ConstrainedType Property

IMethodCallExpressionConstrainedType Property
Gets the type to which the virtual method call is constrained to (see Constrained).

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Type ConstrainedType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodCallExpression Interface
PostSharp.Reflection.Syntax Namespace


IMethodCallExpression.Instance Property

IMethodCallExpressionInstance Property
Gets the instance on which the method is called, or null if the method is static.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Instance { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodCallExpression Interface
PostSharp.Reflection.Syntax Namespace


IMethodCallExpression.IsTail Property

IMethodCallExpressionIsTail Property
Determines whether the call is a tail call (see Tailcall).

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsTail { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodCallExpression Interface
PostSharp.Reflection.Syntax Namespace


IMethodCallExpression.IsVirtual Property

IMethodCallExpressionIsVirtual Property
Determines whether the call is a virtual call.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsVirtual { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodCallExpression Interface
PostSharp.Reflection.Syntax Namespace


IMethodCallExpression.Method Property

IMethodCallExpressionMethod Property
Gets the called method.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
MethodBase Method { get; }

Property Value

Type: MethodBase
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodCallExpression Interface
PostSharp.Reflection.Syntax Namespace


IMethodPointerExpression Interface

IMethodPointerExpression Interface
Expression that represents a C-like pointer to a method.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IMethodPointerExpression : IExpression,
    ISyntaxElement

The IMethodPointerExpression type exposes the following members.

Properties
 | Name | Description
Public property | Instance | Gets the instance on which the method is defined, or null if the method is static.
Public property | Method | Gets the method.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IMethodPointerExpression Properties

IMethodPointerExpression Properties

The IMethodPointerExpression type exposes the following members.

Properties
 | Name | Description
Public property | Instance | Gets the instance on which the method is defined, or null if the method is static.
Public property | Method | Gets the method.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IMethodPointerExpression Interface
PostSharp.Reflection.Syntax Namespace


IMethodPointerExpression.Instance Property

IMethodPointerExpressionInstance Property
Gets the instance on which the method is defined, or null if the method is static.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Instance { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodPointerExpression Interface
PostSharp.Reflection.Syntax Namespace


IMethodPointerExpression.Method Property

IMethodPointerExpressionMethod Property
Gets the method.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
MethodBase Method { get; }

Property Value

Type: MethodBase
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IMethodPointerExpression Interface
PostSharp.Reflection.Syntax Namespace


INewArrayExpression Interface

INewArrayExpression Interface
Expression that returns a new array.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface INewArrayExpression : IExpression,
    ISyntaxElement

The INewArrayExpression type exposes the following members.

Properties
 | Name | Description
Public property | ElementType | Gets the type of elements of the array.
Public property | Length | Gets the number of elements in the array.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


INewArrayExpression Properties

INewArrayExpression Properties

The INewArrayExpression type exposes the following members.

Properties
 | Name | Description
Public property | ElementType | Gets the type of elements of the array.
Public property | Length | Gets the number of elements in the array.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

INewArrayExpression Interface
PostSharp.Reflection.Syntax Namespace


INewArrayExpression.ElementType Property

INewArrayExpressionElementType Property
Gets the type of elements of the array.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Type ElementType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

INewArrayExpression Interface
PostSharp.Reflection.Syntax Namespace


INewArrayExpression.Length Property

INewArrayExpressionLength Property
Gets the number of elements in the array.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Length { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

INewArrayExpression Interface
PostSharp.Reflection.Syntax Namespace


INewObjectExpression Interface

INewObjectExpression Interface
Expression that creates a new object by invoking a constructor.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface INewObjectExpression : IExpression,
    ISyntaxElement

The INewObjectExpression type exposes the following members.

Properties
 | Name | Description
Public property | Arguments | Gets the arguments passed to the constructor.
Public property | Constructor | Gets the constructor.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


INewObjectExpression Properties

INewObjectExpression Properties

The INewObjectExpression type exposes the following members.

Properties
 | Name | Description
Public property | Arguments | Gets the arguments passed to the constructor.
Public property | Constructor | Gets the constructor.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

INewObjectExpression Interface
PostSharp.Reflection.Syntax Namespace


INewObjectExpression.Arguments Property

INewObjectExpressionArguments Property
Gets the arguments passed to the constructor.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IList<IExpression> Arguments { get; }

Property Value

Type: IList IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

INewObjectExpression Interface
PostSharp.Reflection.Syntax Namespace


INewObjectExpression.Constructor Property

INewObjectExpressionConstructor Property
Gets the constructor.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ConstructorInfo Constructor { get; }

Property Value

Type: ConstructorInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

INewObjectExpression Interface
PostSharp.Reflection.Syntax Namespace


IParameterExpression Interface

IParameterExpression Interface
Expression that represents a method parameter.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IParameterExpression : IExpression,
    ISyntaxElement

The IParameterExpression type exposes the following members.

Properties
 | Name | Description
Public property | Parameter | Gets the parameter.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IParameterExpression Properties

IParameterExpression Properties

The IParameterExpression type exposes the following members.

Properties
 | Name | Description
Public property | Parameter | Gets the parameter.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IParameterExpression Interface
PostSharp.Reflection.Syntax Namespace


IParameterExpression.Parameter Property

IParameterExpressionParameter Property
Gets the parameter.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ParameterInfo Parameter { get; }

Property Value

Type: ParameterInfo
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IParameterExpression Interface
PostSharp.Reflection.Syntax Namespace


ISwitchExpression Interface

ISwitchExpression Interface
Expression that represent a switch (conditional statement with multiple branches).

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISwitchExpression : IExpression,
    ISyntaxElement

The ISwitchExpression type exposes the following members.

Properties
 | Name | Description
Public property | Condition | Gets the condition expression.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Targets | Gets the list of target blocks.
Top
Remarks

This interface represents the MSIL switch statement, not the C# statement. The main difference is that switch cases have no value: the value of a switch case is equal to its position in the list of Targets.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


ISwitchExpression Properties

ISwitchExpression Properties

The ISwitchExpression type exposes the following members.

Properties
 | Name | Description
Public property | Condition | Gets the condition expression.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Targets | Gets the list of target blocks.
Top
See Also

Reference

ISwitchExpression Interface
PostSharp.Reflection.Syntax Namespace


ISwitchExpression.Condition Property

ISwitchExpressionCondition Property
Gets the condition expression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Condition { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISwitchExpression Interface
PostSharp.Reflection.Syntax Namespace


ISwitchExpression.Targets Property

ISwitchExpressionTargets Property
Gets the list of target blocks.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IList<IExpression> Targets { get; }

Property Value

Type: IList IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISwitchExpression Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxElement Interface

ISyntaxElement Interface
Represents an element of the syntax tree representing a method body.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISyntaxElement

The ISyntaxElement type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree.
Public property | ParentMethodBody | Gets the parent method body.
Public property | SyntaxElementKind | Gets the kind of syntax element.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


ISyntaxElement Properties

ISyntaxElement Properties

The ISyntaxElement type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree.
Public property | ParentMethodBody | Gets the parent method body.
Public property | SyntaxElementKind | Gets the kind of syntax element.
Top
See Also

Reference

ISyntaxElement Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxElement.ParentElement Property

ISyntaxElementParentElement Property
Gets the parent element in the tree.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ISyntaxElement ParentElement { get; }

Property Value

Type: ISyntaxElement
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxElement Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxElement.ParentMethodBody Property

ISyntaxElementParentMethodBody Property
Gets the parent method body.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ISyntaxMethodBody ParentMethodBody { get; }

Property Value

Type: ISyntaxMethodBody
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxElement Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxElement.SyntaxElementKind Property

ISyntaxElementSyntaxElementKind Property
Gets the kind of syntax element.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
SyntaxElementKind SyntaxElementKind { get; }

Property Value

Type: SyntaxElementKind
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxElement Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxExceptionHandler Interface

ISyntaxExceptionHandler Interface
Represents an exception handler (either catch, finally or filter) attached to a block.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISyntaxExceptionHandler : ISyntaxElement

The ISyntaxExceptionHandler type exposes the following members.

Properties
 | Name | Description
Public property | ExceptionType | Gets the type of handled exception, or null if all exceptions are handled.
Public property | FilterBlock | Gets the exception filtering block, or null if all exceptions are handled.
Public property | FilterLocalVariable | Gets the local variable containing the exception in the FilterBlock.
Public property | HandlerBlock | Gets the exception handling block.
Public property | HandlerLocalVariable | Gets the local variable containing the exception in the HandlerBlock.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


ISyntaxExceptionHandler Properties

ISyntaxExceptionHandler Properties

The ISyntaxExceptionHandler type exposes the following members.

Properties
 | Name | Description
Public property | ExceptionType | Gets the type of handled exception, or null if all exceptions are handled.
Public property | FilterBlock | Gets the exception filtering block, or null if all exceptions are handled.
Public property | FilterLocalVariable | Gets the local variable containing the exception in the FilterBlock.
Public property | HandlerBlock | Gets the exception handling block.
Public property | HandlerLocalVariable | Gets the local variable containing the exception in the HandlerBlock.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

ISyntaxExceptionHandler Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxExceptionHandler.ExceptionType Property

ISyntaxExceptionHandlerExceptionType Property
Gets the type of handled exception, or null if all exceptions are handled.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Type ExceptionType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxExceptionHandler Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxExceptionHandler.FilterBlock Property

ISyntaxExceptionHandlerFilterBlock Property
Gets the exception filtering block, or null if all exceptions are handled.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IBlockExpression FilterBlock { get; }

Property Value

Type: IBlockExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxExceptionHandler Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxExceptionHandler.FilterLocalVariable Property

ISyntaxExceptionHandlerFilterLocalVariable Property
Gets the local variable containing the exception in the FilterBlock.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ISyntaxLocalVariable FilterLocalVariable { get; }

Property Value

Type: ISyntaxLocalVariable
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxExceptionHandler Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxExceptionHandler.HandlerBlock Property

ISyntaxExceptionHandlerHandlerBlock Property
Gets the exception handling block.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IBlockExpression HandlerBlock { get; }

Property Value

Type: IBlockExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxExceptionHandler Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxExceptionHandler.HandlerLocalVariable Property

ISyntaxExceptionHandlerHandlerLocalVariable Property
Gets the local variable containing the exception in the HandlerBlock.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ISyntaxLocalVariable HandlerLocalVariable { get; }

Property Value

Type: ISyntaxLocalVariable
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxExceptionHandler Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxLocalVariable Interface

ISyntaxLocalVariable Interface
Expression that represents a local variable.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISyntaxLocalVariable : ISyntaxElement

The ISyntaxLocalVariable type exposes the following members.

Properties
 | Name | Description
Public property | Name | Gets the name of the local variable.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | Slot | Gets the ordinal of the local variable.
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | VariableType | Gets the type of the local variable.
Top
Remarks

There are three kind of local variable, but consumers of this class should be oblivious to these kinds: local variables defined in user code, local variables introduced by the compiler, and pseudo-variables introduced by the AST decompiler to emulate the stack.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


ISyntaxLocalVariable Properties

ISyntaxLocalVariable Properties

The ISyntaxLocalVariable type exposes the following members.

Properties
 | Name | Description
Public property | Name | Gets the name of the local variable.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | Slot | Gets the ordinal of the local variable.
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | VariableType | Gets the type of the local variable.
Top
See Also

Reference

ISyntaxLocalVariable Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxLocalVariable.Name Property

ISyntaxLocalVariableName Property
Gets the name of the local variable.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
string Name { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxLocalVariable Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxLocalVariable.Slot Property

ISyntaxLocalVariableSlot Property
Gets the ordinal of the local variable.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Nullable<int> Slot { get; }

Property Value

Type: Nullable Int32
Remarks
Several local variables may be assigned the same slot if they are used in different scopes.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxLocalVariable Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxLocalVariable.VariableType Property

ISyntaxLocalVariableVariableType Property
Gets the type of the local variable.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Type VariableType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxLocalVariable Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxMethodBody Interface

ISyntaxMethodBody Interface
Represents the body of a method.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISyntaxMethodBody : ISyntaxElement

The ISyntaxMethodBody type exposes the following members.

Properties
 | Name | Description
Public property | Method | Gets the method whose body is represented by the current object.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | RootBlock | Gets the root instruction block of the method.
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


ISyntaxMethodBody Properties

ISyntaxMethodBody Properties

The ISyntaxMethodBody type exposes the following members.

Properties
 | Name | Description
Public property | Method | Gets the method whose body is represented by the current object.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | RootBlock | Gets the root instruction block of the method.
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

ISyntaxMethodBody Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxMethodBody.Method Property

ISyntaxMethodBodyMethod Property
Gets the method whose body is represented by the current object.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
MethodBase Method { get; }

Property Value

Type: MethodBase
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxMethodBody Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxMethodBody.RootBlock Property

ISyntaxMethodBodyRootBlock Property
Gets the root instruction block of the method.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IBlockExpression RootBlock { get; }

Property Value

Type: IBlockExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxMethodBody Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxReflectionService Interface

ISyntaxReflectionService Interface
Service that exposes the method GetMethodBody(MethodBase, SyntaxAbstractionLevel), which allows to decompile a method and get a AST representation.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISyntaxReflectionService : IService

The ISyntaxReflectionService type exposes the following members.

Methods
 | Name | Description
Public method | GetMethodBody | Decompiles a method and gets an AST representation of it.
Top
Remarks
Note Note
PostSharp Ultimate Edition is required for this feature.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


ISyntaxReflectionService Methods

ISyntaxReflectionService Methods

The ISyntaxReflectionService type exposes the following members.

Methods
 | Name | Description
Public method | GetMethodBody | Decompiles a method and gets an AST representation of it.
Top
See Also

Reference

ISyntaxReflectionService Interface
PostSharp.Reflection.Syntax Namespace


ISyntaxReflectionService.GetMethodBody Method

ISyntaxReflectionServiceGetMethodBody Method
Decompiles a method and gets an AST representation of it.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ISyntaxMethodBody GetMethodBody(
    MethodBase method,
    SyntaxAbstractionLevel abstractionLevel
)

Parameters

method
Type: System.ReflectionMethodBase
The method to decompile.
abstractionLevel
Type: PostSharp.Reflection.SyntaxSyntaxAbstractionLevel
The required level of abstraction and detail.

Return Value

Type: ISyntaxMethodBody
AST representing the method at the required level of abstraction and detail.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISyntaxReflectionService Interface
PostSharp.Reflection.Syntax Namespace


IUnaryExpression Interface

IUnaryExpression Interface
Represents an expression with a single operand.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IUnaryExpression : IExpression,
    ISyntaxElement

The IUnaryExpression type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Value | Operand of the unary expression.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IUnaryExpression Properties

IUnaryExpression Properties

The IUnaryExpression type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Value | Operand of the unary expression.
Top
See Also

Reference

IUnaryExpression Interface
PostSharp.Reflection.Syntax Namespace


IUnaryExpression.Value Property

IUnaryExpressionValue Property
Operand of the unary expression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IExpression Value { get; }

Property Value

Type: IExpression
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IUnaryExpression Interface
PostSharp.Reflection.Syntax Namespace


IValueOfExpression Interface

IValueOfExpression Interface
Expression that returns the value stored at an address. Equivalent to the C# keyword *.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IValueOfExpression : IUnaryExpression,
    IExpression, ISyntaxElement

The IValueOfExpression type exposes the following members.

Properties
 | Name | Description
Public property | Alignment | Gets the alignment of the value at the address.
Public property | IsVolatile | Determines whether if the location at the address is volatile, i.e. if it can be changed by a different thread than the current one.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Value | Operand of the unary expression. (Inherited from IUnaryExpression.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IValueOfExpression Properties

IValueOfExpression Properties

The IValueOfExpression type exposes the following members.

Properties
 | Name | Description
Public property | Alignment | Gets the alignment of the value at the address.
Public property | IsVolatile | Determines whether if the location at the address is volatile, i.e. if it can be changed by a different thread than the current one.
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Public property | Value | Operand of the unary expression. (Inherited from IUnaryExpression.)
Top
See Also

Reference

IValueOfExpression Interface
PostSharp.Reflection.Syntax Namespace


IValueOfExpression.Alignment Property

IValueOfExpressionAlignment Property
Gets the alignment of the value at the address.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
AddressAlignment Alignment { get; }

Property Value

Type: AddressAlignment
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IValueOfExpression Interface
PostSharp.Reflection.Syntax Namespace


IValueOfExpression.IsVolatile Property

IValueOfExpressionIsVolatile Property
Determines whether if the location at the address is volatile, i.e. if it can be changed by a different thread than the current one.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsVolatile { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IValueOfExpression Interface
PostSharp.Reflection.Syntax Namespace


IZeroaryExpression Interface

IZeroaryExpression Interface
Expression with no operand.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IZeroaryExpression : IExpression,
    ISyntaxElement

The IZeroaryExpression type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


IZeroaryExpression Properties

IZeroaryExpression Properties

The IZeroaryExpression type exposes the following members.

Properties
 | Name | Description
Public property | ParentElement | Gets the parent element in the tree. (Inherited from ISyntaxElement.)
Public property | ParentMethodBody | Gets the parent method body. (Inherited from ISyntaxElement.)
Public property | ReturnType | Gets the type of the return value of the current expression, or Void if the expression does not return anything (i.e. for pure instructions, for instance a goto or throw instruction). (Inherited from IExpression.)
Public property | SyntaxElementKind | Gets the kind of syntax element. (Inherited from ISyntaxElement.)
Top
See Also

Reference

IZeroaryExpression Interface
PostSharp.Reflection.Syntax Namespace


SyntaxAbstractionLevel Enumeration

SyntaxAbstractionLevel Enumeration
Enumerates the level of abstraction and the level of details produced by the AST decompiler.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum SyntaxAbstractionLevel
Members
Member name | Value | Description
Structure | 0 | Returns only the block structure (exception handlers).
ExpressionTree | 1 | Returns the expression tree.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


SyntaxElementKind Enumeration

SyntaxElementKind Enumeration
Enumeration of kinds of syntax elements (ISyntaxElement).

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public enum SyntaxElementKind
Members
Member name | Value | Description
Add | 0 | Addition (IBinaryExpression).
AddChecked | 1 | Addition with overflow checking (IBinaryExpression).
And | 2 | Bitwise And (IBinaryExpression).
ArrayIndex | 3 | Element of an array (IBinaryExpression where Left is the array and Right is the index).
ArrayLength | 4 | Length of an array (IUnaryExpression).
Assign | 5 | Assignment (IBinaryExpression).
Goto | 6 | Unconditional branch (IGotoExpression).
Variable | 7 | Local variable expression (ILocalVariableExpression).
Conditional | 8 | Conditional expression (IConditionalExpression).
Cast | 9 | Cast (IUnaryExpression where ReturnType is the destination type).
Divide | 10 | Division (IBinaryExpression).
LessThan | 11 | Less than (IBinaryExpression).
LessThanOrEqual | 12 | Less than or equal (IBinaryExpression).
Modulo | 13 | Modulo (IBinaryExpression).
MultiplyChecked | 14 | Multiply with overflow checking (IBinaryExpression).
Multiply | 15 | Multiply (IBinaryExpression).
GreaterThan | 16 | Greater than (IBinaryExpression).
GreaterThanOrEqual | 17 | Greater than (IBinaryExpression).
Substract | 18 | Substract (IBinaryExpression).
SubstractChecked | 19 | Substract with overflow checking (IBinaryExpression).
Parameter | 20 | Parameter (IParameterExpression).
This | 21 | Current object (this keyword in C#, IZeroaryExpression).
AddressOf | 22 | Referencing operator (& in C#, see IUnaryExpression).
Constant | 23 | Constant (IConstantExpression).
Equal | 24 | Equal (IBinaryExpression).
Not | 25 | Logical negation (IUnaryExpression).
Different | 26 | Different (IBinaryExpression).
ValueOf | 27 | Dereferencing operator (* in C#, see IUnaryExpression).
Or | 28 | Bitwise Or (IBinaryExpression).
Xor | 29 | Bitwise And (IBinaryExpression).
ShiftLeft | 30 | Bitwise shift to left (IBinaryExpression).
ShiftRight | 31 | Bitwise shit to right (IBinaryExpression).
Negate | 32 | Bitwise negation (IUnaryExpression).
SafeCast | 33 | Safe cast (IUnaryExpression where ReturnType is the destination type).
Unbox | 34 | Unbox (IUnaryExpression).
Throw | 35 | Throw exception (IUnaryExpression).
Field | 36 | Field (IFieldExpression).
Box | 37 | Box (IUnaryExpression).
NewArray | 38 | Create new array (INewArrayExpression).
TypedReferenceValue | 39 | Get value of typed reference (IUnaryExpression).
CheckFinite | 40 | Check that the value is finite (IUnaryExpression).
MakeTypedReference | 41 | Make typed reference (IUnaryExpression).
ArgumentList | 42 | Get argument list (IZeroaryExpression).
MethodPointer | 43 | Get pointer of method (IMethodPointerExpression).
LocalAlloc | 44 | Allocate on local stack (IUnaryExpression).
DefaultValue | 45 | Default value for given type (IMetadataExpression).
CopyBuffer | 46 | Copy buffer (ICopyBufferExpression).
InitBuffer | 47 | Initialize buffer (IInitBufferExpression).
LoadToken | 48 | Load metadata token (IMetadataExpression).
SizeOf | 49 | Size of type (IMetadataExpression).
TypedReferenceType | 50 | Get type of typed reference (IUnaryExpression).
ConvertChecked | 51 | Convert to integral type with overflow check (IUnaryExpression).
Convert | 52 | Convert to integral type (IUnaryExpression).
MethodCall | 53 | Method call (IMethodCallExpression).
Return | 54 | Return (IUnaryExpression).
NewObject | 55 | Creates new object (INewObjectExpression).
Switch | 56 | Switch (ISwitchExpression).
Block | 57 | Instruction block (IBlockExpression).
CatchHandler | 58 | Catch exception handler (ISyntaxExceptionHandler).
FilterHandler | 59 | Filter exception handler (ISyntaxExceptionHandler).
FinallyHandler | 60 | Finally exception handler (ISyntaxExceptionHandler).
MethodBody | 61 | Method body (ISyntaxMethodBody).
LocalVariableDefinition | 62 | Local variable definition (ISyntaxLocalVariable).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter Class

SyntaxTreeFormatter Class
Formats an ISyntaxElement to a textual representation, for debugging purposes.
Inheritance Hierarchy
SystemObject
PostSharp.Reflection.SyntaxSyntaxTreeVisitor
PostSharp.Reflection.SyntaxSyntaxTreeFormatter

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class SyntaxTreeFormatter : SyntaxTreeVisitor

The SyntaxTreeFormatter type exposes the following members.

Constructors
 | Name | Description
Public method | SyntaxTreeFormatter | Initializes a new SyntaxTreeFormatter.
Top
Methods
 | Name | Description
Public method | VisitAddressOfExpression | Visits an expression of type IAddressOfExpression and, recursively, all children elements. (Inherited from SyntaxTreeVisitor.)
Public method | VisitBinaryExpression | Visits an expression of type IBinaryExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitBinaryExpression(IBinaryExpression).)
Public method | VisitBlockExpression | Visits an instruction block and, recursively, all syntax nodes. (Overrides SyntaxTreeVisitorVisitBlockExpression(IBlockExpression).)
Public method | VisitConditionalExpression | Visits an expression of type IUnaryExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitConditionalExpression(IConditionalExpression).)
Public method | VisitConstantExpression | Visits an expression of type IGotoExpression. (Overrides SyntaxTreeVisitorVisitConstantExpression(IConstantExpression).)
Public method | VisitCopyBufferExpression | Visits an expression of type ICopyBufferExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitCopyBufferExpression(ICopyBufferExpression).)
Public method | VisitExceptionHandler | Visits an exception handler and, recursively, the HandlerBlock and FilterBlock (if any). (Overrides SyntaxTreeVisitorVisitExceptionHandler(ISyntaxExceptionHandler).)
Public method | VisitFieldExpression | Visits an expression of type IFieldExpression. (Overrides SyntaxTreeVisitorVisitFieldExpression(IFieldExpression).)
Public method | VisitGotoExpression | Visits an expression of type IGotoExpression. (Overrides SyntaxTreeVisitorVisitGotoExpression(IGotoExpression).)
Public method | VisitInitBufferExpression | Visits an expression of type IInitBufferExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitInitBufferExpression(IInitBufferExpression).)
Public method | VisitLocalVariable | Visits a local variable definition. (Inherited from SyntaxTreeVisitor.)
Public method | VisitMetadataExpression | Visits an expression of type IMetadataExpression. (Overrides SyntaxTreeVisitorVisitMetadataExpression(IMetadataExpression).)
Public method | VisitMethodBody | Visits a method body and, recursively, all syntax nodes. (Inherited from SyntaxTreeVisitor.)
Public method | VisitMethodCallExpression | Visits an expression of type IMethodCallExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitMethodCallExpression(IMethodCallExpression).)
Public method | VisitMethodPointerExpression | Visits an expression of type IMethodPointerExpression and, recursively, all children elements. (Inherited from SyntaxTreeVisitor.)
Public method | VisitNewArrayExpression | Visits an expression of type INewArrayExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitNewArrayExpression(INewArrayExpression).)
Public method | VisitNewObjectExpression | Visits an expression of type INewObjectExpression and, recursively, all children elements. (Inherited from SyntaxTreeVisitor.)
Public method | VisitParameterExpression | Visits an expression of type IParameterExpression. (Overrides SyntaxTreeVisitorVisitParameterExpression(IParameterExpression).)
Public method | VisitSwitchExpression | Visits an expression of type ISwitchExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitSwitchExpression(ISwitchExpression).)
Public method | VisitSyntaxElement | Visits a syntax element and, recursively, all children elements. (Inherited from SyntaxTreeVisitor.)
Public method | VisitUnaryExpression | Visits an expression of type IUnaryExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitUnaryExpression(IUnaryExpression).)
Public method | VisitValueOfExpression | Visits an expression of type IValueOfExpression and, recursively, all children elements. (Inherited from SyntaxTreeVisitor.)
Public method | VisitVariableExpression | Visits an expression of type ILocalVariableExpression. (Overrides SyntaxTreeVisitorVisitVariableExpression(ILocalVariableExpression).)
Public method | VisitZeroaryExpression | Visits an expression of type IZeroaryExpression. (Overrides SyntaxTreeVisitorVisitZeroaryExpression(IZeroaryExpression).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter Constructor

SyntaxTreeFormatter Constructor
Initializes a new SyntaxTreeFormatter.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SyntaxTreeFormatter(
    TextWriter writer
)

Parameters

writer
Type: System.IOTextWriter
A TextWriter where the textual representation will be written.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter Methods

SyntaxTreeFormatter Methods

The SyntaxTreeFormatter type exposes the following members.

Methods
 | Name | Description
Public method | VisitAddressOfExpression | Visits an expression of type IAddressOfExpression and, recursively, all children elements. (Inherited from SyntaxTreeVisitor.)
Public method | VisitBinaryExpression | Visits an expression of type IBinaryExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitBinaryExpression(IBinaryExpression).)
Public method | VisitBlockExpression | Visits an instruction block and, recursively, all syntax nodes. (Overrides SyntaxTreeVisitorVisitBlockExpression(IBlockExpression).)
Public method | VisitConditionalExpression | Visits an expression of type IUnaryExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitConditionalExpression(IConditionalExpression).)
Public method | VisitConstantExpression | Visits an expression of type IGotoExpression. (Overrides SyntaxTreeVisitorVisitConstantExpression(IConstantExpression).)
Public method | VisitCopyBufferExpression | Visits an expression of type ICopyBufferExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitCopyBufferExpression(ICopyBufferExpression).)
Public method | VisitExceptionHandler | Visits an exception handler and, recursively, the HandlerBlock and FilterBlock (if any). (Overrides SyntaxTreeVisitorVisitExceptionHandler(ISyntaxExceptionHandler).)
Public method | VisitFieldExpression | Visits an expression of type IFieldExpression. (Overrides SyntaxTreeVisitorVisitFieldExpression(IFieldExpression).)
Public method | VisitGotoExpression | Visits an expression of type IGotoExpression. (Overrides SyntaxTreeVisitorVisitGotoExpression(IGotoExpression).)
Public method | VisitInitBufferExpression | Visits an expression of type IInitBufferExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitInitBufferExpression(IInitBufferExpression).)
Public method | VisitLocalVariable | Visits a local variable definition. (Inherited from SyntaxTreeVisitor.)
Public method | VisitMetadataExpression | Visits an expression of type IMetadataExpression. (Overrides SyntaxTreeVisitorVisitMetadataExpression(IMetadataExpression).)
Public method | VisitMethodBody | Visits a method body and, recursively, all syntax nodes. (Inherited from SyntaxTreeVisitor.)
Public method | VisitMethodCallExpression | Visits an expression of type IMethodCallExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitMethodCallExpression(IMethodCallExpression).)
Public method | VisitMethodPointerExpression | Visits an expression of type IMethodPointerExpression and, recursively, all children elements. (Inherited from SyntaxTreeVisitor.)
Public method | VisitNewArrayExpression | Visits an expression of type INewArrayExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitNewArrayExpression(INewArrayExpression).)
Public method | VisitNewObjectExpression | Visits an expression of type INewObjectExpression and, recursively, all children elements. (Inherited from SyntaxTreeVisitor.)
Public method | VisitParameterExpression | Visits an expression of type IParameterExpression. (Overrides SyntaxTreeVisitorVisitParameterExpression(IParameterExpression).)
Public method | VisitSwitchExpression | Visits an expression of type ISwitchExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitSwitchExpression(ISwitchExpression).)
Public method | VisitSyntaxElement | Visits a syntax element and, recursively, all children elements. (Inherited from SyntaxTreeVisitor.)
Public method | VisitUnaryExpression | Visits an expression of type IUnaryExpression and, recursively, all children elements. (Overrides SyntaxTreeVisitorVisitUnaryExpression(IUnaryExpression).)
Public method | VisitValueOfExpression | Visits an expression of type IValueOfExpression and, recursively, all children elements. (Inherited from SyntaxTreeVisitor.)
Public method | VisitVariableExpression | Visits an expression of type ILocalVariableExpression. (Overrides SyntaxTreeVisitorVisitVariableExpression(ILocalVariableExpression).)
Public method | VisitZeroaryExpression | Visits an expression of type IZeroaryExpression. (Overrides SyntaxTreeVisitorVisitZeroaryExpression(IZeroaryExpression).)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitBinaryExpression Method

SyntaxTreeFormatterVisitBinaryExpression Method
Visits an expression of type IBinaryExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitBinaryExpression(
    IBinaryExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIBinaryExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitBlockExpression Method

SyntaxTreeFormatterVisitBlockExpression Method
Visits an instruction block and, recursively, all syntax nodes.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitBlockExpression(
    IBlockExpression instructionBlock
)

Parameters

instructionBlock
Type: PostSharp.Reflection.SyntaxIBlockExpression
The method body to be visited.

Return Value

Type: Object
instructionBlock, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitConditionalExpression Method

SyntaxTreeFormatterVisitConditionalExpression Method
Visits an expression of type IUnaryExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitConditionalExpression(
    IConditionalExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIConditionalExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitConstantExpression Method

SyntaxTreeFormatterVisitConstantExpression Method
Visits an expression of type IGotoExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitConstantExpression(
    IConstantExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIConstantExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitCopyBufferExpression Method

SyntaxTreeFormatterVisitCopyBufferExpression Method
Visits an expression of type ICopyBufferExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitCopyBufferExpression(
    ICopyBufferExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxICopyBufferExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitExceptionHandler Method

SyntaxTreeFormatterVisitExceptionHandler Method
Visits an exception handler and, recursively, the HandlerBlock and FilterBlock (if any).

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitExceptionHandler(
    ISyntaxExceptionHandler exceptionHandler
)

Parameters

exceptionHandler
Type: PostSharp.Reflection.SyntaxISyntaxExceptionHandler
The exception handler to be visited.

Return Value

Type: Object
exceptionHandler, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitFieldExpression Method

SyntaxTreeFormatterVisitFieldExpression Method
Visits an expression of type IFieldExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitFieldExpression(
    IFieldExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIFieldExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitGotoExpression Method

SyntaxTreeFormatterVisitGotoExpression Method
Visits an expression of type IGotoExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitGotoExpression(
    IGotoExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIGotoExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitInitBufferExpression Method

SyntaxTreeFormatterVisitInitBufferExpression Method
Visits an expression of type IInitBufferExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitInitBufferExpression(
    IInitBufferExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIInitBufferExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitMetadataExpression Method

SyntaxTreeFormatterVisitMetadataExpression Method
Visits an expression of type IMetadataExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitMetadataExpression(
    IMetadataExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIMetadataExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitMethodCallExpression Method

SyntaxTreeFormatterVisitMethodCallExpression Method
Visits an expression of type IMethodCallExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitMethodCallExpression(
    IMethodCallExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIMethodCallExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitNewArrayExpression Method

SyntaxTreeFormatterVisitNewArrayExpression Method
Visits an expression of type INewArrayExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitNewArrayExpression(
    INewArrayExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxINewArrayExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitParameterExpression Method

SyntaxTreeFormatterVisitParameterExpression Method
Visits an expression of type IParameterExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitParameterExpression(
    IParameterExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIParameterExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitSwitchExpression Method

SyntaxTreeFormatterVisitSwitchExpression Method
Visits an expression of type ISwitchExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitSwitchExpression(
    ISwitchExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxISwitchExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitUnaryExpression Method

SyntaxTreeFormatterVisitUnaryExpression Method
Visits an expression of type IUnaryExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitUnaryExpression(
    IUnaryExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIUnaryExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitVariableExpression Method

SyntaxTreeFormatterVisitVariableExpression Method
Visits an expression of type ILocalVariableExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitVariableExpression(
    ILocalVariableExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxILocalVariableExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeFormatter.VisitZeroaryExpression Method

SyntaxTreeFormatterVisitZeroaryExpression Method
Visits an expression of type IZeroaryExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override Object VisitZeroaryExpression(
    IZeroaryExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIZeroaryExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeFormatter Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor Class

SyntaxTreeVisitor Class
Abstract implementation of a visitor of method bodies (ISyntaxMethodBody and IExpression).
Inheritance Hierarchy
SystemObject
PostSharp.Reflection.SyntaxSyntaxTreeVisitor
PostSharp.Reflection.SyntaxSyntaxTreeFormatter

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class SyntaxTreeVisitor

The SyntaxTreeVisitor type exposes the following members.

Constructors
 | Name | Description
Protected method | SyntaxTreeVisitor | Initializes a new instance of the SyntaxTreeVisitor class
Top
Methods
 | Name | Description
Public method | VisitAddressOfExpression | Visits an expression of type IAddressOfExpression and, recursively, all children elements.
Public method | VisitBinaryExpression | Visits an expression of type IBinaryExpression and, recursively, all children elements.
Public method | VisitBlockExpression | Visits an instruction block and, recursively, all syntax nodes.
Public method | VisitConditionalExpression | Visits an expression of type IUnaryExpression and, recursively, all children elements.
Public method | VisitConstantExpression | Visits an expression of type IGotoExpression.
Public method | VisitCopyBufferExpression | Visits an expression of type ICopyBufferExpression and, recursively, all children elements.
Public method | VisitExceptionHandler | Visits an exception handler and, recursively, the HandlerBlock and FilterBlock (if any).
Public method | VisitFieldExpression | Visits an expression of type IFieldExpression.
Public method | VisitGotoExpression | Visits an expression of type IGotoExpression.
Public method | VisitInitBufferExpression | Visits an expression of type IInitBufferExpression and, recursively, all children elements.
Public method | VisitLocalVariable | Visits a local variable definition.
Public method | VisitMetadataExpression | Visits an expression of type IMetadataExpression.
Public method | VisitMethodBody | Visits a method body and, recursively, all syntax nodes.
Public method | VisitMethodCallExpression | Visits an expression of type IMethodCallExpression and, recursively, all children elements.
Public method | VisitMethodPointerExpression | Visits an expression of type IMethodPointerExpression and, recursively, all children elements.
Public method | VisitNewArrayExpression | Visits an expression of type INewArrayExpression and, recursively, all children elements.
Public method | VisitNewObjectExpression | Visits an expression of type INewObjectExpression and, recursively, all children elements.
Public method | VisitParameterExpression | Visits an expression of type IParameterExpression.
Public method | VisitSwitchExpression | Visits an expression of type ISwitchExpression and, recursively, all children elements.
Public method | VisitSyntaxElement | Visits a syntax element and, recursively, all children elements.
Public method | VisitUnaryExpression | Visits an expression of type IUnaryExpression and, recursively, all children elements.
Public method | VisitValueOfExpression | Visits an expression of type IValueOfExpression and, recursively, all children elements.
Public method | VisitVariableExpression | Visits an expression of type ILocalVariableExpression.
Public method | VisitZeroaryExpression | Visits an expression of type IZeroaryExpression.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks

This class provides an abstract implementation, which only ensures that the proper visiting method gets called for every node of the tree, without any other effect. Concrete implementations typically override specific visiting methods, and call the base implementation to ensure that children nodes are being processed too.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor Constructor

SyntaxTreeVisitor Constructor
Initializes a new instance of the SyntaxTreeVisitor class

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected SyntaxTreeVisitor()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor Methods

SyntaxTreeVisitor Methods

The SyntaxTreeVisitor type exposes the following members.

Methods
 | Name | Description
Public method | VisitAddressOfExpression | Visits an expression of type IAddressOfExpression and, recursively, all children elements.
Public method | VisitBinaryExpression | Visits an expression of type IBinaryExpression and, recursively, all children elements.
Public method | VisitBlockExpression | Visits an instruction block and, recursively, all syntax nodes.
Public method | VisitConditionalExpression | Visits an expression of type IUnaryExpression and, recursively, all children elements.
Public method | VisitConstantExpression | Visits an expression of type IGotoExpression.
Public method | VisitCopyBufferExpression | Visits an expression of type ICopyBufferExpression and, recursively, all children elements.
Public method | VisitExceptionHandler | Visits an exception handler and, recursively, the HandlerBlock and FilterBlock (if any).
Public method | VisitFieldExpression | Visits an expression of type IFieldExpression.
Public method | VisitGotoExpression | Visits an expression of type IGotoExpression.
Public method | VisitInitBufferExpression | Visits an expression of type IInitBufferExpression and, recursively, all children elements.
Public method | VisitLocalVariable | Visits a local variable definition.
Public method | VisitMetadataExpression | Visits an expression of type IMetadataExpression.
Public method | VisitMethodBody | Visits a method body and, recursively, all syntax nodes.
Public method | VisitMethodCallExpression | Visits an expression of type IMethodCallExpression and, recursively, all children elements.
Public method | VisitMethodPointerExpression | Visits an expression of type IMethodPointerExpression and, recursively, all children elements.
Public method | VisitNewArrayExpression | Visits an expression of type INewArrayExpression and, recursively, all children elements.
Public method | VisitNewObjectExpression | Visits an expression of type INewObjectExpression and, recursively, all children elements.
Public method | VisitParameterExpression | Visits an expression of type IParameterExpression.
Public method | VisitSwitchExpression | Visits an expression of type ISwitchExpression and, recursively, all children elements.
Public method | VisitSyntaxElement | Visits a syntax element and, recursively, all children elements.
Public method | VisitUnaryExpression | Visits an expression of type IUnaryExpression and, recursively, all children elements.
Public method | VisitValueOfExpression | Visits an expression of type IValueOfExpression and, recursively, all children elements.
Public method | VisitVariableExpression | Visits an expression of type ILocalVariableExpression.
Public method | VisitZeroaryExpression | Visits an expression of type IZeroaryExpression.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitAddressOfExpression Method

SyntaxTreeVisitorVisitAddressOfExpression Method
Visits an expression of type IAddressOfExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitAddressOfExpression(
    IAddressOfExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIAddressOfExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitBinaryExpression Method

SyntaxTreeVisitorVisitBinaryExpression Method
Visits an expression of type IBinaryExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitBinaryExpression(
    IBinaryExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIBinaryExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitBlockExpression Method

SyntaxTreeVisitorVisitBlockExpression Method
Visits an instruction block and, recursively, all syntax nodes.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitBlockExpression(
    IBlockExpression instructionBlock
)

Parameters

instructionBlock
Type: PostSharp.Reflection.SyntaxIBlockExpression
The method body to be visited.

Return Value

Type: Object
instructionBlock, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitConditionalExpression Method

SyntaxTreeVisitorVisitConditionalExpression Method
Visits an expression of type IUnaryExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitConditionalExpression(
    IConditionalExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIConditionalExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitConstantExpression Method

SyntaxTreeVisitorVisitConstantExpression Method
Visits an expression of type IGotoExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitConstantExpression(
    IConstantExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIConstantExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitCopyBufferExpression Method

SyntaxTreeVisitorVisitCopyBufferExpression Method
Visits an expression of type ICopyBufferExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitCopyBufferExpression(
    ICopyBufferExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxICopyBufferExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitExceptionHandler Method

SyntaxTreeVisitorVisitExceptionHandler Method
Visits an exception handler and, recursively, the HandlerBlock and FilterBlock (if any).

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitExceptionHandler(
    ISyntaxExceptionHandler exceptionHandler
)

Parameters

exceptionHandler
Type: PostSharp.Reflection.SyntaxISyntaxExceptionHandler
The exception handler to be visited.

Return Value

Type: Object
exceptionHandler, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitFieldExpression Method

SyntaxTreeVisitorVisitFieldExpression Method
Visits an expression of type IFieldExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitFieldExpression(
    IFieldExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIFieldExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitGotoExpression Method

SyntaxTreeVisitorVisitGotoExpression Method
Visits an expression of type IGotoExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitGotoExpression(
    IGotoExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIGotoExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitInitBufferExpression Method

SyntaxTreeVisitorVisitInitBufferExpression Method
Visits an expression of type IInitBufferExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitInitBufferExpression(
    IInitBufferExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIInitBufferExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitLocalVariable Method

SyntaxTreeVisitorVisitLocalVariable Method
Visits a local variable definition.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitLocalVariable(
    ISyntaxLocalVariable localVariable
)

Parameters

localVariable
Type: PostSharp.Reflection.SyntaxISyntaxLocalVariable
The local variable to be visited.

Return Value

Type: Object
localVariable, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitMetadataExpression Method

SyntaxTreeVisitorVisitMetadataExpression Method
Visits an expression of type IMetadataExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitMetadataExpression(
    IMetadataExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIMetadataExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitMethodBody Method

SyntaxTreeVisitorVisitMethodBody Method
Visits a method body and, recursively, all syntax nodes.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitMethodBody(
    ISyntaxMethodBody methodBody
)

Parameters

methodBody
Type: PostSharp.Reflection.SyntaxISyntaxMethodBody
The method body to be visited.

Return Value

Type: Object
methodBody, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitMethodCallExpression Method

SyntaxTreeVisitorVisitMethodCallExpression Method
Visits an expression of type IMethodCallExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitMethodCallExpression(
    IMethodCallExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIMethodCallExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitMethodPointerExpression Method

SyntaxTreeVisitorVisitMethodPointerExpression Method
Visits an expression of type IMethodPointerExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitMethodPointerExpression(
    IMethodPointerExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIMethodPointerExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitNewArrayExpression Method

SyntaxTreeVisitorVisitNewArrayExpression Method
Visits an expression of type INewArrayExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitNewArrayExpression(
    INewArrayExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxINewArrayExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitNewObjectExpression Method

SyntaxTreeVisitorVisitNewObjectExpression Method
Visits an expression of type INewObjectExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitNewObjectExpression(
    INewObjectExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxINewObjectExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitParameterExpression Method

SyntaxTreeVisitorVisitParameterExpression Method
Visits an expression of type IParameterExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitParameterExpression(
    IParameterExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIParameterExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitSwitchExpression Method

SyntaxTreeVisitorVisitSwitchExpression Method
Visits an expression of type ISwitchExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitSwitchExpression(
    ISwitchExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxISwitchExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitSyntaxElement Method

SyntaxTreeVisitorVisitSyntaxElement Method
Visits a syntax element and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitSyntaxElement(
    ISyntaxElement syntaxElement
)

Parameters

syntaxElement
Type: PostSharp.Reflection.SyntaxISyntaxElement
The element to be visited.

Return Value

Type: Object
syntaxElement, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitUnaryExpression Method

SyntaxTreeVisitorVisitUnaryExpression Method
Visits an expression of type IUnaryExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitUnaryExpression(
    IUnaryExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIUnaryExpression
The element to be visited.

Return Value

Type: Object
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitValueOfExpression Method

SyntaxTreeVisitorVisitValueOfExpression Method
Visits an expression of type IValueOfExpression and, recursively, all children elements.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitValueOfExpression(
    IValueOfExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIValueOfExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitVariableExpression Method

SyntaxTreeVisitorVisitVariableExpression Method
Visits an expression of type ILocalVariableExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitVariableExpression(
    ILocalVariableExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxILocalVariableExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


SyntaxTreeVisitor.VisitZeroaryExpression Method

SyntaxTreeVisitorVisitZeroaryExpression Method
Visits an expression of type IZeroaryExpression.

Namespace: PostSharp.Reflection.Syntax
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object VisitZeroaryExpression(
    IZeroaryExpression expression
)

Parameters

expression
Type: PostSharp.Reflection.SyntaxIZeroaryExpression
The element to be visited.

Return Value

Type: Object
expression, unless the override returns something else.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SyntaxTreeVisitor Class
PostSharp.Reflection.Syntax Namespace


PostSharp.Serialization Namespace

PostSharp.Serialization Namespace
The PostSharp.Serialization namespace implements a portable serializer.
Classes
 | Class | Description
Public class | ActivatorSecurityToken | Security token passed to the CreateInstance(Type, ActivatorSecurityToken) method of the IActivator interface.
Public class | ActivatorTypeAttribute | Custom attribute that, when applied to an assembly, points to a type in the assembly implementing IActivator.
Public class | ImportSerializerAttribute | Custom attribute that, when applied to a serializable type, specifies that the serializer of this type has a dependency on another serializer. The custom attribute can be applied at assembly level; it then applies to all serializable types in this assembly.
Public class | PNonSerializedAttribute | Custom attribute that, when applied to a field of a class annotated with PSerializableAttribute, specifies that this field should not be serialized.
Public class | PortableFormatter | A serializer designed to serialize the internal structure of types with support for cyclic object graphs. The PortableFormatter is very similar in function and design to the BinaryFormatter, but is supported on most platforms and does not require full trust. Both formatters have similar usage: SerializableAttribute is replaced by PSerializableAttribute and NonSerializedAttribute by PNonSerializedAttribute.
Public class | PortableSerializationBinder | Binds types to names and names to types. Used by the PortableFormatter.
Public class | PortableSerializationException | Exception thrown by the PortableFormatter.
Public class | PSerializableAttribute | Custom attribute that, when applied to a type, causes PostSharp to generate a serializer for use by the PortableFormatter.
Public class | ReferenceTypeSerializer | Base serializer for all reference types.
Public class | SerializationServices | Provides some utility method for the current namespace.
Public class | SerializerAttribute | Custom attribute that, when applied to a type, specifies its serializer for use by the PortableFormatter.
Public class | SerializerFactoryProvider | Provides instances of the ISerializerFactory interface for object types that have been previously registered using AddSerializer(Type, Type).
Public class | ValueTypeSerializerT | Base serializer for all value types.
Structures
 | Structure | Description
Public structure | DottedString | Encapsulates dotted strings such as namespaces and type names, so their serialization by PortableFormatter can be optimized.
Interfaces
 | Interface | Description
Public interface | IActivator | Exposes a method CreateInstance(Type, ActivatorSecurityToken), which allows to create an instance of a type using the Activator facility.
Public interface | IArgumentsReader | Provides read access to the collection of deserialized arguments.
Public interface | IArgumentsWriter | Provides write access to a collection of arguments that need to be serialized.
Public interface | ISerializationCallback | Interface that can be implemented by serializable classes. It defines methods OnDeserialized and OnSerializing called during serialization.
Public interface | ISerializer | Defines the semantics of an object serializer.
Public interface | ISerializerDiscoverer | Exposes a method that allows implementations of the interface to discover serializer types for each type being serialized.
Public interface | ISerializerFactory | Defines a method CreateSerializer(Type), which creates instances of the ISerializer interface for given object types.
Public interface | ISerializerFactoryProvider | Provides instances of the ISerializerFactory interface given the object type.


ActivatorSecurityToken Class

ActivatorSecurityToken Class
Security token passed to the CreateInstance(Type, ActivatorSecurityToken) method of the IActivator interface.
Inheritance Hierarchy
SystemObject
PostSharp.SerializationActivatorSecurityToken

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ActivatorSecurityToken
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


ActivatorTypeAttribute Class

ActivatorTypeAttribute Class
Custom attribute that, when applied to an assembly, points to a type in the assembly implementing IActivator.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.SerializationActivatorTypeAttribute

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ActivatorTypeAttribute : Attribute

The ActivatorTypeAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ActivatorTypeAttribute | Initializes a new ActivatorTypeAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ActivatorType | Gets the activator type.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


ActivatorTypeAttribute Constructor

ActivatorTypeAttribute Constructor
Initializes a new ActivatorTypeAttribute.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ActivatorTypeAttribute(
    Type activatorType
)

Parameters

activatorType
Type: SystemType
A type derived from IActivator in the current assembly. This type must be public and have a default constructor.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ActivatorTypeAttribute Class
PostSharp.Serialization Namespace


ActivatorTypeAttribute Methods

ActivatorTypeAttribute Methods

The ActivatorTypeAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ActivatorTypeAttribute Class
PostSharp.Serialization Namespace


ActivatorTypeAttribute Properties

ActivatorTypeAttribute Properties

The ActivatorTypeAttribute type exposes the following members.

Properties
 | Name | Description
Public property | ActivatorType | Gets the activator type.
Top
See Also

Reference

ActivatorTypeAttribute Class
PostSharp.Serialization Namespace


ActivatorTypeAttribute.ActivatorType Property

ActivatorTypeAttributeActivatorType Property
Gets the activator type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type ActivatorType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ActivatorTypeAttribute Class
PostSharp.Serialization Namespace


DottedString Structure

DottedString Structure
Encapsulates dotted strings such as namespaces and type names, so their serialization by PortableFormatter can be optimized.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public struct DottedString : IEquatable<DottedString>

The DottedString type exposes the following members.

Constructors
 | Name | Description
Public method | DottedString | Initializes a new DottedString.
Top
Methods
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(DottedString) | Determines whether the currentDottedString is equal to another one.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | ToString | Returns the fully qualified type name of this instance. (Overrides ValueTypeToString.)
Top
Operators
Name | Description
(String to DottedString) | Converts a String into a DottedString.
(DottedString to String) | Converts a DottedString into a String.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
Null | Gets an instance of DottedString representing a null string.
Top
Properties
 | Name | Description
Public property | IsNull | Determines whether the current DottedString represents a null string.
Public property | Value | Gets the string encapsulated by the current DottedString.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


DottedString Constructor

DottedString Constructor
Initializes a new DottedString.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public DottedString(
    string value
)

Parameters

value
Type: SystemString
Value.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString Fields

DottedString Fields

The DottedString type exposes the following members.

Fields
Name | Description
Null | Gets an instance of DottedString representing a null string.
Top
See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString.Null Field

DottedStringNull Field
Gets an instance of DottedString representing a null string.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly DottedString Null

Field Value

Type: DottedString
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString Methods

DottedString Methods

The DottedString type exposes the following members.

Methods
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(DottedString) | Determines whether the currentDottedString is equal to another one.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method | ToString | Returns the fully qualified type name of this instance. (Overrides ValueTypeToString.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString.Equals Method

DottedStringEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(DottedString) | Determines whether the currentDottedString is equal to another one.
Top
See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString.Equals Method (Object)

DottedStringEquals Method (Object)
Indicates whether this instance and a specified object are equal.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool Equals(
    Object obj
)

Parameters

obj
Type: SystemObject
Another object to compare to.

Return Value

Type: Boolean
true if obj and this instance are the same type and represent the same value; otherwise, false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DottedString Structure
Equals Overload
PostSharp.Serialization Namespace


DottedString.Equals Method (DottedString)

DottedStringEquals Method (DottedString)
Determines whether the currentDottedString is equal to another one.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Equals(
    DottedString other
)

Parameters

other
Type: PostSharp.SerializationDottedString
Another DottedString.

Return Value

Type: Boolean
true if the current DottedString equals other, otherwise false.

Implements

IEquatableTEquals(T)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DottedString Structure
Equals Overload
PostSharp.Serialization Namespace


DottedString.GetHashCode Method

DottedStringGetHashCode Method
Returns the hash code for this instance.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int GetHashCode()

Return Value

Type: Int32
A 32-bit signed integer that is the hash code for this instance.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString.ToString Method

DottedStringToString Method
Returns the fully qualified type name of this instance.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override string ToString()

Return Value

Type: String
A String containing a fully qualified type name.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString Type Conversions

DottedString Type Conversions
Operators
Name | Description
(String to DottedString) | Converts a String into a DottedString.
(DottedString to String) | Converts a DottedString into a String.
Top
See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString Implicit Conversion Operators

DottedString Conversion Operators
Overload List
Name | Description
(String to DottedString) | Converts a String into a DottedString.
(DottedString to String) | Converts a DottedString into a String.
Top
See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString Implicit Conversion (String to DottedString)

DottedString Conversion (String to DottedString)
Converts a String into a DottedString.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static implicit operator DottedString (
    string str
)

Parameters

str
Type: SystemString
A String.

Return Value

Type: DottedString
A DottedString encapsulating str.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DottedString Structure
Overload
PostSharp.Serialization Namespace


DottedString Implicit Conversion (DottedString to String)

DottedString Conversion (DottedString to String)
Converts a DottedString into a String.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static implicit operator string (
    DottedString dottedString
)

Parameters

dottedString
Type: PostSharp.SerializationDottedString
A DottedString.

Return Value

Type: String
The String encapsulated by dottedString.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DottedString Structure
Overload
PostSharp.Serialization Namespace


DottedString Properties

DottedString Properties

The DottedString type exposes the following members.

Properties
 | Name | Description
Public property | IsNull | Determines whether the current DottedString represents a null string.
Public property | Value | Gets the string encapsulated by the current DottedString.
Top
See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString.IsNull Property

DottedStringIsNull Property
Determines whether the current DottedString represents a null string.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool IsNull { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


DottedString.Value Property

DottedStringValue Property
Gets the string encapsulated by the current DottedString.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public string Value { get; }

Property Value

Type: String
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

DottedString Structure
PostSharp.Serialization Namespace


IActivator Interface

IActivator Interface
Exposes a method CreateInstance(Type, ActivatorSecurityToken), which allows to create an instance of a type using the Activator facility.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IActivator

The IActivator type exposes the following members.

Methods
 | Name | Description
Public method | CreateInstance | Creates an instance of a give type.
Top
Remarks

PostSharp generates implementations of this interface in each assembly that contains serializable classes. It allows to create objects in the security context of this assembly (instead of from the security context of PostSharp.dll).

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


IActivator Methods

IActivator Methods

The IActivator type exposes the following members.

Methods
 | Name | Description
Public method | CreateInstance | Creates an instance of a give type.
Top
See Also

Reference

IActivator Interface
PostSharp.Serialization Namespace


IActivator.CreateInstance Method

IActivatorCreateInstance Method
Creates an instance of a give type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object CreateInstance(
    Type objectType,
    ActivatorSecurityToken securityToken
)

Parameters

objectType
Type: SystemType
Type of object whose an instance is requested.
securityToken
Type: PostSharp.SerializationActivatorSecurityToken
A security token.

Return Value

Type: Object
A new instance of type objectType.
Remarks

For security reasons, implementations should throw an exception or return null if securityToken is nuill.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IActivator Interface
PostSharp.Serialization Namespace


IArgumentsReader Interface

IArgumentsReader Interface
Provides read access to the collection of deserialized arguments.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IArgumentsReader

The IArgumentsReader type exposes the following members.

Methods
 | Name | Description
Public method | GetValueT | Reads a value from the collection, and throws an exception if the value does not exist.
Public method | TryGetValueT | Attempts to read a value from the collection, and does not throw an exception if the value does not exist.
Top
Properties
 | Name | Description
Public property | MetadataDispenser | When deserializing PostSharp aspects, gets the IMetadataDispenser corresponding to the MetadataEmitter used at build time.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


IArgumentsReader Methods

IArgumentsReader Methods

The IArgumentsReader type exposes the following members.

Methods
 | Name | Description
Public method | GetValueT | Reads a value from the collection, and throws an exception if the value does not exist.
Public method | TryGetValueT | Attempts to read a value from the collection, and does not throw an exception if the value does not exist.
Top
See Also

Reference

IArgumentsReader Interface
PostSharp.Serialization Namespace


IArgumentsReader.GetValue(T) Method

IArgumentsReaderGetValueT Method
Reads a value from the collection, and throws an exception if the value does not exist.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
T GetValue<T>(
    string name,
    string scope = null
)

Parameters

name
Type: SystemString
Argument name.
scope (Optional)
Type: SystemString
An optional prefix of name, similar to a namespace.

Type Parameters

T
Value type.

Return Value

Type: T
The value of the argument named name in the given optional scope.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IArgumentsReader Interface
PostSharp.Serialization Namespace


IArgumentsReader.TryGetValue(T) Method

IArgumentsReaderTryGetValueT Method
Attempts to read a value from the collection, and does not throw an exception if the value does not exist.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool TryGetValue<T>(
    string name,
    out T value,
    string scope = null
)

Parameters

name
Type: SystemString
Argument name.
value
Type: T
At output, set to the value of the argument named name in the given optional scope.
scope (Optional)
Type: SystemString
An optional prefix of name, similar to a namespace.

Type Parameters

T
Value type.

Return Value

Type: Boolean
true if the value is defined, otherwise false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IArgumentsReader Interface
PostSharp.Serialization Namespace


IArgumentsReader Properties

IArgumentsReader Properties

The IArgumentsReader type exposes the following members.

Properties
 | Name | Description
Public property | MetadataDispenser | When deserializing PostSharp aspects, gets the IMetadataDispenser corresponding to the MetadataEmitter used at build time.
Top
See Also

Reference

IArgumentsReader Interface
PostSharp.Serialization Namespace


IArgumentsReader.MetadataDispenser Property

IArgumentsReaderMetadataDispenser Property
When deserializing PostSharp aspects, gets the IMetadataDispenser corresponding to the MetadataEmitter used at build time.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IMetadataDispenser MetadataDispenser { get; }

Property Value

Type: IMetadataDispenser
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IArgumentsReader Interface
PostSharp.Serialization Namespace


IArgumentsWriter Interface

IArgumentsWriter Interface
Provides write access to a collection of arguments that need to be serialized.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface IArgumentsWriter

The IArgumentsWriter type exposes the following members.

Methods
 | Name | Description
Public method | SetValue | Sets the value of an argument.
Top
Properties
 | Name | Description
Public property | MetadataEmitter | When serializing PostSharp access, gets a facility that can be used to serialize metadata (System.Reflection) objects as MSIL, therefore making them transparent to obfuscation.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


IArgumentsWriter Methods

IArgumentsWriter Methods

The IArgumentsWriter type exposes the following members.

Methods
 | Name | Description
Public method | SetValue | Sets the value of an argument.
Top
See Also

Reference

IArgumentsWriter Interface
PostSharp.Serialization Namespace


IArgumentsWriter.SetValue Method

IArgumentsWriterSetValue Method
Sets the value of an argument.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void SetValue(
    string name,
    Object value,
    string scope = null
)

Parameters

name
Type: SystemString
Argument name.
value
Type: SystemObject
Argument value. The value can be null or must be serializable.
scope (Optional)
Type: SystemString
An optional prefix of name, similar to a namespace.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IArgumentsWriter Interface
PostSharp.Serialization Namespace


IArgumentsWriter Properties

IArgumentsWriter Properties

The IArgumentsWriter type exposes the following members.

Properties
 | Name | Description
Public property | MetadataEmitter | When serializing PostSharp access, gets a facility that can be used to serialize metadata (System.Reflection) objects as MSIL, therefore making them transparent to obfuscation.
Top
See Also

Reference

IArgumentsWriter Interface
PostSharp.Serialization Namespace


IArgumentsWriter.MetadataEmitter Property

IArgumentsWriterMetadataEmitter Property
When serializing PostSharp access, gets a facility that can be used to serialize metadata (System.Reflection) objects as MSIL, therefore making them transparent to obfuscation.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
IMetadataEmitter MetadataEmitter { get; }

Property Value

Type: IMetadataEmitter
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IArgumentsWriter Interface
PostSharp.Serialization Namespace


ImportSerializerAttribute Class

ImportSerializerAttribute Class
Custom attribute that, when applied to a serializable type, specifies that the serializer of this type has a dependency on another serializer. The custom attribute can be applied at assembly level; it then applies to all serializable types in this assembly.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.SerializationImportSerializerAttribute

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class ImportSerializerAttribute : Attribute

The ImportSerializerAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ImportSerializerAttribute | Initializes a new ImportSerializerAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | ObjectType | Gets the type of the object to be made serializable
Public property | SerializerType | Gets the serializer type.
Top
Remarks

This custom attribute is useful to add serializers to types of third-party assemblies. For types whose you can modify the source code, it is preferable to use PSerializableAttribute or SerializerAttribute.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


ImportSerializerAttribute Constructor

ImportSerializerAttribute Constructor
Initializes a new ImportSerializerAttribute.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ImportSerializerAttribute(
    Type objectType,
    Type serializerType
)

Parameters

objectType
Type: SystemType
Type of the object to be made serializable.
serializerType
Type: SystemType
Serializer type. This type must implement ISerializer or ISerializerFactory, and must have a public default constructor. If serializerType is a generic type, if must have the same number of generic type parameters as objectType, and have a compatible set of constraints.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ImportSerializerAttribute Class
PostSharp.Serialization Namespace
PostSharp.SerializationSerializerAttribute


ImportSerializerAttribute Methods

ImportSerializerAttribute Methods

The ImportSerializerAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ImportSerializerAttribute Class
PostSharp.Serialization Namespace


ImportSerializerAttribute Properties

ImportSerializerAttribute Properties

The ImportSerializerAttribute type exposes the following members.

Properties
 | Name | Description
Public property | ObjectType | Gets the type of the object to be made serializable
Public property | SerializerType | Gets the serializer type.
Top
See Also

Reference

ImportSerializerAttribute Class
PostSharp.Serialization Namespace


ImportSerializerAttribute.ObjectType Property

ImportSerializerAttributeObjectType Property
Gets the type of the object to be made serializable

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type ObjectType { get; }

Property Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ImportSerializerAttribute Class
PostSharp.Serialization Namespace


ImportSerializerAttribute.SerializerType Property

ImportSerializerAttributeSerializerType Property
Gets the serializer type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type SerializerType { get; }

Property Value

Type: Type
Remarks
This type must implement ISerializer or ISerializerFactory, and must have a public default constructor. If SerializerType is a generic type, if must have the same number of generic type parameters as ObjectType, and have a compatible set of constraints.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ImportSerializerAttribute Class
PostSharp.Serialization Namespace


ISerializationCallback Interface

ISerializationCallback Interface
Interface that can be implemented by serializable classes. It defines methods OnDeserialized and OnSerializing called during serialization.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISerializationCallback

The ISerializationCallback type exposes the following members.

Methods
 | Name | Description
Public method | OnDeserialized | Method called after the object has been deserialized.
Public method | OnSerializing | Method called before the object is being serialized.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


ISerializationCallback Methods

ISerializationCallback Methods

The ISerializationCallback type exposes the following members.

Methods
 | Name | Description
Public method | OnDeserialized | Method called after the object has been deserialized.
Public method | OnSerializing | Method called before the object is being serialized.
Top
See Also

Reference

ISerializationCallback Interface
PostSharp.Serialization Namespace


ISerializationCallback.OnDeserialized Method

ISerializationCallbackOnDeserialized Method
Method called after the object has been deserialized.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnDeserialized()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializationCallback Interface
PostSharp.Serialization Namespace


ISerializationCallback.OnSerializing Method

ISerializationCallbackOnSerializing Method
Method called before the object is being serialized.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void OnSerializing()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializationCallback Interface
PostSharp.Serialization Namespace


ISerializer Interface

ISerializer Interface
Defines the semantics of an object serializer.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISerializer

The ISerializer type exposes the following members.

Methods
 | Name | Description
Public method | Convert | Converts a value into a given target type.
Public method | CreateInstance | Creates an instance of the given type.
Public method | DeserializeFields | Completes the second phase of deserialization by setting fields and other properties.
Public method | SerializeObject | Serializes an object
Top
Properties
 | Name | Description
Public property | IsTwoPhase | Determines whether DeserializeFields(Object, IArgumentsReader) should be invoked during deserialization. The value is false if CreateInstance(Type, IArgumentsReader) return fully created object, true otherwise.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


ISerializer Methods

ISerializer Methods

The ISerializer type exposes the following members.

Methods
 | Name | Description
Public method | Convert | Converts a value into a given target type.
Public method | CreateInstance | Creates an instance of the given type.
Public method | DeserializeFields | Completes the second phase of deserialization by setting fields and other properties.
Public method | SerializeObject | Serializes an object
Top
See Also

Reference

ISerializer Interface
PostSharp.Serialization Namespace


ISerializer.Convert Method

ISerializerConvert Method
Converts a value into a given target type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object Convert(
    Object value,
    Type targetType
)

Parameters

value
Type: SystemObject
Value to be converted.
targetType
Type: SystemType
target type.

Return Value

Type: Object
The value converted to targetType.
Remarks

This method allows for additional flexibility if the serialization-time type is not equal to the deserialization-time. The current method is invoked at deserialization time to perform the conversion.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializer Interface
PostSharp.Serialization Namespace


ISerializer.CreateInstance Method

ISerializerCreateInstance Method
Creates an instance of the given type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Object CreateInstance(
    Type type,
    IArgumentsReader constructorArguments
)

Parameters

type
Type: SystemType
Type of the instance to be created.
constructorArguments
Type: PostSharp.SerializationIArgumentsReader
Gives access to arguments required to create the instance.

Return Value

Type: Object
An instance of type type initialized using constructorArguments.
Remarks

This method is invoked during deserialization. If IsTwoPhase is true, the DeserializeFields(Object, IArgumentsReader) method is called later to complete deserialization.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializer Interface
PostSharp.Serialization Namespace


ISerializer.DeserializeFields Method

ISerializerDeserializeFields Method
Completes the second phase of deserialization by setting fields and other properties.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void DeserializeFields(
    ref Object obj,
    IArgumentsReader initializationArguments
)

Parameters

obj
Type: SystemObject
The object being deserialized.
initializationArguments
Type: PostSharp.SerializationIArgumentsReader
Gives access to field values.
Remarks

This method is only invoked if IsTwoPhase is true.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializer Interface
PostSharp.Serialization Namespace


ISerializer.SerializeObject Method

ISerializerSerializeObject Method
Serializes an object

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void SerializeObject(
    Object obj,
    IArgumentsWriter constructorArguments,
    IArgumentsWriter initializationArguments
)

Parameters

obj
Type: SystemObject
constructorArguments
Type: PostSharp.SerializationIArgumentsWriter
Gives access to arguments that will be passed to the CreateInstance(Type, IArgumentsReader) method during deserialization.
initializationArguments
Type: PostSharp.SerializationIArgumentsWriter
Gives access to arguments that will be passed to the DeserializeFields(Object, IArgumentsReader) method during deserialization.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializer Interface
PostSharp.Serialization Namespace


ISerializer Properties

ISerializer Properties

The ISerializer type exposes the following members.

Properties
 | Name | Description
Public property | IsTwoPhase | Determines whether DeserializeFields(Object, IArgumentsReader) should be invoked during deserialization. The value is false if CreateInstance(Type, IArgumentsReader) return fully created object, true otherwise.
Top
See Also

Reference

ISerializer Interface
PostSharp.Serialization Namespace


ISerializer.IsTwoPhase Property

ISerializerIsTwoPhase Property
Determines whether DeserializeFields(Object, IArgumentsReader) should be invoked during deserialization. The value is false if CreateInstance(Type, IArgumentsReader) return fully created object, true otherwise.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
bool IsTwoPhase { get; }

Property Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializer Interface
PostSharp.Serialization Namespace


ISerializerDiscoverer Interface

ISerializerDiscoverer Interface
Exposes a method that allows implementations of the interface to discover serializer types for each type being serialized.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISerializerDiscoverer

The ISerializerDiscoverer type exposes the following members.

Methods
 | Name | Description
Public method | DiscoverSerializers | Invoked by once for every type that needs to be serialized, before is invoked.
Top
Remarks
Only implementations of may implement this interface.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace
ISerializerDiscovererDiscoverSerializers(Type)
PostSharp.SerializationISerializerFactoryProvider
PostSharp.SerializationISerializerFactoryProvider
PostSharp.SerializationISerializerFactoryProvider


ISerializerDiscoverer Methods

ISerializerDiscoverer Methods

The ISerializerDiscoverer type exposes the following members.

Methods
 | Name | Description
Public method | DiscoverSerializers | Invoked by once for every type that needs to be serialized, before is invoked.
Top
See Also

Reference

ISerializerDiscoverer Interface
PostSharp.Serialization Namespace


ISerializerDiscoverer.DiscoverSerializers Method

ISerializerDiscovererDiscoverSerializers Method
Invoked by once for every type that needs to be serialized, before is invoked.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
void DiscoverSerializers(
    Type objectType
)

Parameters

objectType
Type: SystemType
Type being serialized.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializerDiscoverer Interface
PostSharp.Serialization Namespace
PostSharp.SerializationPortableFormatter
ISerializerFactoryProviderGetSurrogateType(Type)


ISerializerFactory Interface

ISerializerFactory Interface
Defines a method CreateSerializer(Type), which creates instances of the ISerializer interface for given object types.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISerializerFactory

The ISerializerFactory type exposes the following members.

Methods
 | Name | Description
Public method | CreateSerializer | Creates an instance of the ISerializer interface for a given object type.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


ISerializerFactory Methods

ISerializerFactory Methods

The ISerializerFactory type exposes the following members.

Methods
 | Name | Description
Public method | CreateSerializer | Creates an instance of the ISerializer interface for a given object type.
Top
See Also

Reference

ISerializerFactory Interface
PostSharp.Serialization Namespace


ISerializerFactory.CreateSerializer Method

ISerializerFactoryCreateSerializer Method
Creates an instance of the ISerializer interface for a given object type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ISerializer CreateSerializer(
    Type objectType
)

Parameters

objectType
Type: SystemType
Type of object being serialized or deserialized.

Return Value

Type: ISerializer
A new instance implementing the ISerializer interface.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializerFactory Interface
PostSharp.Serialization Namespace


ISerializerFactoryProvider Interface

ISerializerFactoryProvider Interface
Provides instances of the ISerializerFactory interface given the object type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public interface ISerializerFactoryProvider

The ISerializerFactoryProvider type exposes the following members.

Methods
 | Name | Description
Public method | GetSerializerFactory | Gets the instance of ISerializerFactory
Public method | GetSurrogateType | Gets the surrogate type for a given object type.
Top
Properties
 | Name | Description
Public property | NextProvider | Gets the next provider in the chain.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace
PostSharp.SerializationISerializerDiscoverer


ISerializerFactoryProvider Methods

ISerializerFactoryProvider Methods

The ISerializerFactoryProvider type exposes the following members.

Methods
 | Name | Description
Public method | GetSerializerFactory | Gets the instance of ISerializerFactory
Public method | GetSurrogateType | Gets the surrogate type for a given object type.
Top
See Also

Reference

ISerializerFactoryProvider Interface
PostSharp.Serialization Namespace


ISerializerFactoryProvider.GetSerializerFactory Method

ISerializerFactoryProviderGetSerializerFactory Method
Gets the instance of ISerializerFactory

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ISerializerFactory GetSerializerFactory(
    Type objectType
)

Parameters

objectType
Type: SystemType
Type of object being serialized or deserialized. If a surrogate type has been specified during serialization, this parameter is set to the surrogate type during deserialization.

Return Value

Type: ISerializerFactory
An instance of ISerializerFactory able to serialize or deserialize objectType, or null if there is no known serializer factory for this object.
Remarks

It is not the responsibility of this class to call the next provider (NextProvider).

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializerFactoryProvider Interface
PostSharp.Serialization Namespace


ISerializerFactoryProvider.GetSurrogateType Method

ISerializerFactoryProviderGetSurrogateType Method
Gets the surrogate type for a given object type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
Type GetSurrogateType(
    Type objectType
)

Parameters

objectType
Type: SystemType
Type of the object being serialized.

Return Value

Type: Type
The surrogate type for objectType, or null (or objectType) is objectType does not require a surrogate type.
Remarks

This method is called only during serialization. The surrogate type is the type whose name will be serialized; therefore, it will also be the type that will be deserialized.

It is not the responsibility of this class to call the next provider (NextProvider).

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializerFactoryProvider Interface
PostSharp.Serialization Namespace


ISerializerFactoryProvider Properties

ISerializerFactoryProvider Properties

The ISerializerFactoryProvider type exposes the following members.

Properties
 | Name | Description
Public property | NextProvider | Gets the next provider in the chain.
Top
See Also

Reference

ISerializerFactoryProvider Interface
PostSharp.Serialization Namespace


ISerializerFactoryProvider.NextProvider Property

ISerializerFactoryProviderNextProvider Property
Gets the next provider in the chain.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
ISerializerFactoryProvider NextProvider { get; }

Property Value

Type: ISerializerFactoryProvider
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ISerializerFactoryProvider Interface
PostSharp.Serialization Namespace


PNonSerializedAttribute Class

PNonSerializedAttribute Class
Custom attribute that, when applied to a field of a class annotated with PSerializableAttribute, specifies that this field should not be serialized.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.SerializationPNonSerializedAttribute

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class PNonSerializedAttribute : Attribute

The PNonSerializedAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | PNonSerializedAttribute | Initializes a new instance of the PNonSerializedAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


PNonSerializedAttribute Constructor

PNonSerializedAttribute Constructor
Initializes a new instance of the PNonSerializedAttribute class

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PNonSerializedAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PNonSerializedAttribute Class
PostSharp.Serialization Namespace


PNonSerializedAttribute Methods

PNonSerializedAttribute Methods

The PNonSerializedAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PNonSerializedAttribute Class
PostSharp.Serialization Namespace


PortableFormatter Class

PortableFormatter Class
A serializer designed to serialize the internal structure of types with support for cyclic object graphs. The PortableFormatter is very similar in function and design to the BinaryFormatter, but is supported on most platforms and does not require full trust. Both formatters have similar usage: SerializableAttribute is replaced by PSerializableAttribute and NonSerializedAttribute by PNonSerializedAttribute.
Inheritance Hierarchy
SystemObject
PostSharp.SerializationPortableFormatter

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class PortableFormatter

The PortableFormatter type exposes the following members.

Constructors
 | Name | Description
Public method | PortableFormatter | Initializes a new PortableFormatter.
Top
Methods
 | Name | Description
Public method | Deserialize | Deserializes a stream.
Public method | Serialize | Serializes an object (and the complete graph whose this object is the root) into a Stream.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | MetadataDispenser | When deserializing PostSharp aspects, gets the IMetadataDispenser corresponding to the MetadataEmitter used at build time.
Public property | MetadataEmitter | When serializing PostSharp access, gets or sets a facility that can be used to serialize metadata (System.Reflection) objects as MSIL, therefore making them transparent to obfuscation.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


PortableFormatter Constructor

PortableFormatter Constructor
Initializes a new PortableFormatter.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PortableFormatter(
    PortableSerializationBinder binder = null,
    ISerializerFactoryProvider serializerProvider = null
)

Parameters

binder (Optional)
Type: PostSharp.SerializationPortableSerializationBinder
A PortableSerializationBinder customizing bindings between types and type names, or null to use the default implementation.
serializerProvider (Optional)
Type: PostSharp.SerializationISerializerFactoryProvider
A custom implementation of ISerializerFactoryProvider, or null to use the default implementation.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableFormatter Class
PostSharp.Serialization Namespace


PortableFormatter Methods

PortableFormatter Methods

The PortableFormatter type exposes the following members.

Methods
 | Name | Description
Public method | Deserialize | Deserializes a stream.
Public method | Serialize | Serializes an object (and the complete graph whose this object is the root) into a Stream.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PortableFormatter Class
PostSharp.Serialization Namespace


PortableFormatter.Deserialize Method

PortableFormatterDeserialize Method
Deserializes a stream.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Object Deserialize(
    Stream stream
)

Parameters

stream
Type: System.IOStream
A Stream containing a serialized object graph.

Return Value

Type: Object
The root object of the object graph serialized in stream.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableFormatter Class
PostSharp.Serialization Namespace


PortableFormatter.Serialize Method

PortableFormatterSerialize Method
Serializes an object (and the complete graph whose this object is the root) into a Stream.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void Serialize(
    Object obj,
    Stream stream
)

Parameters

obj
Type: SystemObject
The object to serialize.
stream
Type: System.IOStream
The stream where obj needs to be serialized.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableFormatter Class
PostSharp.Serialization Namespace


PortableFormatter Properties

PortableFormatter Properties

The PortableFormatter type exposes the following members.

Properties
 | Name | Description
Public property | MetadataDispenser | When deserializing PostSharp aspects, gets the IMetadataDispenser corresponding to the MetadataEmitter used at build time.
Public property | MetadataEmitter | When serializing PostSharp access, gets or sets a facility that can be used to serialize metadata (System.Reflection) objects as MSIL, therefore making them transparent to obfuscation.
Top
See Also

Reference

PortableFormatter Class
PostSharp.Serialization Namespace


PortableFormatter.MetadataDispenser Property

PortableFormatterMetadataDispenser Property
When deserializing PostSharp aspects, gets the IMetadataDispenser corresponding to the MetadataEmitter used at build time.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IMetadataDispenser MetadataDispenser { get; set; }

Property Value

Type: IMetadataDispenser
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableFormatter Class
PostSharp.Serialization Namespace


PortableFormatter.MetadataEmitter Property

PortableFormatterMetadataEmitter Property
When serializing PostSharp access, gets or sets a facility that can be used to serialize metadata (System.Reflection) objects as MSIL, therefore making them transparent to obfuscation.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IMetadataEmitter MetadataEmitter { get; set; }

Property Value

Type: IMetadataEmitter
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableFormatter Class
PostSharp.Serialization Namespace


PortableSerializationBinder Class

PortableSerializationBinder Class
Binds types to names and names to types. Used by the PortableFormatter.
Inheritance Hierarchy
SystemObject
PostSharp.SerializationPortableSerializationBinder

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class PortableSerializationBinder

The PortableSerializationBinder type exposes the following members.

Constructors
 | Name | Description
Public method | PortableSerializationBinder | Initializes a new instance of the PortableSerializationBinder class.
Top
Methods
 | Name | Description
Public method | BindToName |
Public method | BindToType |
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


PortableSerializationBinder Constructor

PortableSerializationBinder Constructor
Initializes a new instance of the PortableSerializationBinder class.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PortableSerializationBinder()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableSerializationBinder Class
PostSharp.Serialization Namespace


PortableSerializationBinder Methods

PortableSerializationBinder Methods

The PortableSerializationBinder type exposes the following members.

Methods
 | Name | Description
Public method | BindToName |
Public method | BindToType |
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PortableSerializationBinder Class
PostSharp.Serialization Namespace


PortableSerializationBinder.BindToName Method

PortableSerializationBinderBindToName Method

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual void BindToName(
    Type type,
    out string typeName,
    out string assemblyName
)

Parameters

type
Type: SystemType
typeName
Type: SystemString
assemblyName
Type: SystemString
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableSerializationBinder Class
PostSharp.Serialization Namespace


PortableSerializationBinder.BindToType Method

PortableSerializationBinderBindToType Method

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Type BindToType(
    string typeName,
    string assemblyName
)

Parameters

typeName
Type: SystemString
assemblyName
Type: SystemString

Return Value

Type: Type
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableSerializationBinder Class
PostSharp.Serialization Namespace


PortableSerializationException Class

PortableSerializationException Class
Exception thrown by the PortableFormatter.
Inheritance Hierarchy
SystemObject
SystemException
PostSharp.SerializationPortableSerializationException

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
public class PortableSerializationException : Exception

The PortableSerializationException type exposes the following members.

Constructors
 | Name | Description
Public method | PortableSerializationException | Initializes a new PortableSerializationException.
Public method | PortableSerializationException(String) | Initializes a new PortableSerializationException and specifies the message.
Protected method | PortableSerializationException(SerializationInfo, StreamingContext) | Deserialization constructor.
Public method | PortableSerializationException(String, Exception) | Initializes a new PortableSerializationException and specifies the message and inner exception.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


PortableSerializationException Constructor

PortableSerializationException Constructor
Overload List
 | Name | Description
Public method | PortableSerializationException | Initializes a new PortableSerializationException.
Public method | PortableSerializationException(String) | Initializes a new PortableSerializationException and specifies the message.
Protected method | PortableSerializationException(SerializationInfo, StreamingContext) | Deserialization constructor.
Public method | PortableSerializationException(String, Exception) | Initializes a new PortableSerializationException and specifies the message and inner exception.
Top
See Also

Reference

PortableSerializationException Class
PostSharp.Serialization Namespace


PortableSerializationException Constructor

PortableSerializationException Constructor
Initializes a new PortableSerializationException.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PortableSerializationException()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableSerializationException Class
PortableSerializationException Overload
PostSharp.Serialization Namespace


PortableSerializationException Constructor (String)

PortableSerializationException Constructor (String)
Initializes a new PortableSerializationException and specifies the message.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PortableSerializationException(
    string message
)

Parameters

message
Type: SystemString
Message.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableSerializationException Class
PortableSerializationException Overload
PostSharp.Serialization Namespace


PortableSerializationException Constructor (SerializationInfo, StreamingContext)

PortableSerializationException Constructor (SerializationInfo, StreamingContext)
Deserialization constructor.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected PortableSerializationException(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.SerializationSerializationInfo
context
Type: System.Runtime.SerializationStreamingContext
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableSerializationException Class
PortableSerializationException Overload
PostSharp.Serialization Namespace


PortableSerializationException Constructor (String, Exception)

PortableSerializationException Constructor (String, Exception)
Initializes a new PortableSerializationException and specifies the message and inner exception.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PortableSerializationException(
    string message,
    Exception inner
)

Parameters

message
Type: SystemString
Message.
inner
Type: SystemException
Inner exception.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PortableSerializationException Class
PortableSerializationException Overload
PostSharp.Serialization Namespace


PortableSerializationException Methods

PortableSerializationException Methods

The PortableSerializationException type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PortableSerializationException Class
PostSharp.Serialization Namespace


PSerializableAttribute Class

PSerializableAttribute Class
Custom attribute that, when applied to a type, causes PostSharp to generate a serializer for use by the PortableFormatter.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.SerializationPSerializableAttribute

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class PSerializableAttribute : MulticastAttribute,
    IAspect

The PSerializableAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | PSerializableAttribute | Initializes a new instance of the PSerializableAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Remarks

Fields that should not be serialized must be annotated with PNonSerializedAttribute.

This class inherits from MulticastAttribute, so it is possible to use multicasting to add this aspect to several classes using a single line, or to add this aspect to derived classes through inheritance.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace
PostSharp.SerializationPortableFormatter


PSerializableAttribute Constructor

PSerializableAttribute Constructor
Initializes a new instance of the PSerializableAttribute class

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public PSerializableAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PSerializableAttribute Class
PostSharp.Serialization Namespace


PSerializableAttribute Methods

PSerializableAttribute Methods

The PSerializableAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

PSerializableAttribute Class
PostSharp.Serialization Namespace


PSerializableAttribute Properties

PSerializableAttribute Properties

The PSerializableAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

PSerializableAttribute Class
PostSharp.Serialization Namespace


ReferenceTypeSerializer Class

ReferenceTypeSerializer Class
Base serializer for all reference types.
Inheritance Hierarchy
SystemObject
PostSharp.SerializationReferenceTypeSerializer

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class ReferenceTypeSerializer : ISerializer

The ReferenceTypeSerializer type exposes the following members.

Constructors
 | Name | Description
Protected method | ReferenceTypeSerializer | Initializes a new instance of the ReferenceTypeSerializer class
Top
Methods
 | Name | Description
Public method | Convert | Converts a value into a given target type.
Public method | CreateInstance | Creates an instance of the given type.
Public method | DeserializeFields | Completes the second phase of deserialization by setting fields and other properties.
Public method | SerializeObject | Serializes an object
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Remarks
This type is intentionally non-generic because it is intended to be derived several times, making strong typing less convenient.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


ReferenceTypeSerializer Constructor

ReferenceTypeSerializer Constructor
Initializes a new instance of the ReferenceTypeSerializer class

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected ReferenceTypeSerializer()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReferenceTypeSerializer Class
PostSharp.Serialization Namespace


ReferenceTypeSerializer Methods

ReferenceTypeSerializer Methods

The ReferenceTypeSerializer type exposes the following members.

Methods
 | Name | Description
Public method | Convert | Converts a value into a given target type.
Public method | CreateInstance | Creates an instance of the given type.
Public method | DeserializeFields | Completes the second phase of deserialization by setting fields and other properties.
Public method | SerializeObject | Serializes an object
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReferenceTypeSerializer Class
PostSharp.Serialization Namespace


ReferenceTypeSerializer.Convert Method

ReferenceTypeSerializerConvert Method
Converts a value into a given target type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object Convert(
    Object value,
    Type targetType
)

Parameters

value
Type: SystemObject
Value to be converted.
targetType
Type: SystemType
target type.

Return Value

Type: Object
The value converted to targetType.

Implements

ISerializerConvert(Object, Type)
Remarks

This method allows for additional flexibility if the serialization-time type is not equal to the deserialization-time. The current method is invoked at deserialization time to perform the conversion.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReferenceTypeSerializer Class
PostSharp.Serialization Namespace


ReferenceTypeSerializer.CreateInstance Method

ReferenceTypeSerializerCreateInstance Method
Creates an instance of the given type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract Object CreateInstance(
    Type type,
    IArgumentsReader constructorArguments
)

Parameters

type
Type: SystemType
Type of the instance to be created.
constructorArguments
Type: PostSharp.SerializationIArgumentsReader
Gives access to arguments required to create the instance.

Return Value

Type: Object
An instance of type type initialized using constructorArguments.

Implements

ISerializerCreateInstance(Type, IArgumentsReader)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReferenceTypeSerializer Class
PostSharp.Serialization Namespace


ReferenceTypeSerializer.DeserializeFields Method

ReferenceTypeSerializerDeserializeFields Method
Completes the second phase of deserialization by setting fields and other properties.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void DeserializeFields(
    Object obj,
    IArgumentsReader initializationArguments
)

Parameters

obj
Type: SystemObject
The object being deserialized.
initializationArguments
Type: PostSharp.SerializationIArgumentsReader
Gives access to field values.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReferenceTypeSerializer Class
PostSharp.Serialization Namespace


ReferenceTypeSerializer.SerializeObject Method

ReferenceTypeSerializerSerializeObject Method
Serializes an object

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void SerializeObject(
    Object obj,
    IArgumentsWriter constructorArguments,
    IArgumentsWriter initializationArguments
)

Parameters

obj
Type: SystemObject
constructorArguments
Type: PostSharp.SerializationIArgumentsWriter
Gives access to arguments that will be passed to the CreateInstance(Type, IArgumentsReader) method during deserialization.
initializationArguments
Type: PostSharp.SerializationIArgumentsWriter
Gives access to arguments that will be passed to the DeserializeFields(Object, IArgumentsReader) method during deserialization.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReferenceTypeSerializer Class
PostSharp.Serialization Namespace


SerializationServices Class

SerializationServices Class
Provides some utility method for the current namespace.
Inheritance Hierarchy
SystemObject
PostSharp.SerializationSerializationServices

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static class SerializationServices
Methods
Name | Description
GetSerializationException(MemberInfo) | Checks whether a given MethodInfo, ConstructorInfo, FieldInfo, PropertyInfo, EventInfo or Type can be safely serialized.
GetSerializationException(ParameterInfo) | Checks whether a given ParameterInfo can be safely serialized.
GetSerializationException(LocationInfo) | Checks whether a given LocationInfo can be safely serialized.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


SerializationServices Methods

SerializationServices Methods
Methods
Name | Description
GetSerializationException(MemberInfo) | Checks whether a given MethodInfo, ConstructorInfo, FieldInfo, PropertyInfo, EventInfo or Type can be safely serialized.
GetSerializationException(ParameterInfo) | Checks whether a given ParameterInfo can be safely serialized.
GetSerializationException(LocationInfo) | Checks whether a given LocationInfo can be safely serialized.
Top
See Also

Reference

SerializationServices Class
PostSharp.Serialization Namespace


SerializationServices.GetSerializationException Method

SerializationServicesGetSerializationException Method
Overload List
Name | Description
GetSerializationException(MemberInfo) | Checks whether a given MethodInfo, ConstructorInfo, FieldInfo, PropertyInfo, EventInfo or Type can be safely serialized.
GetSerializationException(ParameterInfo) | Checks whether a given ParameterInfo can be safely serialized.
GetSerializationException(LocationInfo) | Checks whether a given LocationInfo can be safely serialized.
Top
See Also

Reference

SerializationServices Class
PostSharp.Serialization Namespace


SerializationServices.GetSerializationException Method (MemberInfo)

SerializationServicesGetSerializationException Method (MemberInfo)
Checks whether a given MethodInfo, ConstructorInfo, FieldInfo, PropertyInfo, EventInfo or Type can be safely serialized.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static PortableSerializationException GetSerializationException(
    MemberInfo memberInfo
)

Parameters

memberInfo
Type: System.ReflectionMemberInfo
The declaration to be serialized.

Return Value

Type: PortableSerializationException
null if memberInfo can be safely serialized, otherwise an exception where the text describes the reason why the declaration is not serializable.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializationServices Class
GetSerializationException Overload
PostSharp.Serialization Namespace


SerializationServices.GetSerializationException Method (ParameterInfo)

SerializationServicesGetSerializationException Method (ParameterInfo)
Checks whether a given ParameterInfo can be safely serialized.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static PortableSerializationException GetSerializationException(
    ParameterInfo parameterInfo
)

Parameters

parameterInfo
Type: System.ReflectionParameterInfo
The declaration to be serialized.

Return Value

Type: PortableSerializationException
null if parameterInfo can be safely serialized, otherwise an exception where the text describes the reason why the declaration is not serializable.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializationServices Class
GetSerializationException Overload
PostSharp.Serialization Namespace


SerializationServices.GetSerializationException Method (LocationInfo)

SerializationServicesGetSerializationException Method (LocationInfo)
Checks whether a given LocationInfo can be safely serialized.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static PortableSerializationException GetSerializationException(
    LocationInfo locationInfo
)

Parameters

locationInfo
Type: PostSharp.ReflectionLocationInfo
The declaration to be serialized.

Return Value

Type: PortableSerializationException
null if locationInfo can be safely serialized, otherwise an exception where the text describes the reason why the declaration is not serializable.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializationServices Class
GetSerializationException Overload
PostSharp.Serialization Namespace


SerializerAttribute Class

SerializerAttribute Class
Custom attribute that, when applied to a type, specifies its serializer for use by the PortableFormatter.
Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.SerializationSerializerAttribute

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public sealed class SerializerAttribute : Attribute

The SerializerAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | SerializerAttribute | Initializes a new SerializerAttribute.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | SerializerType | Gets the serializer type.
Top
Remarks

The use of the SerializerAttribute is optional if the serializer of a type is a nested class of that class named Serializer.

Windows Phone 7.0 does not allow to assign generic types to parameters of custom attributes.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace
PostSharp.SerializationImportSerializerAttribute


SerializerAttribute Constructor

SerializerAttribute Constructor
Initializes a new SerializerAttribute.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SerializerAttribute(
    Type serializerType
)

Parameters

serializerType
Type: SystemType
Serializer type. This type must implement ISerializer or ISerializerFactory, and must have a public default constructor. If serializerType is a generic type, if must have the same number of generic type parameters as the target type, and have a compatible set of constraints.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializerAttribute Class
PostSharp.Serialization Namespace


SerializerAttribute Methods

SerializerAttribute Methods

The SerializerAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SerializerAttribute Class
PostSharp.Serialization Namespace


SerializerAttribute Properties

SerializerAttribute Properties

The SerializerAttribute type exposes the following members.

Properties
 | Name | Description
Public property | SerializerType | Gets the serializer type.
Top
See Also

Reference

SerializerAttribute Class
PostSharp.Serialization Namespace


SerializerAttribute.SerializerType Property

SerializerAttributeSerializerType Property
Gets the serializer type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public Type SerializerType { get; }

Property Value

Type: Type
Remarks
This type must implement ISerializer or ISerializerFactory, and must have a public default constructor. If SerializerType is a generic type, if must have the same number of generic type parameters as the target type, and have a compatible set of constraints.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializerAttribute Class
PostSharp.Serialization Namespace


SerializerFactoryProvider Class

SerializerFactoryProvider Class
Provides instances of the ISerializerFactory interface for object types that have been previously registered using AddSerializer(Type, Type).
Inheritance Hierarchy
SystemObject
PostSharp.SerializationSerializerFactoryProvider

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public class SerializerFactoryProvider : ISerializerFactoryProvider

The SerializerFactoryProvider type exposes the following members.

Constructors
 | Name | Description
Public method | SerializerFactoryProvider | Initializes a new SerializerFactoryProvider.
Top
Methods
 | Name | Description
Public method | AddSerializer(Type, Type) | Maps an object type to a serializer type.
Public method | AddSerializerObjectType, SerializerType | Maps an object type to a serializer type (using generic type parameters).
Public method | GetSerializerFactory | Gets the instance of ISerializerFactory
Public method | GetSurrogateType | Gets the surrogate type for a given object type.
Public method | MakeReadOnly | Forbids further changes in the current SerializerFactoryProvider.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
BuiltIn | Gets the SerializerFactoryProvider instance that supports built-in types.
Top
Properties
 | Name | Description
Public property | NextProvider | Gets the next provider in the chain.
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


SerializerFactoryProvider Constructor

SerializerFactoryProvider Constructor
Initializes a new SerializerFactoryProvider.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public SerializerFactoryProvider(
    ISerializerFactoryProvider nextProvider,
    ActivatorProvider activatorProvider
)

Parameters

nextProvider
Type: PostSharp.SerializationISerializerFactoryProvider
The next provider in the chain, or null if there is none.
activatorProvider
Type: ActivatorProvider
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializerFactoryProvider Class
PostSharp.Serialization Namespace


SerializerFactoryProvider Fields

SerializerFactoryProvider Fields

The SerializerFactoryProvider type exposes the following members.

Fields
Name | Description
BuiltIn | Gets the SerializerFactoryProvider instance that supports built-in types.
Top
See Also

Reference

SerializerFactoryProvider Class
PostSharp.Serialization Namespace


SerializerFactoryProvider.BuiltIn Field

SerializerFactoryProviderBuiltIn Field
Gets the SerializerFactoryProvider instance that supports built-in types.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly SerializerFactoryProvider BuiltIn

Field Value

Type: SerializerFactoryProvider
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializerFactoryProvider Class
PostSharp.Serialization Namespace


SerializerFactoryProvider Methods

SerializerFactoryProvider Methods

The SerializerFactoryProvider type exposes the following members.

Methods
 | Name | Description
Public method | AddSerializer(Type, Type) | Maps an object type to a serializer type.
Public method | AddSerializerObjectType, SerializerType | Maps an object type to a serializer type (using generic type parameters).
Public method | GetSerializerFactory | Gets the instance of ISerializerFactory
Public method | GetSurrogateType | Gets the surrogate type for a given object type.
Public method | MakeReadOnly | Forbids further changes in the current SerializerFactoryProvider.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

SerializerFactoryProvider Class
PostSharp.Serialization Namespace


SerializerFactoryProvider.AddSerializer Method

SerializerFactoryProviderAddSerializer Method
Overload List
 | Name | Description
Public method | AddSerializerObjectType, SerializerType | Maps an object type to a serializer type (using generic type parameters).
Public method | AddSerializer(Type, Type) | Maps an object type to a serializer type.
Top
See Also

Reference

SerializerFactoryProvider Class
PostSharp.Serialization Namespace


SerializerFactoryProvider.AddSerializer(ObjectType, SerializerType) Method

SerializerFactoryProviderAddSerializerObjectType, SerializerType Method
Maps an object type to a serializer type (using generic type parameters).

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void AddSerializer<ObjectType, SerializerType>()
where SerializerType : new(), ISerializer

Type Parameters

ObjectType
Type of the serialized object.
SerializerType
Type of the serializer.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializerFactoryProvider Class
AddSerializer Overload
PostSharp.Serialization Namespace


SerializerFactoryProvider.AddSerializer Method (Type, Type)

SerializerFactoryProviderAddSerializer Method (Type, Type)
Maps an object type to a serializer type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void AddSerializer(
    Type objectType,
    Type serializerType
)

Parameters

objectType
Type: SystemType
Type of the serialized object.
serializerType
Type: SystemType
Type of the serializer (must be derived from ISerializer).
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializerFactoryProvider Class
AddSerializer Overload
PostSharp.Serialization Namespace


SerializerFactoryProvider.GetSerializerFactory Method

SerializerFactoryProviderGetSerializerFactory Method
Gets the instance of ISerializerFactory

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual ISerializerFactory GetSerializerFactory(
    Type objectType
)

Parameters

objectType
Type: SystemType
Type of object being serialized or deserialized. If a surrogate type has been specified during serialization, this parameter is set to the surrogate type during deserialization.

Return Value

Type: ISerializerFactory
An instance of ISerializerFactory able to serialize or deserialize objectType, or null if there is no known serializer factory for this object.

Implements

ISerializerFactoryProviderGetSerializerFactory(Type)
Remarks

It is not the responsibility of this class to call the next provider (NextProvider).

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializerFactoryProvider Class
PostSharp.Serialization Namespace


SerializerFactoryProvider.GetSurrogateType Method

SerializerFactoryProviderGetSurrogateType Method
Gets the surrogate type for a given object type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Type GetSurrogateType(
    Type objectType
)

Parameters

objectType
Type: SystemType
Type of the object being serialized.

Return Value

Type: Type
The surrogate type for objectType, or null (or objectType) is objectType does not require a surrogate type.

Implements

ISerializerFactoryProviderGetSurrogateType(Type)
Remarks

This method is called only during serialization. The surrogate type is the type whose name will be serialized; therefore, it will also be the type that will be deserialized.

It is not the responsibility of this class to call the next provider (NextProvider).

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializerFactoryProvider Class
PostSharp.Serialization Namespace


SerializerFactoryProvider.MakeReadOnly Method

SerializerFactoryProviderMakeReadOnly Method
Forbids further changes in the current SerializerFactoryProvider.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void MakeReadOnly()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializerFactoryProvider Class
PostSharp.Serialization Namespace


SerializerFactoryProvider Properties

SerializerFactoryProvider Properties

The SerializerFactoryProvider type exposes the following members.

Properties
 | Name | Description
Public property | NextProvider | Gets the next provider in the chain.
Top
See Also

Reference

SerializerFactoryProvider Class
PostSharp.Serialization Namespace


SerializerFactoryProvider.NextProvider Property

SerializerFactoryProviderNextProvider Property
Gets the next provider in the chain.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ISerializerFactoryProvider NextProvider { get; }

Property Value

Type: ISerializerFactoryProvider

Implements

ISerializerFactoryProviderNextProvider
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

SerializerFactoryProvider Class
PostSharp.Serialization Namespace


ValueTypeSerializer(T) Class

ValueTypeSerializerT Class
Base serializer for all value types.
Inheritance Hierarchy
SystemObject
PostSharp.SerializationValueTypeSerializerT

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract class ValueTypeSerializer<T> : ISerializer
where T : struct, new()

Type Parameters

T

The ValueTypeSerializerT type exposes the following members.

Constructors
 | Name | Description
Protected method | ValueTypeSerializerT | Initializes a new instance of the ValueTypeSerializerT class
Top
Methods
 | Name | Description
Public method | Convert | Converts a value into a given target type.
Public method | DeserializeObject | Creates an instance of the given type.
Public method | SerializeObject | Serializes an object
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

PostSharp.Serialization Namespace


ValueTypeSerializer(T) Constructor

ValueTypeSerializerT Constructor
Initializes a new instance of the ValueTypeSerializerT class

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected ValueTypeSerializer()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ValueTypeSerializerT Class
PostSharp.Serialization Namespace


ValueTypeSerializer(T) Methods

ValueTypeSerializerT Methods

The ValueTypeSerializerT generic type exposes the following members.

Methods
 | Name | Description
Public method | Convert | Converts a value into a given target type.
Public method | DeserializeObject | Creates an instance of the given type.
Public method | SerializeObject | Serializes an object
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ValueTypeSerializerT Class
PostSharp.Serialization Namespace


ValueTypeSerializer(T).Convert Method

ValueTypeSerializerTConvert Method
Converts a value into a given target type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public virtual Object Convert(
    Object value,
    Type targetType
)

Parameters

value
Type: SystemObject
Value to be converted.
targetType
Type: SystemType
target type.

Return Value

Type: Object
The value converted to targetType.

Implements

ISerializerConvert(Object, Type)
Remarks

This method allows for additional flexibility if the serialization-time type is not equal to the deserialization-time. The current method is invoked at deserialization time to perform the conversion.

Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ValueTypeSerializerT Class
PostSharp.Serialization Namespace


ValueTypeSerializer(T).DeserializeObject Method

ValueTypeSerializerTDeserializeObject Method
Creates an instance of the given type.

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract T DeserializeObject(
    IArgumentsReader constructorArguments
)

Parameters

constructorArguments
Type: PostSharp.SerializationIArgumentsReader
Gives access to arguments required to create the instance.

Return Value

Type: T
An instance of type T initialized using constructorArguments.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ValueTypeSerializerT Class
PostSharp.Serialization Namespace


ValueTypeSerializer(T).SerializeObject Method

ValueTypeSerializerTSerializeObject Method
Serializes an object

Namespace: PostSharp.Serialization
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public abstract void SerializeObject(
    T obj,
    IArgumentsWriter constructorArguments
)

Parameters

obj
Type: T
constructorArguments
Type: PostSharp.SerializationIArgumentsWriter
Gives access to arguments that will be passed to the DeserializeObject(IArgumentsReader) method during deserialization.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ValueTypeSerializerT Class
PostSharp.Serialization Namespace


ReaderLockAttribute Constructor

ReaderLockAttribute Constructor
Initializes a new instance of the ReaderLockAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ReaderLockAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ReaderLockAttribute Class
PostSharp.Patterns.Threading Namespace


IReaderWriterSynchronized Properties

IReaderWriterSynchronized Properties

The IReaderWriterSynchronized type exposes the following members.

Properties
 | Name | Description
Public property | Lock | Gets the ReaderWriterLockSlim that has to be used to synchronize access to the current instance.
Top
See Also

Reference

IReaderWriterSynchronized Interface
PostSharp.Patterns.Threading Namespace


ObserverLockAttribute Constructor

ObserverLockAttribute Constructor
Initializes a new instance of the ObserverLockAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public ObserverLockAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

ObserverLockAttribute Class
PostSharp.Patterns.Threading Namespace


InstanceCredentials.Equals Method (InstanceCredentials)

InstanceCredentialsEquals Method (InstanceCredentials)
Indicates whether the current object is equal to another object of the same type.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool Equals(
    InstanceCredentials other
)

Parameters

other
Type: PostSharp.AspectsInstanceCredentials
An object to compare with this object.

Return Value

Type: Boolean
true if the current object is equal to the other parameter; otherwise, false.

Implements

IEquatableTEquals(T)
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceCredentials Structure
Equals Overload
PostSharp.Aspects Namespace


LockNotHeldException Class

LockNotHeldException Class

Note: This API is now obsolete.

Inheritance Hierarchy
SystemObject
SystemException
PostSharp.Patterns.ThreadingThreadingException
PostSharp.Patterns.ThreadingLockNotHeldException
PostSharp.Patterns.ThreadingThreadAccessException

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
[ObsoleteAttribute("Use ThreadAccessException")]
public class LockNotHeldException : ThreadingException
Version Information

Supported in: 3.1
Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


UpgradeableReaderLockAttribute Class

UpgradeableReaderLockAttribute Class

Note: This API is now obsolete.

Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingReaderWriterLockAttribute
PostSharp.Patterns.ThreadingUpgradeableReaderAttribute
PostSharp.Patterns.ThreadingUpgradeableReaderLockAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use UpgradeableReaderAttribute.")]
public sealed class UpgradeableReaderLockAttribute : UpgradeableReaderAttribute

The UpgradeableReaderLockAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | UpgradeableReaderLockAttribute | Initializes a new instance of the UpgradeableReaderLockAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 3.1
Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


Actor Class

Actor Class

Note: This API is now obsolete.

Inheritance Hierarchy
SystemObject
PostSharp.Patterns.ThreadingActor

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use the [Actor] custom attribute.")]
public abstract class Actor : IDispatcherObject,
    IAttachable, IActor

The Actor type exposes the following members.

Constructors
 | Name | Description
Protected method | Actor(ConstructorDepth) | Initializes a new instance of the Actor class
Protected method | Actor(IDispatcher, ConstructorDepth) | Initializes a new instance of the Actor class
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Overrides ObjectEquals(Object).)
Public method | GetHashCode | Serves as a hash function for a particular type. (Overrides ObjectGetHashCode.)
Protected method | OnAncestorChanged |
Protected method | OnChildAttached |
Protected method | OnChildDetached |
Protected method | OnException | Obsolete.
Protected method | OnParentChanged |
Public method | ToString | Returns a string that represents the current object. (Overrides ObjectToString.)
Protected method | VisitChildren |
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Dispatcher | Gets the dispatcher used to dispatch access to the current Actor.
Top
Version Information

Supported in: 3.1
Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


InstanceCredentials Methods

InstanceCredentials Methods

The InstanceCredentials type exposes the following members.

Methods
 | Name | Description
Public method | AssertEquals | Throws an exception if given credentials are not equal to the current one.
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(InstanceCredentials) | Indicates whether the current object is equal to another object of the same type.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
 | MakeNew | Creates a new InstanceCredentials.
Public method | ToString | Returns the fully qualified type name of this instance. (Overrides ValueTypeToString.)
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


InstanceCredentials.MakeNew Method

InstanceCredentialsMakeNew Method
Creates a new InstanceCredentials.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static InstanceCredentials MakeNew()

Return Value

Type: InstanceCredentials
A new InstanceCredentials.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


IProtectedInterface(T) Methods

IProtectedInterfaceT Methods

The IProtectedInterfaceT generic type exposes the following members.

Methods
 | Name | Description
Public method | GetInterface | Gets a protected interface.
Top
See Also

Reference

IProtectedInterfaceT Interface
PostSharp.Aspects Namespace


ActorExceptionEventArgs Properties

ActorExceptionEventArgs Properties

The ActorExceptionEventArgs type exposes the following members.

Properties
 | Name | Description
Public property | Exception | Gets the exception. (Inherited from ThreadingUnhandledExceptionEventArgs.)
Public property | IsHandled | Determines whether the exception has been handled. Clients of the UnhandledException event must set this property to true if they handle the exception. Otherwise, the exception will be rethrown. (Inherited from ThreadingUnhandledExceptionEventArgs.)
Public property | Source | Gets the source component that caught the exception. (Inherited from ThreadingUnhandledExceptionEventArgs.)
Top
See Also

Reference

ActorExceptionEventArgs Class
PostSharp.Patterns.Threading Namespace


InstanceCredentials.Inequality Operator

InstanceCredentialsInequality Operator
Determines whether two InstanceCredentials are different.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator !=(
    InstanceCredentials left,
    InstanceCredentials right
)

Parameters

left
Type: PostSharp.AspectsInstanceCredentials
An InstanceCredentials object.
right
Type: PostSharp.AspectsInstanceCredentials
An InstanceCredentials object.

Return Value

Type: Boolean
true if left is different than right, otherwise false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


UpgradeableReaderLockAttribute Constructor

UpgradeableReaderLockAttribute Constructor
Initializes a new instance of the UpgradeableReaderLockAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public UpgradeableReaderLockAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

UpgradeableReaderLockAttribute Class
PostSharp.Patterns.Threading Namespace


IProtectedInterface(T) Interface

IProtectedInterfaceT Interface

Note: This API is now obsolete.

Gives access to a 'protected' interface, typically introduced by a CompositionAspect or a IntroduceInterfaceAttribute

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute]
public interface IProtectedInterface<T>

Type Parameters

T
Exposed interface.

The IProtectedInterfaceT type exposes the following members.

Methods
 | Name | Description
Public method | GetInterface | Gets a protected interface.
Top
Remarks

A 'protected' interface is not directly implemented by the type. Instead, the type exposes it through the IProtectedInterfaceT interface. When an object wants access to a protected interface, it must provide valid InstanceCredentials. Since the method providing InstanceCredentials is protected, it allows an instance to control which code can have access to protected semantics.

Note Note
Protected interfaces are considered obsolete. It is suggested to use techniques that do not require instance credentials.
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

PostSharp.Aspects Namespace


IReaderWriterSynchronized.Lock Property

IReaderWriterSynchronizedLock Property
Gets the ReaderWriterLockSlim that has to be used to synchronize access to the current instance.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
PortableReaderWriterLock Lock { get; }

Property Value

Type: PortableReaderWriterLock
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IReaderWriterSynchronized Interface
PostSharp.Patterns.Threading Namespace


InstanceCredentials Operators

InstanceCredentials Operators

The InstanceCredentials type exposes the following members.

Operators
Name | Description
Equality | Determines whether two InstanceCredentials are equal.
Inequality | Determines whether two InstanceCredentials are different.
Top
See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


Actor Properties

Actor Properties

The Actor type exposes the following members.

Properties
 | Name | Description
Public property | Dispatcher | Gets the dispatcher used to dispatch access to the current Actor.
Top
See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


InstanceCredentials.Equals Method

InstanceCredentialsEquals Method
Overload List
 | Name | Description
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(InstanceCredentials) | Indicates whether the current object is equal to another object of the same type.
Top
See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


ObserverLockAttribute.CompileTimeValidate Method

ObserverLockAttributeCompileTimeValidate Method
Method invoked at build time to ensure that the aspect has been applied to the right target.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public bool CompileTimeValidate(
    Object target
)

Parameters

target
Type: SystemObject
Target element.

Return Value

Type: Boolean
true if the aspect was applied to an acceptable target, otherwise false.

Implements

IValidableAnnotationCompileTimeValidate(Object)
Remarks
The implementation of this method is expected to emit an error message or an exception of type InvalidAnnotationException in case of error. Only returning false causes the aspect to be silently ignored.
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ObserverLockAttribute Class
PostSharp.Patterns.Threading Namespace


ObserverLockAttribute Class

ObserverLockAttribute Class

Note: This API is now obsolete.

Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingReaderWriterLockAttribute
PostSharp.Patterns.ThreadingObserverLockAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use YieldAttribute.")]
public sealed class ObserverLockAttribute : ReaderWriterLockAttribute,
    IValidableAnnotation

The ObserverLockAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ObserverLockAttribute | Initializes a new instance of the ObserverLockAttribute class
Top
Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 3.1
Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


ReaderLockAttribute Class

ReaderLockAttribute Class

Note: This API is now obsolete.

Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingReaderWriterLockAttribute
PostSharp.Patterns.ThreadingReaderAttribute
PostSharp.Patterns.ThreadingReaderLockAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use ReaderAttribute.")]
public sealed class ReaderLockAttribute : ReaderAttribute

The ReaderLockAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | ReaderLockAttribute | Initializes a new instance of the ReaderLockAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 3.1
Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


WriterLockAttribute Class

WriterLockAttribute Class

Note: This API is now obsolete.

Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingReaderWriterLockAttribute
PostSharp.Patterns.ThreadingWriterAttribute
PostSharp.Patterns.ThreadingWriterLockAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use WriterAttribute.")]
public sealed class WriterLockAttribute : WriterAttribute

The WriterLockAttribute type exposes the following members.

Constructors
 | Name | Description
Public method | WriterLockAttribute | Initializes a new instance of the WriterLockAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 3.1
Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


Actor.OnAncestorChanged Method

ActorOnAncestorChanged Method

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void OnAncestorChanged(
    AncestorChangedEventArgs args
)

Parameters

args
Type: PostSharp.Patterns.ModelAncestorChangedEventArgs
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


ReaderLockAttribute Properties

ReaderLockAttribute Properties

The ReaderLockAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

ReaderLockAttribute Class
PostSharp.Patterns.Threading Namespace


ObserverLockAttribute Properties

ObserverLockAttribute Properties

The ObserverLockAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

ObserverLockAttribute Class
PostSharp.Patterns.Threading Namespace


Actor.OnParentChanged Method

ActorOnParentChanged Method

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void OnParentChanged()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


InstanceCredentials.AssertEquals Method

InstanceCredentialsAssertEquals Method
Throws an exception if given credentials are not equal to the current one.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public void AssertEquals(
    InstanceCredentials others
)

Parameters

others
Type: PostSharp.AspectsInstanceCredentials
Other credentials.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


ObserverLockAttribute Methods

ObserverLockAttribute Methods

The ObserverLockAttribute type exposes the following members.

Methods
 | Name | Description
Public method | CompileTimeValidate | Method invoked at build time to ensure that the aspect has been applied to the right target.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ObserverLockAttribute Class
PostSharp.Patterns.Threading Namespace


Actor.OnException Method

ActorOnException Method

Note: This API is now obsolete.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use ThreadingServices.UnhandledException.")]
protected virtual void OnException(
    ActorExceptionEventArgs eventArgs
)

Parameters

eventArgs
Type: PostSharp.Patterns.ThreadingActorExceptionEventArgs
Version Information

Supported in: 3.1
Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0

See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


InstanceCredentials.Null Field

InstanceCredentialsNull Field
Gets a null (or empty) InstanceCredentials/

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static readonly InstanceCredentials Null

Field Value

Type: InstanceCredentials
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


Actor Constructor

Actor Constructor
Overload List
 | Name | Description
Protected method | Actor(ConstructorDepth) | Initializes a new instance of the Actor class
Protected method | Actor(IDispatcher, ConstructorDepth) | Initializes a new instance of the Actor class
Top
See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


IComposed(T) Methods

IComposedT Methods

The IComposedT generic type exposes the following members.

Methods
 | Name | Description
Public method | GetImplementation | Gets the object implementing the interface T on behalf of the current instance.
Top
See Also

Reference

IComposedT Interface
PostSharp.Aspects Namespace


Actor.GetHashCode Method

ActorGetHashCode Method
Serves as a hash function for a particular type.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int GetHashCode()

Return Value

Type: Int32
A hash code for the current Object.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


WriterLockAttribute Methods

WriterLockAttribute Methods

The WriterLockAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

WriterLockAttribute Class
PostSharp.Patterns.Threading Namespace


InstanceCredentials.ToString Method

InstanceCredentialsToString Method
Returns the fully qualified type name of this instance.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override string ToString()

Return Value

Type: String
A String containing a fully qualified type name.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


Actor.Dispatcher Property

ActorDispatcher Property
Gets the dispatcher used to dispatch access to the current Actor.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public IDispatcher Dispatcher { get; }

Property Value

Type: IDispatcher
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


InstanceCredentials Structure

InstanceCredentials Structure

Note: This API is now obsolete.

Credentials that give access to 'protected' semantics.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[SerializableAttribute]
[ObsoleteAttribute]
public struct InstanceCredentials : IEquatable<InstanceCredentials>

The InstanceCredentials type exposes the following members.

Methods
 | Name | Description
Public method | AssertEquals | Throws an exception if given credentials are not equal to the current one.
Public method | Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object).)
Public method | Equals(InstanceCredentials) | Indicates whether the current object is equal to another object of the same type.
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
 | MakeNew | Creates a new InstanceCredentials.
Public method | ToString | Returns the fully qualified type name of this instance. (Overrides ValueTypeToString.)
Top
Operators
Name | Description
Equality | Determines whether two InstanceCredentials are equal.
Inequality | Determines whether two InstanceCredentials are different.
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Fields
Name | Description
Null | Gets a null (or empty) InstanceCredentials/
Top
Remarks

A protected semantic is specified by an interface with public visibility, but code can only get this interface when it provides the semantics represented by the current type. Instance semantics are typically retrieved by an instance method GetInstanceCredentials, which has protected visibility. This method is implemented by PostSharp automatically.

Note Note
Instance credentials are considered obsolete. It is suggested to use techniques that do not require instance credentials.
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

PostSharp.Aspects Namespace


ActorExceptionEventArgs Methods

ActorExceptionEventArgs Methods

The ActorExceptionEventArgs type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ActorExceptionEventArgs Class
PostSharp.Patterns.Threading Namespace


IComposed(T) Interface

IComposedT Interface

Note: This API is now obsolete.

Interface exposing the implementation of another interface introduced by a CompositionAspect.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute]
public interface IComposed<T>

Type Parameters

T
Interface whose implementation is expose.

The IComposedT type exposes the following members.

Methods
 | Name | Description
Public method | GetImplementation | Gets the object implementing the interface T on behalf of the current instance.
Top
Version Information

Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0
Obsolete (compiler warning) in 3.1

See Also

Reference

PostSharp.Aspects Namespace


ReaderWriterLockAttribute Properties

ReaderWriterLockAttribute Properties

The ReaderWriterLockAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

ReaderWriterLockAttribute Class
PostSharp.Patterns.Threading Namespace


InstanceCredentials Fields

InstanceCredentials Fields

The InstanceCredentials type exposes the following members.

Fields
Name | Description
Null | Gets a null (or empty) InstanceCredentials/
Top
See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


Actor.VisitChildren Method

ActorVisitChildren Method

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual bool VisitChildren(
    ChildVisitor visitor,
    ChildVisitorOptions options,
    Object state
)

Parameters

visitor
Type: PostSharp.Patterns.ModelChildVisitor
options
Type: PostSharp.Patterns.ModelChildVisitorOptions
state
Type: SystemObject

Return Value

Type: Boolean
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


ReaderWriterLockAttribute Class

ReaderWriterLockAttribute Class

Note: This API is now obsolete.

Inheritance Hierarchy
SystemObject
SystemAttribute
PostSharp.ExtensibilityMulticastAttribute
PostSharp.Patterns.ThreadingAccessLevelAttribute
PostSharp.Patterns.ThreadingReaderWriterLockAttribute
PostSharp.Patterns.ThreadingObserverLockAttribute
PostSharp.Patterns.ThreadingReaderAttribute
PostSharp.Patterns.ThreadingUpgradeableReaderAttribute
PostSharp.Patterns.ThreadingWriterAttribute
PostSharp.Patterns.ThreadingYielderAttribute

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use AccessLevelAttribute.")]
public abstract class ReaderWriterLockAttribute : AccessLevelAttribute

The ReaderWriterLockAttribute type exposes the following members.

Constructors
 | Name | Description
Protected method | ReaderWriterLockAttribute | Initializes a new instance of the ReaderWriterLockAttribute class
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
Version Information

Supported in: 3.1
Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


Actor Methods

Actor Methods

The Actor type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified Object is equal to the current Object. (Overrides ObjectEquals(Object).)
Public method | GetHashCode | Serves as a hash function for a particular type. (Overrides ObjectGetHashCode.)
Protected method | OnAncestorChanged |
Protected method | OnChildAttached |
Protected method | OnChildDetached |
Protected method | OnException | Obsolete.
Protected method | OnParentChanged |
Public method | ToString | Returns a string that represents the current object. (Overrides ObjectToString.)
Protected method | VisitChildren |
Top
Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


UpgradeableReaderLockAttribute Properties

UpgradeableReaderLockAttribute Properties

The UpgradeableReaderLockAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

UpgradeableReaderLockAttribute Class
PostSharp.Patterns.Threading Namespace


IProtectedInterface(T).GetInterface Method

IProtectedInterfaceTGetInterface Method
Gets a protected interface.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
T GetInterface(
    InstanceCredentials credentials
)

Parameters

credentials
Type: PostSharp.AspectsInstanceCredentials
Credentials of the current instance.

Return Value

Type: T
The implementation of the interface T.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IProtectedInterfaceT Interface
PostSharp.Aspects Namespace


UpgradeableReaderLockAttribute Methods

UpgradeableReaderLockAttribute Methods

The UpgradeableReaderLockAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

UpgradeableReaderLockAttribute Class
PostSharp.Patterns.Threading Namespace


InstanceCredentials.GetHashCode Method

InstanceCredentialsGetHashCode Method
Returns the hash code for this instance.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override int GetHashCode()

Return Value

Type: Int32
A 32-bit signed integer that is the hash code for this instance.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


ReaderWriterLockAttribute Constructor

ReaderWriterLockAttribute Constructor
Initializes a new instance of the ReaderWriterLockAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected ReaderWriterLockAttribute()
Version Information

Supported in: 4.1, 4.0

See Also

Reference

ReaderWriterLockAttribute Class
PostSharp.Patterns.Threading Namespace


ReaderLockAttribute Methods

ReaderLockAttribute Methods

The ReaderLockAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReaderLockAttribute Class
PostSharp.Patterns.Threading Namespace


Actor Constructor (ConstructorDepth)

Actor Constructor (ConstructorDepth)
Initializes a new instance of the Actor class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected Actor(
    ConstructorDepth __depth
)

Parameters

__depth
Type: PostSharp.AspectsConstructorDepth
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Actor Class
Actor Overload
PostSharp.Patterns.Threading Namespace


InstanceCredentials.Equals Method (Object)

InstanceCredentialsEquals Method (Object)
Indicates whether this instance and a specified object are equal.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool Equals(
    Object obj
)

Parameters

obj
Type: SystemObject
Another object to compare to.

Return Value

Type: Boolean
true if obj and this instance are the same type and represent the same value; otherwise, false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceCredentials Structure
Equals Overload
PostSharp.Aspects Namespace


Actor.ToString Method

ActorToString Method
Returns a string that represents the current object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override string ToString()

Return Value

Type: String
A string that represents the current object.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


IReaderWriterSynchronized Interface

IReaderWriterSynchronized Interface

Note: This API is now obsolete.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use IThreadAware.ConcurrencyController.", true)]
public interface IReaderWriterSynchronized

The IReaderWriterSynchronized type exposes the following members.

Properties
 | Name | Description
Public property | Lock | Gets the ReaderWriterLockSlim that has to be used to synchronize access to the current instance.
Top
Version Information

Supported in: 3.1
Obsolete (does not compile) in 4.0 and later

See Also

Reference

PostSharp.Patterns.Threading Namespace


WriterLockAttribute Properties

WriterLockAttribute Properties

The WriterLockAttribute type exposes the following members.

Properties
 | Name | Description
Public property | AttributeExclude | If true, indicates that this attribute removes all other instances of the same attribute type from the set of elements defined by the current instance. (Inherited from MulticastAttribute.)
Public property | AttributeInheritance | Determines whether this attribute is inherited (Inherited from MulticastAttribute.)
Public property | AttributePriority | Gets or sets the priority of the current attribute in case that multiple instances are defined on the same element (lower values are processed before). (Inherited from MulticastAttribute.)
Public property | AttributeReplace | Determines whether this attribute replaces other attributes found on the target declarations. (Inherited from MulticastAttribute.)
Public property | AttributeTargetAssemblies | Gets or sets the assemblies to which the current attribute apply. (Inherited from MulticastAttribute.)
Public property | AttributeTargetElements | Gets or sets the kind of elements to which this custom attributes applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies, when the member is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetExternalTypeAttributes | Gets or sets the visibilities of types to which this attribute applies, when this type is external to the current module. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMemberAttributes | Gets or sets the visibilities, scopes, virtualities, and implementation of members to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetMembers | Gets or sets the expression specifying to which members this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameterAttributes | Gets or sets the passing style (by value, out or ref) of parameters to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetParameters | Gets or sets the expression specifying to which parameters this instance applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypeAttributes | Gets or sets the visibilities of types to which this attribute applies. (Inherited from MulticastAttribute.)
Public property | AttributeTargetTypes | Gets or sets the expression specifying to which types this instance applies. (Inherited from MulticastAttribute.)
Top
See Also

Reference

WriterLockAttribute Class
PostSharp.Patterns.Threading Namespace


Actor Constructor (IDispatcher, ConstructorDepth)

Actor Constructor (IDispatcher, ConstructorDepth)
Initializes a new instance of the Actor class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected Actor(
    IDispatcher dispatcher,
    ConstructorDepth __depth
)

Parameters

dispatcher
Type: PostSharp.Patterns.ThreadingIDispatcher
__depth
Type: PostSharp.AspectsConstructorDepth
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Actor Class
Actor Overload
PostSharp.Patterns.Threading Namespace


InstanceCredentials.Equality Operator

InstanceCredentialsEquality Operator
Determines whether two InstanceCredentials are equal.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public static bool operator ==(
    InstanceCredentials left,
    InstanceCredentials right
)

Parameters

left
Type: PostSharp.AspectsInstanceCredentials
An InstanceCredentials object.
right
Type: PostSharp.AspectsInstanceCredentials
An InstanceCredentials object.

Return Value

Type: Boolean
true if left equals right, otherwise false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

InstanceCredentials Structure
PostSharp.Aspects Namespace


Actor.OnChildDetached Method

ActorOnChildDetached Method

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void OnChildDetached(
    Object child,
    ChildInfo childInfo
)

Parameters

child
Type: SystemObject
childInfo
Type: PostSharp.Patterns.ModelChildInfo
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


Actor.OnChildAttached Method

ActorOnChildAttached Method

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
protected virtual void OnChildAttached(
    Object child,
    ChildInfo childInfo
)

Parameters

child
Type: SystemObject
childInfo
Type: PostSharp.Patterns.ModelChildInfo
Version Information

Supported in: 4.1, 4.0

See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


WriterLockAttribute Constructor

WriterLockAttribute Constructor
Initializes a new instance of the WriterLockAttribute class

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public WriterLockAttribute()
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

WriterLockAttribute Class
PostSharp.Patterns.Threading Namespace


ReaderWriterLockAttribute Methods

ReaderWriterLockAttribute Methods

The ReaderWriterLockAttribute type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
See Also

Reference

ReaderWriterLockAttribute Class
PostSharp.Patterns.Threading Namespace


Actor.Equals Method

ActorEquals Method
Determines whether the specified Object is equal to the current Object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
public override bool Equals(
    Object obj
)

Parameters

obj
Type: SystemObject
The object to compare with the current object.

Return Value

Type: Boolean
true if the specified object is equal to the current object; otherwise, false.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

Actor Class
PostSharp.Patterns.Threading Namespace


IComposed(T).GetImplementation Method

IComposedTGetImplementation Method
Gets the object implementing the interface T on behalf of the current instance.

Namespace: PostSharp.Aspects
Assembly: PostSharp (in PostSharp.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
T GetImplementation(
    InstanceCredentials credentials
)

Parameters

credentials
Type: PostSharp.AspectsInstanceCredentials
Credentials provided by the current instance.

Return Value

Type: T
The object implementing the interface T on behalf of the current instance.
Version Information

Supported in: 4.1, 4.0, 3.1

See Also

Reference

IComposedT Interface
PostSharp.Aspects Namespace


ActorExceptionEventArgs Class

ActorExceptionEventArgs Class

Note: This API is now obsolete.

Inheritance Hierarchy
SystemObject
SystemEventArgs
PostSharp.Patterns.ThreadingThreadingUnhandledExceptionEventArgs
PostSharp.Patterns.ThreadingActorExceptionEventArgs

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 4.1.7.0 (4.1.7.0)
Syntax
C#
Copy
[ObsoleteAttribute("Use ThreadingServices.UnhandledException.")]
public sealed class ActorExceptionEventArgs : ThreadingUnhandledExceptionEventArgs

The ActorExceptionEventArgs type exposes the following members.

Extension Methods
 | Name | Description
Public Extension Method | QueryInterfaceT | Gets the implementation of a specified interface for the specified object. (Defined by QueryInterfaceExtensions.)
Top
Properties
 | Name | Description
Public property | Exception | Gets the exception. (Inherited from ThreadingUnhandledExceptionEventArgs.)
Public property | IsHandled | Determines whether the exception has been handled. Clients of the UnhandledException event must set this property to true if they handle the exception. Otherwise, the exception will be rethrown. (Inherited from ThreadingUnhandledExceptionEventArgs.)
Public property | Source | Gets the source component that caught the exception. (Inherited from ThreadingUnhandledExceptionEventArgs.)
Top
Version Information

Supported in: 3.1
Obsolete (compiler warning) in 4.1
Obsolete (compiler warning) in 4.0

See Also

Reference

PostSharp.Patterns.Threading Namespace


Installing PostSharp Unattended

Installing PostSharp Unattended

PostSharp is composed of a user interface (PostSharp Tools for Visual Studio) and build components (NuGet packages). NuGet packages are usually checked into source control or retrieved from a package repository at build time (see Restoring Packages at Build Time), so its deployment does not require additional automation. The user interface is typically installed by each user. It does not require administrative privileges.

Caution note Caution

The PostSharp user interface requires NuGet Package Manager 2.2, which is not installed by default with Visual Studio. Installing NuGet requires administrative privileges on the local machine.

You can install PostSharp automatically for a large number of users using a script.

To install PostSharp on a machine:

  1. Ensure that NuGet 2.2 is installed. Your script will need to look for a file named NuGet.Core.dll under the following directories. The search should include up to 2 levels of subdirectories.

    • C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions for Visual Studio 2010.

    • C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions for Visual Studio 2012.

  2. If NuGet 2.2 is not installed, install it with the command line VsixInstaller.exe /q NuGet.Tools.vsix. This command requires administrative privileges on the local machine. The current version of NuGet.Tools.vsix can be downloaded from Visual Studio Gallery. Note that PostSharp is tested with versions that are current at the time of writing. If you need to be able to restore a working development environment several years from now, it is a good idea to archive a version of NuGet that is known to work with your version of PostSharp.

  3. Execute command line VsixInstaller.exe /q PostSharp-VERSION.vsix. The file can be downloaded from Visual Studio Gallery. Exit codes other than 0 or 1001 should be considered as errors.

  4. Install the license key or the license server URL in the registry key HKEY_CURRENT_USER\Software\SharpCrafters\PostSharp 3, registry value LicenseKey (type REG_SZ).

This procedure can be automated by the following PowerShell 2.0 script:

Copy
# TODO: Set the right value for the following variables
$postsharpFile = "PostSharp-3.0.14-beta.vsix"   # Replace with the proper version number and add the full path.
$nugetFile = "NuGet.Tools.vsix"                 # Add the full path.
$license = "XXXX-XXXXXXXXXXXXXXXXXXXXXXXXX"     # Replace by your license key or license server URL.

$installNuget = $false

# Check NuGet in Visual Studio 2010.
if ( Test-Path "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" )
{

    $vsixInstaller = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\VsixInstaller.exe"

    $nugetVs10Path = dir "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions" -Include "NuGet.Core.dll" -Recurse | select -First 1

    if ( $nugetVs10Path -eq $null )
    {
        $installNuget = $true
    }
    else
    {
        $nugetVs10Version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($nugetVs10Path)
        Write-Host "Detected NuGet" $nugetVs10Version.FileVersion "for Visual Studio 2010."
        if ( $nugetVs10Version.FileMajorPart -lt 2 -or $nugetVs10Version.FileMinorPart -lt 1 )
        {
            $installNuget = $true;
        }
    }
}

# Check NuGet in Visual Studio 2012.
if ( Test-Path "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" )
{

    $vsixInstaller = "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\VsixInstaller.exe"
    $nugetVs11Path = dir "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions" -Include "NuGet.Core.dll" -Recurse | select -First 1

    if ( $nugetVs11Path -eq $null )
    {
        $installNuget = $true
    }
    else
    {
        $nugetVs11Version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($nugetVs10Path)
        Write-Host "Detected NuGet"  $nugetVs11Version.FileVersion "for Visual Studio 2012."
        if ( $nugetVs11Version.FileMajorPart -lt 2 -or $nugetVs11Version.FileMinorPart -lt 1 )
        {
            $installNuget = $true;
        }
    }
}

if ( -not ( Test-Path $vsixInstaller) )
{
    Write-Host "Cannot find " $vsixInstaller
    exit
}

# Install NuGet
if ( $installNuget )
{
    Write-Host "Installing NuGet"
    $process = Start-Process -FilePath  $vsixInstaller -ArgumentList @("/q", $nugetFile) -Wait -Verb runas  -PassThru
    if ( $process.ExitCode -ne 0 -and $process.ExitCode -ne 1001)
    {
        Write-Host "Error: VsixInstaller exited with code" $process.ExitCode -ForegroundColor Red
    }
}

# Install PostSharp
Write-Host "Installing PostSharp"
$process = Start-Process -FilePath $vsixInstaller -ArgumentList @("/q", $postsharpFile) -Wait -PassThru
if ( $process.ExitCode -ne 0 -and $process.ExitCode -ne 1001)
{
    Write-Host "Error: VsixInstaller exited with code" $process.ExitCode -ForegroundColor Red
}

# Install the license key
Write-Host "Installing the license key"
$regPath = "HKCU:\Software\SharpCrafters\PostSharp 3"

if ( -not ( Test-Path $regPath ) )
{
    New-Item -Path $regPath | Out-Null
}

Set-ItemProperty -Path $regPath -Name "LicenseKey" -Value $license

Write-Host "Done"