Skip to content

Commit

Permalink
fix: Migrate NBug bug report
Browse files Browse the repository at this point in the history
Migrate NBug bug report form into the main project from subproject.

The NBug project was introduced into the project to automate capturing
exception information. However the project is stale and it wasn't
integrated with GitHub, so we have adapted the project specifically for
the Git Extensions project (e.g. gitextensions#6446, gitextensions#6455).

However further changes were necessary (i.e. to address gitextensions#6607), the NBug
project contain too many unnecessary functionality, there was no i8n set
for the project.

Bringing only necessary functionality into Git Extensions addresses the
above issues.
  • Loading branch information
RussKie committed Jun 15, 2019
1 parent d86089e commit 4c38f64
Show file tree
Hide file tree
Showing 24 changed files with 2,065 additions and 33 deletions.
4 changes: 0 additions & 4 deletions GitExtensions/GitExtensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@
<None Include="app.manifest" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Externals\NBug\NBug\NBug.csproj">
<Project>{62CED1D5-F603-40DE-8BF5-3E49D3A392F4}</Project>
<Name>NBug</Name>
</ProjectReference>
<ProjectReference Include="..\GitExtUtils\GitExtUtils.csproj">
<Project>{0f1f1168-a4b2-4fa2-b17b-735140d17f39}</Project>
<Name>GitExtUtils</Name>
Expand Down
39 changes: 19 additions & 20 deletions GitExtensions/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,10 @@ private static void Main()

try
{
NBug.Settings.UIMode = NBug.Enums.UIMode.Full;

// Uncomment the following after testing to see that NBug is working as configured
NBug.Settings.ReleaseMode = true;
NBug.Settings.ExitApplicationImmediately = false;
NBug.Settings.WriteLogToDisk = false;
NBug.Settings.MaxQueuedReports = 10;
NBug.Settings.StopReportingAfter = 90;
NBug.Settings.SleepBeforeSend = 30;
NBug.Settings.StoragePath = NBug.Enums.StoragePath.WindowsTemp;
NBug.Settings.GetSystemInfo = () =>
{
// if the error happens before we had a chance to init the environment information
// the call to GetInformation() will fail. A double Initialise() call is safe.
UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);
return UserEnvironmentInformation.GetInformation();
};

if (!Debugger.IsAttached)
{
AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;
Application.ThreadException += NBug.Handler.ThreadException;
AppDomain.CurrentDomain.UnhandledException += (s, e) => ReportBug((Exception)e.ExceptionObject);
Application.ThreadException += (s, e) => ReportBug(e.Exception);
}
}
catch (TypeInitializationException tie)
Expand Down Expand Up @@ -326,5 +308,22 @@ private static bool LocateMissingGit()
}
}
}

private static void ReportBug(Exception ex)
{
// if the error happens before we had a chance to init the environment information
// the call to GetInformation() will fail. A double Initialise() call is safe.
UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);
var envInfo = UserEnvironmentInformation.GetInformation();

using (var form = new GitUI.NBugReports.BugReportForm())
{
var result = form.ShowDialog(ex, envInfo);
if (result == DialogResult.Abort)
{
Environment.Exit(-1);
}
}
}
}
}
40 changes: 40 additions & 0 deletions GitUI/GitUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<Reference Include="System.ServiceModel" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft-WindowsAPICodePack-Core">
Expand Down Expand Up @@ -328,6 +329,33 @@
<Compile Include="Editor\GitHighlightingStrategyBase.cs" />
<Compile Include="Editor\RebaseTodoHighlightingStrategy.cs" />
<Compile Include="FindFilePredicateProvider.cs" />
<Compile Include="NBugReports\BugReportForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="NBugReports\BugReportForm.Designer.cs">
<DependentUpon>BugReportForm.cs</DependentUpon>
</Compile>
<Compile Include="NBugReports\ErrorReportMarkDownBodyBuilder.cs" />
<Compile Include="NBugReports\ExceptionDetails.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="NBugReports\ExceptionDetails.Designer.cs">
<DependentUpon>ExceptionDetails.cs</DependentUpon>
</Compile>
<Compile Include="NBugReports\ExceptionDetailView.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="NBugReports\ExceptionDetailView.Designer.cs">
<DependentUpon>ExceptionDetailView.cs</DependentUpon>
</Compile>
<Compile Include="NBugReports\GitHubUrlBuilder.cs" />
<Compile Include="NBugReports\Info\AssemblyInfo.cs" />
<Compile Include="NBugReports\Info\ConfigurationInfo.cs" />
<Compile Include="NBugReports\Info\GeneralInfo.cs" />
<Compile Include="NBugReports\Info\Report.cs" />
<Compile Include="NBugReports\Info\SystemInfo.cs" />
<Compile Include="NBugReports\Serialization\SerializableDictionary.cs" />
<Compile Include="NBugReports\Serialization\SerializableException.cs" />
<Compile Include="Properties\Images.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down Expand Up @@ -1294,6 +1322,9 @@
<EmbeddedResource Include="CommitInfo\CommitInfoHeader.resx">
<DependentUpon>CommitInfoHeader.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="NBugReports\BugReportForm.resx">
<DependentUpon>BugReportForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="HelperDialogs\FormBuildServerCredentials.resx">
<DependentUpon>FormBuildServerCredentials.cs</DependentUpon>
<SubType>Designer</SubType>
Expand All @@ -1310,6 +1341,12 @@
<EmbeddedResource Include="CommandsDialogs\SettingsDialog\Plugins\PluginRootIntroductionPage.resx">
<DependentUpon>PluginRootIntroductionPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="NBugReports\ExceptionDetails.resx">
<DependentUpon>ExceptionDetails.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="NBugReports\ExceptionDetailView.resx">
<DependentUpon>ExceptionDetailView.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
Expand Down Expand Up @@ -1819,6 +1856,9 @@
<ItemGroup>
<None Include="Resources\Icons\branch_inv.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\bug.png" />
</ItemGroup>
<Target Name="CopyTranslations" AfterTargets="AfterBuild">
<ItemGroup>
<Translations Include="$(ProjectDir)Translation\*.xlf;$(ProjectDir)Translation\*.gif" />
Expand Down
Loading

0 comments on commit 4c38f64

Please sign in to comment.