RecursiveIlFinder.Execute C# (CSharp) Method

Execute() public method

public Execute ( MethodDefinition getMethod ) : void
getMethod MethodDefinition
return void
    public void Execute(MethodDefinition getMethod)
    {
        processedMethods.Add(getMethod);
        if (getMethod.Body == null)
        {
            return;
        }
        foreach (var instruction in getMethod.Body.Instructions)
        {
            Instructions.Add(instruction);
            if (!IsCall(instruction.OpCode))
            {
                continue;
            }
            var methodDefinition = instruction.Operand as MethodDefinition;
            if (methodDefinition == null)
            {
                continue;
            }
            if (methodDefinition.IsGetter || methodDefinition.IsSetter)
            {
                continue;
            }
            if (processedMethods.Contains(methodDefinition))
            {
                continue;
            }
            if (methodDefinition.DeclaringType != typeDefinition)
            {
                continue;
            }
            Execute(methodDefinition);
        }
    }

Usage Example

    void ProcessGet(PropertyDefinition property)
    {
        //Exclude indexers
        if (property.HasParameters)
        {
            return;
        }

        var getMethod = property.GetMethod;

        //Exclude when no get
        if (getMethod == null)
        {
            return;
        }
        //Exclude when abstract
        if (getMethod.IsAbstract)
        {
            return;
        }
        var recursiveIlFinder = new RecursiveIlFinder(property.DeclaringType);

        recursiveIlFinder.Execute(getMethod);
        foreach (var instruction in recursiveIlFinder.Instructions)
        {
            ProcessInstructionForGet(property, instruction);
        }
    }
All Usage Examples Of RecursiveIlFinder::Execute