using Mono.Cecil; MethodDefinition myMethod = ... // Get the method definition if (myMethod.IsGeneratedCode) { Console.WriteLine("This method is generated code."); }
using Mono.Cecil; foreach(MethodDefinition myMethod in assemblyDefinition.Modules.SelectMany(module => module.GetTypes()).SelectMany(type => type.Methods)) { if (!myMethod.IsGeneratedCode) { // Perform analysis on the method here } }In this example, we loop through all methods in an assembly and exclude generated code from being analyzed by checking the IsGeneratedCode property of each method. Package/Library: Mono.Cecil