From db7ac422796c482af89d759a4b19d8ecf482a74b Mon Sep 17 00:00:00 2001 From: axodox Date: Fri, 24 Mar 2017 22:14:53 +0100 Subject: [PATCH] Added PDBs to VSIX and support for localized crash stack traces --- AxoCover/AxoCover.csproj | 8 +++++++- AxoCover/Models/Data/StackItem.cs | 13 +++++++++++-- AxoCover/Models/HockeyClient.cs | 20 ++++++++------------ AxoCover/source.extension.vsixmanifest | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/AxoCover/AxoCover.csproj b/AxoCover/AxoCover.csproj index ff5288a..340e3fc 100644 --- a/AxoCover/AxoCover.csproj +++ b/AxoCover/AxoCover.csproj @@ -31,6 +31,7 @@ True Key.snk v4.5 + true Program @@ -567,22 +568,27 @@ {2ca98ecf-c250-4524-ad43-749b59e60bc1} AxoCover.Common + BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;GetCopyToOutputDirectoryItems;DebugSymbolsProjectOutputGroup {de90f6ef-57c2-4963-8639-505f29a3dbbe} AxoCover.Dependencies + BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;GetCopyToOutputDirectoryItems;DebugSymbolsProjectOutputGroup - {30a4d1cc-28c2-4822-b76a-5131ddd3666e} + {30a4d1cc-28c2-4822-b76a-5131ddd3666e} AxoCover.Host-x64 + BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;GetCopyToOutputDirectoryItems;DebugSymbolsProjectOutputGroup {960e90f5-8a08-4dfa-b268-32bc5fc9f336} AxoCover.Host-x86 + BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;GetCopyToOutputDirectoryItems;DebugSymbolsProjectOutputGroup {a2fb0e18-82e7-4907-86a3-5add9bda3341} AxoCover.Runner + BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;GetCopyToOutputDirectoryItems;DebugSymbolsProjectOutputGroup diff --git a/AxoCover/Models/Data/StackItem.cs b/AxoCover/Models/Data/StackItem.cs index 31e578d..8b22e11 100644 --- a/AxoCover/Models/Data/StackItem.cs +++ b/AxoCover/Models/Data/StackItem.cs @@ -7,7 +7,7 @@ namespace AxoCover.Models.Data { public class StackItem { - private const string _methodPattern = @"[\w\.<>`\[\],]+\([^\)]*\)"; + private const string _methodPattern = @"(?[\w\.<>`\[\],]+)\((?[^\)]*)\)"; private static readonly Regex _methodRegex = new Regex(_methodPattern, RegexOptions.Compiled); private const string _filePathPattern = @"(?:[a-zA-Z]:|\\)(?:\\[^<>:""\/\\|\?\*]*)+\.\w+"; @@ -28,7 +28,12 @@ public static StackItem[] FromStackTrace(string stackTrace) var methodMatch = _methodRegex.Match(line); if (!methodMatch.Success) continue; - var item = new StackItem() { Method = methodMatch.Value }; + var item = new StackItem() + { + Method = methodMatch.Value, + MethodName = methodMatch.Groups["name"].Value, + MethodArguments = methodMatch.Groups["arguments"].Value + }; var filePathMatch = _filePathRegex.Match(line); if (filePathMatch.Success) @@ -49,6 +54,10 @@ public static StackItem[] FromStackTrace(string stackTrace) public string Method { get; set; } + public string MethodName { get; set; } + + public string MethodArguments { get; set; } + public string SourceFile { get; set; } public int Line { get; set; } diff --git a/AxoCover/Models/HockeyClient.cs b/AxoCover/Models/HockeyClient.cs index eaca53c..bfb3e1a 100644 --- a/AxoCover/Models/HockeyClient.cs +++ b/AxoCover/Models/HockeyClient.cs @@ -1,10 +1,10 @@ -using AxoCover.Models.Extensions; +using AxoCover.Models.Data; +using AxoCover.Models.Extensions; using System; using System.Diagnostics; using System.IO; using System.Net; using System.Net.Http; -using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Web; @@ -30,8 +30,6 @@ public class HockeyClient : TelemetryManager, IDisposable private readonly string _uriPrefix; - private readonly Regex _stackRegex; - public HockeyClient(IEditorContext editorContext, IOptions options) : base(editorContext, options) { @@ -53,8 +51,6 @@ public HockeyClient(IEditorContext editorContext, IOptions options) _uriPrefix = $"https://rink.hockeyapp.net/api/2/apps/{AppId}/"; _httpClient.BaseAddress = new Uri(_uriPrefix); - - _stackRegex = new Regex(@" *at (?[^(]*)\([^\)]*\)( in (?.*):line (?\d+))?"); } public override async Task UploadExceptionAsync(Exception exception) @@ -93,16 +89,16 @@ public override async Task UploadExceptionAsync(Exception exception) writer.WriteLine(exception.GetType().FullName + ": " + exception.Message); var stackTrace = exception.StackTrace ?? new StackTrace().ToString(); - var stackFrames = _stackRegex.Matches(stackTrace); + var stackFrames = StackItem.FromStackTrace(stackTrace); - if (stackFrames.Count > 0) + if (stackFrames.Length > 0) { - foreach (Match match in stackFrames) + foreach (var stackItem in stackFrames) { - writer.Write($" at {match.Groups["methodName"].Value}"); - if (match.Groups["filePath"].Success && match.Groups["line"].Success) + writer.Write($" at {stackItem.MethodName}"); + if (stackItem.SourceFile != null) { - writer.WriteLine($"({ Path.GetFileName(match.Groups["filePath"].Value)}:{ match.Groups["line"].Value})"); + writer.WriteLine($"({Path.GetFileName(stackItem.SourceFile)}:{stackItem.Line})"); } else { diff --git a/AxoCover/source.extension.vsixmanifest b/AxoCover/source.extension.vsixmanifest index 2108f34..79f5557 100644 --- a/AxoCover/source.extension.vsixmanifest +++ b/AxoCover/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + AxoCover Nice and free .Net code coverage support for Visual Studio with OpenCover. https://marketplace.visualstudio.com/items?itemName=axodox1.AxoCover