Как получить uwp. NET Количество строк в собственном stackTrace? - PullRequest
0 голосов
/ 17 июня 2020

В Центре приложений Micrososft, если вы отслеживаете ошибку, он может отображать номер строки stacktrace, если вы загружаете символ своего uwp-приложения (pdb из bin \ x86 \ il c в zip или appxsym). Я вижу в Nuget App Center SDK для платформ. NET, они отправляют некоторую информацию, чтобы найти номер строки в pdb:

private static ModelException ProcessException(System.Exception exception, ModelException outerException, Dictionary<long, ModelBinary> seenBinaries)
    {
        var modelException = new ModelException
        {
            Type = exception.GetType().ToString(),
            Message = exception.Message,
            StackTrace = exception.StackTrace
        };
        if (exception is AggregateException aggregateException)
        {
            if (aggregateException.InnerExceptions.Count != 0)
            {
                modelException.InnerExceptions = new List<ModelException>();
                foreach (var innerException in aggregateException.InnerExceptions)
                {
                    ProcessException(innerException, modelException, seenBinaries);
                }
            }
        }
        if (exception.InnerException != null)
        {
            modelException.InnerExceptions = modelException.InnerExceptions ?? new List<ModelException>();
            ProcessException(exception.InnerException, modelException, seenBinaries);
        }
        var stackTrace = new StackTrace(exception, true);
        var frames = stackTrace.GetFrames();

        // If there are native frames available, process them to extract image information and frame addresses.
        // The check looks odd, but there is a possibility of frames being null or empty both.
        if (frames != null && frames.Length > 0 && frames[0].HasNativeImage())
        {
            foreach (var frame in frames)
            {
                // Get stack frame address.
                var crashFrame = new ModelStackFrame
                {
                    Address = string.Format(CultureInfo.InvariantCulture, AddressFormat, frame.GetNativeIP().ToInt64()),
                };
                if (modelException.Frames == null)
                {
                    modelException.Frames = new List<ModelStackFrame>();
                }
                modelException.Frames.Add(crashFrame);

                // Process binary.
                var nativeImageBase = frame.GetNativeImageBase().ToInt64();
                if (seenBinaries.ContainsKey(nativeImageBase) || nativeImageBase == 0)
                {
                    continue;
                }
                var binary = ImageToBinary(frame.GetNativeImageBase());
                if (binary != null)
                {
                    seenBinaries[nativeImageBase] = binary;
                }
            }
        }
        outerException?.InnerExceptions.Add(modelException);
        return modelException;
    }

Кто-то знает, как они используют эту информацию для получения строки stacktrace номер?

...