Skip to content

Commit

Permalink
[CrashReport] Bumped crash report to 1.0.1 (force HTTPS), anonymize r…
Browse files Browse the repository at this point in the history
…eports and make sure it doesn't conflict with NuGetAssemblyResolver
  • Loading branch information
xen2 committed Feb 25, 2019
1 parent 0e9c28f commit 401496a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
13 changes: 13 additions & 0 deletions sources/editor/Xenko.GameStudio/CrashReportHelper.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions sources/editor/Xenko.GameStudio/Program.cs
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion sources/editor/Xenko.GameStudio/Xenko.GameStudio.csproj
Expand Up @@ -43,7 +43,7 @@
<PackageReference Include="SharpDX" Version="4.0.1" />
<PackageReference Include="EnvDTE" Version="8.0.1" />
<PackageReference Include="Xenko.Metrics" Version="1.0.0" />
<PackageReference Include="Xenko.CrashReport" Version="1.0.0" />
<PackageReference Include="Xenko.CrashReport" Version="1.0.1" />
<Reference Include="Mono.Cecil">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(XenkoCommonDependenciesDir)Mono.Cecil\Mono.Cecil.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion sources/launcher/Xenko.Launcher/Xenko.Launcher.csproj
Expand Up @@ -52,7 +52,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xenko.Metrics" Version="1.0.0" />
<PackageReference Include="Xenko.CrashReport" Version="1.0.0" />
<PackageReference Include="Xenko.CrashReport" Version="1.0.1" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Management" />
Expand Down
7 changes: 6 additions & 1 deletion sources/shared/Xenko.NuGetResolver/NuGetAssemblyResolver.cs
Expand Up @@ -19,14 +19,19 @@
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;

namespace Xenko.Core.Assets.CompilerApp
namespace Xenko.Core.Assets
{
class NuGetAssemblyResolver
{
static bool assembliesResolved;
static object assembliesLock = new object();
static List<string> assemblies;

internal static void DisableAssemblyResolve()
{
assembliesResolved = true;
}

[ModuleInitializer(-100000)]
internal static void __Initialize__()
{
Expand Down

0 comments on commit 401496a

Please sign in to comment.