Between the versions 0.6 and 0.9 of Mono.Cecil, the API evolved in a few directions:
Porting applications to the new Mono.Cecil is easy. We suggest you branch your project using Cecil in time to stabilize it on the new version of Mono.Cecil. For most projects I’ve personally ported, half a day was enough to get it running and enjoy the speed of the new version of Cecil.
Changes to take care of:
AssemblyFactoryis no more. You can use the
AssemblyDefinition.ReadAssemblystatic methods, and call
Writeon them to write them back.
ModuleDefinition.Typesnow only returns top level (not nested) types. If you want to iterate over all the types defined in an assembly, you can use the method
TypeDefinition.Constructorsis merged inside
TypeDefinition.Methods. It was a Cecil thing, and it was breaking the order in which methods are defined in the type.
ParameterDefinition.Sequencewas a one-based index of the parameter. It has been replaced by
ParameterDefinition.Indexwhich is zero-based. To help porting your application, you can replace your usage of the
Sequenceproperty to use the extension method
Mono.Cecil.Rocks.ParameterReferenceRocks.GetSequence (this ParameterReference self).
IMethodSignature.ReturnType(which impacts types such as
MethodDefinitionnow directly returns a
TypeReference. It avoids the recurring pattern:
method.ReturnType.ReturnTypethat was often found in previous Cecil code. If you still want to have access to the custom attributes or the marshal informations specified on the return type, you can use
method.ReturnTypeis just a fast path for
TypeDefinitionCollectionthat was used to retrieve a
TypeDefinitionbased on its full name. It has been replaced by the
(string) attribute.ConstructorParameters . It has to be replaced with
(string) attribute.ConstructorArguments .Value.
.ConstructorArgument returns a
CustomAttributeArgumentthat has both a
TypeReference Typeproperty and a
CilWorkeris no more, it has been renamed to
ILProcessor, and you get one by calling