Representation of Types

Types are represented by various means in PostSharp. The first important distinction is the one between types and type signatures:

Semantics of types are derived from semantics of type signatures.

Type Signatures

Type signatures are specified by the ITypeSignature interface and have the following semantics:

Note that type signatures are not necessarily metadata declarations, i.e. they do not need an entry in module metadata tables.

Types

When types are defined inside the current module, they are represented by the TypeDefDeclaration class. When they are defined in an external module or an external assembly, they are represented by the TypeRefDeclaration class.

Type constructions TypeSpecDeclaration are a very specific case. A TypeSpecDeclaration is basically a metadata table entry to 'wrap' a type signature. However, when the type signature is a generic instance (i.e. generic construction), the type construction may have fields and methods. So generic constructions behave nearly as 'normal' types, but they have no name.

To take this specificity into account, we defined two interfaces: IType, extended by INamedType. IType interface.

Additionally from the semantics inherited from the ITypeSignature interface, the IType interface has the following semantics:

The only additional semantics of INamedType over IType is that named types have... a name.

Generic parameters

Since generic parameters are placeholders for type signatures, they have semantics of a type signature and implement the ITypeSignature interface. See Generics for more details about generic parameters.