コード例 #1
0
        public static MethodBodyInfo Create(MethodBase method)
        {
            MethodBodyInfo mbi = new MethodBodyInfo();

            mbi.Identity       = method.GetHashCode();
            mbi.TypeName       = method.GetType().Name;
            mbi.MethodToString = method.ToString();
            ReadableILStringVisitor readableIlStringVisitor = new ReadableILStringVisitor((IILStringCollector) new MethodBodyInfo.MethodBodyInfoBuilder(mbi), (IFormatProvider)DefaultFormatProvider.Instance);

            new ILReader(method).Accept((ILInstructionVisitor)readableIlStringVisitor);
            return(mbi);
        }
コード例 #2
0
        protected override void DoChecks(MethodBase mehodBeingChecked, MethodBodyInfo methodBody, Dependency parent)
        {
            foreach (ILInstruction instruction in methodBody.Instructions)
            {
                if (instruction is InlineMethodInstruction)
                {
                    InlineMethodInstruction line = instruction as InlineMethodInstruction;
                    if (line.Method.IsVirtual)
                    {
                        parent.Add(new VirtualMethodCallDependency(line.Method.ReflectedType.Name, line.Method.Name));

                    }
                }
            }
        }
コード例 #3
0
        protected override void DoChecks(MethodBase mehodBeingChecked, MethodBodyInfo methodBody, Dependency parent)
        {
            foreach (ILInstruction instruction in methodBody.Instructions)
            {
                if (instruction is InlineMethodInstruction)
                {
                    InlineMethodInstruction line = instruction as InlineMethodInstruction;
                    if (line.Method.IsStatic)
                    {
                        string message =
                            string.Format("Static method call {0} on {1}", line.Method.Name,
                                          line.Method.ReflectedType.Name);

                        parent.Add(new ProblemDependency(message));
                    }
                }
            }
        }
コード例 #4
0
            public MethodBodyInfoBuilder(MethodBodyInfo mbi)
            {
                m_mbi = mbi;
                m_indent = "";

                m_starts = new HashSet<int>();
                m_ends = new HashSet<int>();
                m_startFinally = new HashSet<int>();
                m_startFault = new HashSet<int>();
                m_startFilter = new HashSet<int>();
                m_startCatch = new Dictionary<int, Type>();
                m_endCatch = new HashSet<int>();

                foreach (var e in mbi.Exceptions)
                {
                    var finallyOrFault = e.Handlers.Count(h => h.Kind == HandlerKind.Finally || h.Kind == HandlerKind.Fault);
                    var numberOfCatch = e.Handlers.Length - finallyOrFault;

                    m_starts.Add(e.StartAddress);
                    m_ends.Add(e.EndAddress);

                    foreach (var c in e.Handlers)
                    {
                        if (c.Kind == HandlerKind.Finally)
                        {
                            m_startFinally.Add(c.StartAddress);
                        }
                        else if (c.Kind == HandlerKind.Fault)
                        {
                            m_startFault.Add(c.StartAddress);
                        }
                        else if (c.Kind == HandlerKind.Filter)
                        {
                            m_startFilter.Add(c.StartAddress);
                        }
                        else
                        {
                            m_startCatch.Add(c.StartAddress, c.Type);
                        }
                        m_endCatch.Add(c.EndAddress);
                    }
                }
            }
コード例 #5
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;
        }
コード例 #6
0
            public MethodBodyInfoBuilder(MethodBodyInfo mbi)
            {
                m_mbi    = mbi;
                m_indent = "";

                m_starts       = new HashSet <int>();
                m_ends         = new HashSet <int>();
                m_startFinally = new HashSet <int>();
                m_startFault   = new HashSet <int>();
                m_startFilter  = new HashSet <int>();
                m_startCatch   = new Dictionary <int, Type>();
                m_endCatch     = new HashSet <int>();

                foreach (var e in mbi.Exceptions)
                {
                    var finallyOrFault = e.Handlers.Count(h => h.Kind == HandlerKind.Finally || h.Kind == HandlerKind.Fault);
                    var numberOfCatch  = e.Handlers.Length - finallyOrFault;

                    m_starts.Add(e.StartAddress);
                    m_ends.Add(e.EndAddress);

                    foreach (var c in e.Handlers)
                    {
                        if (c.Kind == HandlerKind.Finally)
                        {
                            m_startFinally.Add(c.StartAddress);
                        }
                        else if (c.Kind == HandlerKind.Fault)
                        {
                            m_startFault.Add(c.StartAddress);
                        }
                        else if (c.Kind == HandlerKind.Filter)
                        {
                            m_startFilter.Add(c.StartAddress);
                        }
                        else
                        {
                            m_startCatch.Add(c.StartAddress, c.Type);
                        }
                        m_endCatch.Add(c.EndAddress);
                    }
                }
            }
コード例 #7
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);
        }
コード例 #8
0
 public MethodBodyInfoBuilder(MethodBodyInfo mbi)
 {
     this.m_mbi = mbi;
 }
コード例 #9
0
ファイル: MethodBodyInfo.cs プロジェクト: jklipp/codegravity
 public static MethodBodyInfo Create(MethodBase method)
 {
     MethodBodyInfo mbi = new MethodBodyInfo();
       mbi.Identity = method.GetHashCode();
       mbi.TypeName = method.GetType().Name;
       mbi.MethodToString = method.ToString();
       ReadableILStringVisitor readableIlStringVisitor = new ReadableILStringVisitor((IILStringCollector) new MethodBodyInfo.MethodBodyInfoBuilder(mbi), (IFormatProvider) DefaultFormatProvider.Instance);
       new ILReader(method).Accept((ILInstructionVisitor) readableIlStringVisitor);
       return mbi;
 }
コード例 #10
0
ファイル: MethodBodyInfo.cs プロジェクト: jklipp/codegravity
 public MethodBodyInfoBuilder(MethodBodyInfo mbi)
 {
     this.m_mbi = mbi;
 }