Open sandboxFocus

Class PSerializableAttribute

Custom attribute that, when applied to a type, causes PostSharp to generate a serializer for use by the PortableFormatter.

Inheritance
PSerializableAttribute
Implements
Namespace: PostSharp.Serialization
Assembly: PostSharp.dll
Syntax
[AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct)]
[MulticastAttributeUsage(MulticastTargets.Class|MulticastTargets.Struct)]
[RequirePostSharp(null, "PortableSerializer")]
[LinesOfCodeAvoided(0)]
public sealed class PSerializableAttribute : MulticastAttribute, IAspect
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.

Aspects are instantiated at build time, serialized into the assembly, and deserialized at run time, so aspect classes and the types of their serialized fields must be serializable. Annotating an aspect class with PSerializableAttribute selects the default serialization strategy, PortableAspectSerializer. Annotating an aspect class with SerializableAttribute instead selects binary serialization, which is considered insecure, and causes the build error LA0206 unless the PostSharpBinaryFormatterAllowed MSBuild property is set to true.

Constructors

Name Description
PSerializableAttribute()

See Also