Ejemplo n.º 1
0
        public static MethodBodyInfo Create(MethodBase method)
        {
            MethodBodyInfo mbi = new MethodBodyInfo();

            mbi.Identity = method.GetHashCode();
            mbi.TypeName = method.GetType().Name;
            mbi.MethodToString = ".method " + method.ToIL();

            ILReader reader = ILReaderFactory.Create(method);
            mbi.Exceptions = reader.ILProvider.GetExceptionInfos();

            ReadableILStringVisitor visitor = new ReadableILStringVisitor(
                new MethodBodyInfoBuilder(mbi),
                DefaultFormatProvider.Instance);

            reader.Accept(visitor);

            return mbi;
        }