cecil

Find argument values of method call in IL.

Hi, I have several special methods, and I want analyze they calls in compiled assembly. Example: public static class SrcHelper { [MySpecialMethod] [Conditional( "DEBUG" )] public static void ToDo( params object[] info ) { /* do nothing */ /* this method is not called when code is compiled in RELEASE mode */...

Mono.Cecil - How to get custom attributes

Hello. I am trying to use Cecil to inspect the attributes associated with a given method. It seems to find it, but I cannot get its name using the following code: AssemblyDefinition assembly = AssemblyFactory.GetAssembly(pathBin); assembly.MainModule.Types[0].Methods[1].CustomAttributes[0].ToString() I know this must be the attribute...

Cecil - Getting the defined attributes properties

Hello. I am using Cecil to try to read my attributes properties: [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] public sealed class TraceMethodAttribute : Attribute { public TraceMethodAttribute() { MethodStart = true; MethodReturn = true; MethodMessages = true; } ...

Mono Cecil vs. PostSharp Core vs. Microsoft CCI for implementing AOP framework

Which is the better in terms of capabilities, easy of use, documentation, samples, community/support, VS integration, known implementations, long-term viability, and build speed to implement a custom AOP framework? I'll start with what I know (I have only tried PostSharp to so far): Microsoft Common Compiler Instrastruture (CCI): I've...

Determine all referenced assemblies

I need to determine all assemblies referenced by a certain .NET Compact Framework assembly. Do you think this is possible with Cecil? This way our deployment tools could automatically resolve all dependencies of our .NET Compact Framework applications. ...

Mono Cecil documentation and tutorials?

Hi, I am new to Mono Cecil! Any comprehensive documentations and tutorials on Mono Cecil? I have seen these articles and video below, so don't give me these links again: http://www.mono-project.com/Cecil%3AFAQ http://blog.paul-mason.co.nz/2009/08/protecting-your-precious-code-monocecil.html http://www.dimecasts.net/Casts/CastDetails...

What are the following constructs in Mono.Cecil referring to in C#?

Can someone explain what are these referring to? MemberReference, TypeReference, ExternType, Override, NestedType, PInvokeInfo, SecurityDeclaration and CustomAttribute and MarshalSpec Best if can illustrate with examples. Will appreciate even if u don't know all, but still help me in understanding those u know. Cos I am trying to write ...

How to tell from a CIL instruction whether a field is read or written to?

I am currently using Mono Cecil to extract data from C# projects. Now I need to check whether a field is read or written to in each method. How can tell from the CIL instruction that a field is being read or written to? Cos I doubt there a library in Mono Cecil similar to Assignment in Eclipse's JDT that allows me to extract the left h...

What do these properties mean in Mono.Cecil?

I am using Lokad shared libraries, which in turn depends on Mono.Cecil. I am a little confused what the following properties mean (they are to do with .NET internals and thus have equivalent .NET internals): PackingSize (they are to do with types as it is in TypeDefinition). Mvid (in ModuleDefinition). ExplicitThis (something to do wi...

DynamicMethod in Cecil

Hello guys, Is there anything similar to Reflection.Emit.DynamicMethod in Cecil? Thanks. DynamicMethod Edit: What about for the following things? EmitCall (e.g. IL.EmitCall(OpCodes.Callvirt, GetBuildKey, null); IL.Emit(OpCodes.Unbox_Any, dependencyType); ) LocalBuilder (e.g. LocalBuilder resolving = ilContext.IL.DeclareLoc...

Replacing instructions in a method's MethodBody

Hi, (First of all, this is a very lengthy post, but don't worry: I've already implemented all of it, I'm just asking your opinion, or possible alternatives.) I'm having trouble implementing the following; I'd appreciate some help: I get a Type as parameter. I define a subclass using reflection. Notice that I don't intend to modify th...

How to alias an interface method implementation with Mono.Cecil?

I'm using Mono.Cecil (version 0.6.9.0) to alias a method that implements an interface method. To do that, I have to add an Override to the target method that points back to the interface method (much like what's possible with VB.NET), like this: using System; using System.Reflection; using Mono.Cecil; class Program { static void Mai...