Exemplo n.º 1
0
        public static void Apply(ref string stacktrace)
        {
            try
            {
                var str         = "";
                var lines       = stacktrace.Split('\n');
                var settings    = DemystifySettings.instance;
                var foundPrefix = false;
                foreach (var t in lines)
                {
                    var line = t;

                    if (StacktraceMarkerUtil.IsPrefix(line))
                    {
                        StacktraceMarkerUtil.RemoveMarkers(ref line);
                        if (!string.IsNullOrEmpty(settings.Separator))
                        {
                            str += settings.Separator + "\n";
                        }
                        foundPrefix = true;
                    }

                    if (foundPrefix && settings.UseSyntaxHighlighting)
                    {
                        SyntaxHighlighting.AddSyntaxHighlighting(ref line);
                    }

                    str += line.Trim();

                    if (!str.EndsWith("\n"))
                    {
                        str += "\n";
                    }
                }

                if (!string.IsNullOrWhiteSpace(str))
                {
                    stacktrace = str;
                }
            }
            catch
            // (Exception e)
            {
                // ignore
            }
        }
Exemplo n.º 2
0
        public static void Apply(ref string stacktrace)
        {
            try
            {
                using (new ProfilerMarker("Demystify.Apply").Auto())
                {
                    string[] lines = null;
                    using (new ProfilerMarker("Split Lines").Auto())
                        lines = stacktrace.Split('\n');
                    var settings    = DemystifySettings.instance;
                    var foundPrefix = false;
                    foreach (var t in lines)
                    {
                        var line = t;

                        using (new ProfilerMarker("Remove Markers").Auto())
                        {
                            if (StacktraceMarkerUtil.IsPrefix(line))
                            {
                                StacktraceMarkerUtil.RemoveMarkers(ref line);
                                if (!string.IsNullOrEmpty(settings.Separator))
                                {
                                    builder.AppendLine(settings.Separator);
                                }
                                foundPrefix = true;
                            }
                        }

                        if (foundPrefix && settings.UseSyntaxHighlighting)
                        {
                            SyntaxHighlighting.AddSyntaxHighlighting(ref line);
                        }

                        var l = line.Trim();
                        if (!string.IsNullOrEmpty(l))
                        {
                            if (!l.EndsWith("\n"))
                            {
                                builder.AppendLine(l);
                            }
                            else
                            {
                                builder.Append(l);
                            }
                        }
                    }

                    var res = builder.ToString();
                    if (!string.IsNullOrWhiteSpace(res))
                    {
                        stacktrace = res;
                    }
                    builder.Clear();
                }
            }
            catch
            // (Exception e)
            {
                // ignore
            }
        }