Esempio n. 1
0
        public IEnumerable <string> GetCallStack()
        {
            var stackLines  = new List <string>();
            var stackFrames = dte
                              .With(_dte => _dte.Debugger)
                              .With(debugger => debugger.CurrentThread)
                              .With(curTh => curTh.StackFrames);

            if (stackFrames == null)
            {
                return(stackLines);
            }
            foreach (StackFrame frame in stackFrames)
            {
                var functionStringBuilder = new StringBuilder();
                var argsStringBuilder     = new StringBuilder();

                if (string.IsNullOrEmpty(frame.ReturnType))
                {
                    continue;
                }

                functionStringBuilder.AppendFormat("{0} {1}", frame.ReturnType, frame.FunctionName);

                foreach (var argument in frame.Arguments)
                {
                    var expr = argument as EnvDTE.Expression;
                    if (expr == null || !expr.IsValidValue)
                    {
                        continue;
                    }
                    argsStringBuilder.Append(string.Format("{0} {1} = {2} ", expr.Type, expr.Name, expr.Value));
                }

                stackLines.Add(string.Format("{0}({1})", functionStringBuilder, argsStringBuilder));
            }
            return(stackLines);
        }