Open sandboxFocus

Class PureAttribute

Custom attribute that, when applied on a method, specifies that this method is a pure function, that is, 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 (int, string, and so on). 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
PureAttribute
Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model.dll
Syntax
[AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Method, AllowMultiple = true)]
[MulticastAttributeUsage(MulticastTargets.Method, PersistMetaData = true, AllowMultiple = false)]
public sealed class PureAttribute : MulticastAttribute, IValidableAnnotation
Remarks

The dependency analysis of the NotifyPropertyChangedAttribute aspect cannot analyze calls to most static methods and to methods of other classes, and reports an error when a property getter calls one. Mark such a helper method as pure to allow the call: the analysis then accepts the call without analyzing the body of the method.

When you apply this attribute to a class, a struct or an assembly, it applies to all methods of that declaration.

Constructors

Name Description
PureAttribute()

Methods

Name Description
CompileTimeValidate(object)

Method invoked at build time to ensure that the aspect has been applied to the right target.

See Also