MSDN-WhiteKnight / CilTools

A set of tools to work with CIL in .NET applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support .override directive

MSDN-WhiteKnight opened this issue · comments

ECMA-335 II.10.3.2

using System;
using System.Reflection;
using CilTools.BytecodeAnalysis;

class Program
{
    static void Main(string[] args)
    {        
        CilGraph graph = CilGraph.Create(typeof(Derived).GetMethod(
            "IBase.PrintName", 
            BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance
            ));
        Console.WriteLine(graph.ToText());
        Console.ReadKey();
    }
}

public interface IBase
{
    void PrintName();
}

public class Derived:IBase
{
    void IBase.PrintName()
    {
        Console.WriteLine("Derived");
    }
}

Current output:

.method   private hidebysig newslot virtual final instance void IBase.PrintName() cil managed
{
 .maxstack   8

          nop
          ldstr       "Derived"
          call        void [mscorlib]System.Console::WriteLine(string)
          nop
          ret
}

Expected output:

.method private hidebysig newslot virtual final 
        instance void  IBase.PrintName() cil managed
{
  .override IBase::PrintName
  .maxstack   8

          nop
          ldstr       "Derived"
          call        void [mscorlib]System.Console::WriteLine(string)
          nop
          ret
}