Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DYN-3343] Automatically add loaded packages as crash detail #11500

Merged
merged 59 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1319780
Merge pull request #1 from DynamoDS/master
Astul-Betizagasti Jul 6, 2020
c78dfe9
Removal of unused code
Astul-Betizagasti Jul 7, 2020
e446a29
Merge pull request #2 from DynamoDS/master
Astul-Betizagasti Jul 7, 2020
a361a67
Merge branch 'master' into Graph-Workspaces-Coverage
Astul-Betizagasti Jul 7, 2020
f4d5c44
Revert "Removal of unused code"
Astul-Betizagasti Jul 7, 2020
1b91432
Added Obsolete Tag
Astul-Betizagasti Jul 7, 2020
4944efb
Message change
Astul-Betizagasti Jul 7, 2020
edf927d
Tests1
Astul-Betizagasti Jul 9, 2020
efee990
Merge pull request #3 from DynamoDS/master
Astul-Betizagasti Jul 9, 2020
948b39f
Merge pull request #4 from Astul-Betizagasti/master
Astul-Betizagasti Jul 9, 2020
ea4dce4
Merge pull request #5 from DynamoDS/master
Astul-Betizagasti Jul 10, 2020
a8b38cc
Tests changes
Astul-Betizagasti Jul 10, 2020
ec787fa
Merge pull request #7 from DynamoDS/master
Astul-Betizagasti Jul 10, 2020
7f1c3a5
WorkspaceModel Tests
Astul-Betizagasti Jul 17, 2020
a0461d6
Merge pull request #9 from DynamoDS/master
Astul-Betizagasti Jul 17, 2020
d2ebf09
Merge branch 'Graph-Workspaces-Coverage' into master
Astul-Betizagasti Jul 17, 2020
d96a729
Merge branch 'pr/11'
Astul-Betizagasti Jul 27, 2020
b0f8162
Fix merge issue
Astul-Betizagasti Jul 27, 2020
714fe11
Merge pull request #17 from DynamoDS/master
Astul-Betizagasti Aug 28, 2020
3a126b5
Merge pull request #22 from DynamoDS/master
Astul-Betizagasti Oct 5, 2020
02eda71
Merge pull request #23 from DynamoDS/master
Astul-Betizagasti Oct 15, 2020
391876c
Merge pull request #25 from DynamoDS/master
Astul-Betizagasti Oct 29, 2020
a5efddc
Merge pull request #26 from DynamoDS/master
Astul-Betizagasti Nov 20, 2020
074953f
GitHub Action For Issue Content
Astul-Betizagasti Nov 20, 2020
de03f79
Refactor
Astul-Betizagasti Nov 20, 2020
b6e27c2
Update checkIssueInfo.yaml
Astul-Betizagasti Nov 23, 2020
fb440d5
Merge pull request #27 from DynamoDS/master
Astul-Betizagasti Nov 26, 2020
053995d
Add github action
Astul-Betizagasti Nov 26, 2020
052efea
Template/Issue parser and comparator improvements
Astul-Betizagasti Nov 26, 2020
8b71a46
Merge pull request #28 from DynamoDS/master
Astul-Betizagasti Dec 4, 2020
b58c205
Merge pull request #29 from DynamoDS/master
Astul-Betizagasti Dec 8, 2020
631462e
Update infromation analyzer
Astul-Betizagasti Dec 8, 2020
90b5e82
Merge branch 'CheckIssueContent' into master
Astul-Betizagasti Dec 8, 2020
ff0d9c9
Merge pull request #31 from DynamoDS/master
Astul-Betizagasti Dec 11, 2020
ae28659
Delete checkIssueInfo.yaml
Astul-Betizagasti Jan 7, 2021
66233a8
Merge pull request #33 from DynamoDS/master
Astul-Betizagasti Jan 7, 2021
c1e51ec
Merge pull request #35 from DynamoDS/master
Astul-Betizagasti Jan 12, 2021
3f5e4a6
Merge pull request #36 from DynamoDS/master
Astul-Betizagasti Jan 20, 2021
21457f9
Merge pull request #37 from DynamoDS/master
Astul-Betizagasti Jan 21, 2021
3588f40
Merge pull request #38 from DynamoDS/master
Astul-Betizagasti Jan 25, 2021
d6a4d8b
Merge pull request #40 from DynamoDS/master
Astul-Betizagasti Jan 29, 2021
8a60f0e
Fake Crash on canvas click
QilongTang Feb 2, 2021
2daeaa7
Merge pull request #42 from DynamoDS/master
Astul-Betizagasti Feb 3, 2021
942158f
Merge branch 'master' into FakeCrash
QilongTang Feb 5, 2021
cbced46
Merge pull request #44 from DynamoDS/master
Astul-Betizagasti Feb 5, 2021
3b9e275
Merge pull request #45 from DynamoDS/FakeCrash
Astul-Betizagasti Feb 12, 2021
839f05f
Include loaded packages in crash report
Astul-Betizagasti Feb 12, 2021
0da6573
revert fake crush
Astul-Betizagasti Feb 12, 2021
2cc79e0
Reference fix
Astul-Betizagasti Feb 12, 2021
7298926
Changes
Astul-Betizagasti Feb 19, 2021
f31b2d1
Removed unused reference
Astul-Betizagasti Feb 19, 2021
5d73798
Update CrashUtilities.cs
Astul-Betizagasti Feb 19, 2021
78bbea2
remove redundant line on issue description
Astul-Betizagasti Feb 19, 2021
c06405e
format change
Astul-Betizagasti Feb 19, 2021
ca69f53
Update CrashPrompt.xaml.cs
Astul-Betizagasti Feb 19, 2021
a1cfbd2
refactor and fixes
Astul-Betizagasti Feb 19, 2021
2e663eb
spelling
Astul-Betizagasti Feb 20, 2021
aaa2229
added packages versions
Astul-Betizagasti Feb 22, 2021
8de2a98
Tests
Astul-Betizagasti Feb 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/DynamoCoreWpf/UI/Prompts/CrashPrompt.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Markup;
using System.Xml;
using Dynamo.Core;
using Dynamo.PackageManager;
using Dynamo.ViewModels;

