From 401496a90cfb05ae84b83a5d9b10e6fb61875290 Mon Sep 17 00:00:00 2001 From: Virgile Bello Date: Mon, 25 Feb 2019 12:49:50 +0900 Subject: [PATCH] [CrashReport] Bumped crash report to 1.0.1 (force HTTPS), anonymize reports and make sure it doesn't conflict with NuGetAssemblyResolver --- .../editor/Xenko.GameStudio/CrashReportHelper.cs | 13 +++++++++++++ sources/editor/Xenko.GameStudio/Program.cs | 3 +++ .../editor/Xenko.GameStudio/Xenko.GameStudio.csproj | 2 +- .../launcher/Xenko.Launcher/Xenko.Launcher.csproj | 2 +- .../Xenko.NuGetResolver/NuGetAssemblyResolver.cs | 7 ++++++- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/sources/editor/Xenko.GameStudio/CrashReportHelper.cs b/sources/editor/Xenko.GameStudio/CrashReportHelper.cs index 88757ca9e9..b0ce4d45cb 100644 --- a/sources/editor/Xenko.GameStudio/CrashReportHelper.cs +++ b/sources/editor/Xenko.GameStudio/CrashReportHelper.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Reflection; using System.Text; +using System.Text.RegularExpressions; using Xenko.Core.Assets.Editor.Components.Transactions; #if DEBUG using System.Diagnostics; @@ -171,6 +172,18 @@ public static void SendReport(string exceptionMessage, int crashLocation, string crashReport["Log"] = nonFatalReport.ToString(); + // Try to anonymize reports + // It also makes it easier to copy and paste paths + for (var i = 0; i < crashReport.Data.Count; i++) + { + var data = crashReport.Data[i].Item2; + + data = Regex.Replace(data, Regex.Escape(Environment.GetEnvironmentVariable("USERPROFILE")), Regex.Escape("%USERPROFILE%"), RegexOptions.IgnoreCase); + data = Regex.Replace(data, $@"\b{Regex.Escape(Environment.GetEnvironmentVariable("USERNAME"))}\b", Regex.Escape("%USERNAME%"), RegexOptions.IgnoreCase); + + crashReport.Data[i] = Tuple.Create(crashReport.Data[i].Item1, data); + } + var reporter = new CrashReportForm(crashReport, new ReportSettings()); var result = reporter.ShowDialog(); XenkoGameStudio.MetricsClient?.CrashedSession(result == DialogResult.Yes); diff --git a/sources/editor/Xenko.GameStudio/Program.cs b/sources/editor/Xenko.GameStudio/Program.cs index 4c636196c2..cb77779f2e 100644 --- a/sources/editor/Xenko.GameStudio/Program.cs +++ b/sources/editor/Xenko.GameStudio/Program.cs @@ -209,6 +209,9 @@ private static void HandleException(Exception exception, int location) if (terminating) return; terminating = true; + // In case assembly resolve was not done yet, disable it altogether + NuGetAssemblyResolver.DisableAssemblyResolve(); + var englishCulture = new CultureInfo("en-US"); var crashLogThread = new Thread(CrashReport) { CurrentUICulture = englishCulture, CurrentCulture = englishCulture }; crashLogThread.SetApartmentState(ApartmentState.STA); diff --git a/sources/editor/Xenko.GameStudio/Xenko.GameStudio.csproj b/sources/editor/Xenko.GameStudio/Xenko.GameStudio.csproj index 80172979b8..9a1725eb72 100644 --- a/sources/editor/Xenko.GameStudio/Xenko.GameStudio.csproj +++ b/sources/editor/Xenko.GameStudio/Xenko.GameStudio.csproj @@ -43,7 +43,7 @@ - + False $(XenkoCommonDependenciesDir)Mono.Cecil\Mono.Cecil.dll diff --git a/sources/launcher/Xenko.Launcher/Xenko.Launcher.csproj b/sources/launcher/Xenko.Launcher/Xenko.Launcher.csproj index a1792f1521..0af2fcdcc4 100644 --- a/sources/launcher/Xenko.Launcher/Xenko.Launcher.csproj +++ b/sources/launcher/Xenko.Launcher/Xenko.Launcher.csproj @@ -52,7 +52,7 @@ - + diff --git a/sources/shared/Xenko.NuGetResolver/NuGetAssemblyResolver.cs b/sources/shared/Xenko.NuGetResolver/NuGetAssemblyResolver.cs index 84b8249073..666798ce56 100644 --- a/sources/shared/Xenko.NuGetResolver/NuGetAssemblyResolver.cs +++ b/sources/shared/Xenko.NuGetResolver/NuGetAssemblyResolver.cs @@ -19,7 +19,7 @@ using NuGet.Protocol.Core.Types; using NuGet.Versioning; -namespace Xenko.Core.Assets.CompilerApp +namespace Xenko.Core.Assets { class NuGetAssemblyResolver { @@ -27,6 +27,11 @@ class NuGetAssemblyResolver static object assembliesLock = new object(); static List assemblies; + internal static void DisableAssemblyResolve() + { + assembliesResolved = true; + } + [ModuleInitializer(-100000)] internal static void __Initialize__() {