About the Code Object Model
The Code Object Model, implemented in the PostSharp.CodeModel namespace, is by far the most important and the most complex component of PostSharp.
The Code Object Model represents .NET assemblies in all details and with high fidelity. It contains classes to define types, fields, methods, security attributes, type references, exception handler and so on.
What is more, the Code Object Model provides a lot of high-level operations that make it reasonably easy to browse and modify an assembly.
Structure of this chapter
- Section Modules, Assemblies
and Domains explain how these three entities relate between
themselves in PostSharp and what are the differences with
System.Reflection. - Section Types describes the various representation of types in PostSharp. It presents different interfaces and briefly list their semantics.
- Section Generic Constructions gives the precise formalism of generic types and methods in PostSharp. It explains the differences with System.Reflection and introduces the main interfaces and their semantics.
- Section Method Bodies explains how method implementations are structured in PostSharp (instruction sequences, instruction blocks, exception handlers) and what are the principal classes that work with instruction streams.
- Section Debugging shows how to work with debugging symbols (local variable symbols and symbol sequence points) inside method bodies.
- Section Binding PostSharp Modules discusses how to relate or translate declarations of one module into another.
- Section Binding With
System.Reflection shows how to get PostSharp objects when you
know its
System.Reflectionrepresentation (i.e.Type,FieldInfo,MethodBase, ...). - Section Platform Invoke briefly points out some classes that describe how native platform calls should be marshalled.
- Section Serialized Values describes how arguments of custom and security attributes, among others, are represented.
- Finally, the Utilities & Tricks section shows some methods and utility classes that make work with the object model easier.