namespace Dynamo.Nodes.Prompts
Expand All @@ -18,17 +22,18 @@ public partial class CrashPrompt : Window
private string details; // Store here for clipboard copy
private string folderPath;
private string productName;
private string markdownPackages;

public CrashPrompt(string details, DynamoViewModel dynamoViewModel)
{
InitializeComponent();
this.CrashDetailsContent.Text = details;

productName = dynamoViewModel.BrandingResourceProvider.ProductName;
Title = string.Format(Wpf.Properties.Resources.CrashPromptDialogTitle,productName);
Title = string.Format(Wpf.Properties.Resources.CrashPromptDialogTitle, productName);
txtOverridingText.Text = string.Format(Wpf.Properties.Resources.CrashPromptDialogCrashMessage, productName);
}

public CrashPrompt(DynamoViewModel dynamoViewModel)
{
InitializeComponent();
Expand All @@ -42,6 +47,9 @@ public CrashPrompt(CrashPromptArgs args, DynamoViewModel dynamoViewModel)
{
InitializeComponent();

var packageLoader = dynamoViewModel.Model.GetPackageManagerExtension()?.PackageLoader;
markdownPackages = Wpf.Utilities.CrashUtilities.PackagesToMakrdown(packageLoader);

productName = dynamoViewModel.BrandingResourceProvider.ProductName;
Title = string.Format(Wpf.Properties.Resources.CrashPromptDialogTitle, productName);
txtOverridingText.Text = string.Format(Wpf.Properties.Resources.CrashPromptDialogCrashMessage, productName);
Expand Down Expand Up @@ -92,7 +100,7 @@ private void Continue_Click(object sender, RoutedEventArgs e)

private void PostOnGithub_Click(object sender, RoutedEventArgs e)
{
DynamoViewModel.ReportABug(this.CrashDetailsContent.Text);
DynamoViewModel.ReportABug(markdownPackages);
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
}

private void Details_Click(object sender, RoutedEventArgs e)
Expand Down
46 changes: 41 additions & 5 deletions src/DynamoCoreWpf/Utilities/CrashUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Dynamo.Configuration;
using Dynamo.PackageManager;
using Dynamo.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Dynamo.Wpf.Utilities
{
Expand All @@ -26,28 +29,61 @@ internal static string GithubNewIssueUrlFromCrashContent(object crashContent)
return baseUri.ToString();
}

/// <summary>
/// Converts packages information into markdown format for use in Github issue body
/// </summary>
/// <param name="packageLoader">Package loader</param>
/// <returns>A markdown format string to use in issue body.</returns>
internal static string PackagesToMakrdown(PackageLoader packageLoader)
{
if (packageLoader != null)
{
//List of the names of all the loaded packages
var packagesNames = packageLoader.LocalPackages.Select(o => o.Name + " " + o.VersionName).ToList();
//Package's issue section in markdown format
string markdownText;
if (packagesNames.Any())
{
markdownText = "### Loaded Packages" + Environment.NewLine;
foreach (var name in packagesNames)
{
markdownText += "- " + name + Environment.NewLine;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also do you think we can easily get package versions as well? @Astul-Betizagasti

}
}
else
{
markdownText = "No loaded packages were found.";
Copy link
Contributor

@QilongTang QilongTang Feb 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I thought about if we need to convert these into resource strings but think it may help the customer but not us. What do you guys think @DynamoDS/dynamo

}
return markdownText;
}
else
{
return "(Fill in here)";
}
}

/// <summary>
/// Formats crash details and adds metadata for use in Github issue body
/// </summary>
/// <param name="details">Crash details, such as a stack trace.</param>
/// <returns>A formatted, but not escaped, string to use as issue body.</returns>
private static string GitHubCrashReportBody(object details)
{
var stackTrace = details?.ToString() ?? string.Empty;
var markdownPackages = details?.ToString() ?? string.Empty;

// This functionality was not available prior to version 2.1.0, so it should be the fallback value
var dynamoVersion = AssemblyHelper.GetDynamoVersion().ToString() ?? "2.1.0+";

return BuildMarkdownContent(dynamoVersion, stackTrace);
return BuildMarkdownContent(dynamoVersion, markdownPackages);
}

/// <summary>
/// Builds a Markdown string that will be posted to our new GitHub issue
/// </summary>
/// <param name="dynamoVersion">Dynamo version that should be recorded in the issue report</param>
/// <param name="stackTrace">The crash stack trace to be included in the issue report</param>
/// <param name="markdownPackages">Section of the issue with the loaded packages in markdown format</param>
/// <returns></returns>
internal static string BuildMarkdownContent(string dynamoVersion, string stackTrace)
internal static string BuildMarkdownContent(string dynamoVersion, string markdownPackages)
{
return
"# Issue Description" + Environment.NewLine +
Expand All @@ -70,7 +106,7 @@ internal static string BuildMarkdownContent(string dynamoVersion, string stackTr
"(Fill in here)" + Environment.NewLine + Environment.NewLine +

"## What packages or external references (if any) were used?" + Environment.NewLine +
"(Fill in here)" + Environment.NewLine + Environment.NewLine + Environment.NewLine +
markdownPackages + Environment.NewLine + Environment.NewLine +

"## Stack Trace" + Environment.NewLine +
"```" + Environment.NewLine +
Expand Down
9 changes: 7 additions & 2 deletions test/DynamoCoreWpfTests/CrashReportingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at DynamoSandbox.DynamoCoreSetup.RunApplication(Application app)";

// This are example packages names used to simulate loaded packages information
private string Packages = @"
- Package Example A
- Package Example B";

[Test]
[Ignore("Test ignored because the web browser is not closed after the test execution")]
public void CanReportBugWithNoContent()
Expand All @@ -66,7 +71,7 @@ public void CanReportBugWithContent()
var dynamoVersion = "2.1.0";

// Create a crash report to submit
var crashReport = Wpf.Utilities.CrashUtilities.BuildMarkdownContent(dynamoVersion, StackTrace);
var crashReport = Wpf.Utilities.CrashUtilities.BuildMarkdownContent(dynamoVersion, Packages);
Assert.IsNotNullOrEmpty(crashReport);

// Report a bug with a stack trace
Expand All @@ -80,7 +85,7 @@ public void StackTraceIncludedInReport()
var dynamoVersion = AssemblyHelper.GetDynamoVersion().ToString();

// Create a crash report to submit
var crashReport = Wpf.Utilities.CrashUtilities.BuildMarkdownContent(dynamoVersion, StackTrace);
var crashReport = Wpf.Utilities.CrashUtilities.BuildMarkdownContent(dynamoVersion, Packages);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assert below that decoded contains package info. And also make a new test that covers the default state of the API

Copy link
Contributor Author

@Astul-Betizagasti Astul-Betizagasti Feb 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the change suggested on the test, but can you expand on the other test you mentioned? The API should work the same as before the changes with the exception of it including more information (which is being checked on that test you linked with the changes you suggested). Are you referring to the method PackagesToMakrdown(PackageLoader packageLoader) in CrashUtilities.cs?

Copy link
Contributor

@QilongTang QilongTang Feb 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. I would like a test covering the default state so we can assert the API defaults to No loaded packages were found.

Assert.IsNotNullOrEmpty(crashReport);

// Mock url for request
Expand Down