예제 #1
0
        public static CStackTraceLine[] ParseStackTrace(string stackTrace)
        {
            if (stackTrace != null)
            {
                List <CStackTraceLine> list = new List <CStackTraceLine>();

                int lineStart = 0;
                int lineEnd;

                while (lineStart < stackTrace.Length)
                {
                    // extract next line
                    lineEnd = CStringUtils.EndOfLineIndex(stackTrace, lineStart);
                    string line = stackTrace.Substring(lineStart, lineEnd - lineStart);
                    lineStart = lineEnd + 1;

                    // extract data
                    Match m;
                    if ((m = PatternUnityStackTrace.Match(line)).Success)
                    {
                        GroupCollection groups        = m.Groups;
                        string          sourcePath    = groups[2].Value;
                        string          lineNumberStr = groups[3].Value;
                        int             lineNumber    = CStringUtils.ParseInt(lineNumberStr, -1);

                        list.Add(new CStackTraceLine(line, string.IsNullOrEmpty(sourcePath) ? null : sourcePath, lineNumber, lineNumberStr.Length));
                    }
                    else if ((m = PatternSystemStackTrace.Match(line)).Success)
                    {
                        GroupCollection groups = m.Groups;

                        string method        = groups[1].Value;
                        string args          = OptimizeArgs(groups[2].Value);
                        string path          = OptimizePath(groups[4].Value);
                        string lineNumberStr = groups[5].Value;
                        int    lineNumber    = CStringUtils.ParseInt(lineNumberStr, -1);

                        if (!string.IsNullOrEmpty(path) && lineNumber != -1)
                        {
                            line = CStringUtils.TryFormat("{0}({1}) (at {2}:{3})", method, args, path, lineNumberStr);
                        }
                        else
                        {
                            line = CStringUtils.TryFormat("{0}({1})", method, args);
                        }

                        list.Add(new CStackTraceLine(line, path, lineNumber, lineNumberStr.Length));
                    }
                    else
                    {
                        list.Add(new CStackTraceLine(line));
                    }
                }

                return(list.ToArray());
            }

            return(CStackTraceLine.kEmptyLinesArray);
        }
예제 #2
0
        public static bool TryParseCompilerMessage(string line, out CSourcePathEntry entry)
        {
            if (line != null)
            {
                Match m = PatternCompilerMessageSourcePath.Match(line);
                if (m.Success)
                {
                    string path       = m.Groups[1].Value;
                    int    lineNumber = CStringUtils.ParseInt(m.Groups[2].Value, -1);
                    entry = new CSourcePathEntry(path, lineNumber);
                    return(true);
                }
            }

            entry = CSourcePathEntry.Invalid;
            return(false);
        }