Skip to content

Commit

Permalink
Merge pull request #419 from BUTR/dev
Browse files Browse the repository at this point in the history
v2.9.18
  • Loading branch information
Aragas authored Oct 7, 2024
2 parents f252321 + e3030a9 commit 36c5efe
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 50 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- 'src/**'
- 'tests/**'
- 'build/**'
workflow_dispatch:

env:
# Disable the .NET logo in the console output.
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
steam-depotid: '261551 261552'

- name: Test
timeout-minutes: 10
run: >-
$stable_version=$env:STABLE_VERSION;
$stable_version=$stable_version.substring(1);
Expand All @@ -68,6 +69,7 @@ jobs:
shell: pwsh

- name: Test Coverage
timeout-minutes: 10
run: >-
opencover/OpenCover.Console.exe -register -target:"dotnet.exe" -targetargs:"test tests/Bannerlord.ButterLib.Tests/Bannerlord.ButterLib.Tests.csproj --configuration Debug --no-build" -filter:"${{env.TEST_FILTERS}}" -excludebyattribute:"*.ExcludeFromCodeCoverage*" -output:coverage_butterlib_stable_debug.xml -mergebyhash;
opencover/OpenCover.Console.exe -register -target:"dotnet.exe" -targetargs:"test tests/Bannerlord.ButterLib.Tests/Bannerlord.ButterLib.Tests.csproj --configuration Release --no-build" -filter:"${{env.TEST_FILTERS}}" -excludebyattribute:"*.ExcludeFromCodeCoverage*" -output:coverage_butterlib_stable_release.xml -mergebyhash;
Expand Down
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<BaseGameVersion>1.0.0</BaseGameVersion>
<!--Module Version-->
<Version>2.9.17</Version>
<Version>2.9.18</Version>
<!--Harmony Version-->
<HarmonyVersion>2.2.2</HarmonyVersion>
<HarmonyExtensionsVersion>3.2.0.77</HarmonyExtensionsVersion>
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 2.9.18
Game Versions: v1.0.x,v1.1.x,v1.2.x
* Removed Crash Report duplicates being shown after closing
* BEW should not be involved anymore when Finalizer is used
---------------------------------------------------------------------------------------------------
Version: 2.9.17
Game Versions: v1.0.x,v1.1.x,v1.2.x
* Crash reports were not correctly identifying game assemblies, better path data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ internal static bool Disable(Harmony harmony)

private static readonly Patch[] Patches =
[
new PrefixPatch(nameof(AddBasicTypeDefinitionPrefix), TargetTypeMethod("AddBasicTypeDefinition")),
new PrefixPatch(nameof(AddClassDefinitionPrefix), TargetTypeMethod("AddClassDefinition")),
new PrefixPatch(nameof(AddContainerDefinitionPrefix), TargetTypeMethod("AddContainerDefinition")),
new PrefixPatch(nameof(AddEnumDefinitionPrefix), TargetTypeMethod("AddEnumDefinition")),
new PrefixPatch(nameof(AddGenericClassDefinitionPrefix), TargetTypeMethod("AddGenericClassDefinition")),
new PrefixPatch(nameof(AddBasicTypeDefinitionPrefix), TargetTypeMethod("AddBasicTypeDefinition")),
new PrefixPatch(nameof(AddClassDefinitionPrefix), TargetTypeMethod("AddClassDefinition")),
new PrefixPatch(nameof(AddContainerDefinitionPrefix), TargetTypeMethod("AddContainerDefinition")),
new PrefixPatch(nameof(AddEnumDefinitionPrefix), TargetTypeMethod("AddEnumDefinition")),
new PrefixPatch(nameof(AddGenericClassDefinitionPrefix), TargetTypeMethod("AddGenericClassDefinition")),
new PrefixPatch(nameof(AddGenericStructDefinitionPrefix), TargetTypeMethod("AddGenericStructDefinition")),
new PrefixPatch(nameof(AddInterfaceDefinitionPrefix), TargetTypeMethod("AddInterfaceDefinition")),
new PrefixPatch(nameof(AddRootClassDefinitionPrefix), TargetTypeMethod("AddRootClassDefinition")),
new PrefixPatch(nameof(AddStructDefinitionPrefix), TargetTypeMethod("AddStructDefinition")),
new PrefixPatch(nameof(AddInterfaceDefinitionPrefix), TargetTypeMethod("AddInterfaceDefinition")),
new PrefixPatch(nameof(AddRootClassDefinitionPrefix), TargetTypeMethod("AddRootClassDefinition")),
new PrefixPatch(nameof(AddStructDefinitionPrefix), TargetTypeMethod("AddStructDefinition")),
new ConstructContainerDefinitionPrefixPatch()
];

Expand Down
19 changes: 6 additions & 13 deletions src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ public static bool IsDebuggerAttached()
return _cachedDebuggerAttached;
}

internal record ExceptionIdentifier(Type Type, string? StackTrace, string Message)
{
public static ExceptionIdentifier FromException(Exception e) => new(e.GetType(), e.StackTrace, e.Message);
}

internal static readonly HashSet<ExceptionIdentifier> SuppressedExceptions = [];

private static readonly string[] BEW = ["org.calradia.admiralnelson.betterexceptionwindow"];


Expand All @@ -63,13 +56,13 @@ internal record ExceptionIdentifier(Type Type, string? StackTrace, string Messag

private static void Finalizer(Exception? __exception)
{
if (__exception is not null)
{
if (ExceptionHandlerSubSystem.Instance?.DisableWhenDebuggerIsAttached == true && IsDebuggerAttached())
return;
if (__exception is null)
return;

if (ExceptionHandlerSubSystem.Instance?.DisableWhenDebuggerIsAttached == true && IsDebuggerAttached())
return;

ExceptionReporter.Show(__exception);
}
ExceptionReporter.Show(__exception);
}

internal static void Enable(Harmony harmony)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
using HarmonyLib;
using HarmonyLib.BUTR.Extensions;

using JetBrains.Annotations;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Security;
using JetBrains.Annotations;

namespace Bannerlord.ButterLib.ExceptionHandler;

Expand Down
40 changes: 20 additions & 20 deletions src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ namespace Bannerlord.ButterLib.ExceptionHandler;
[BLSEExceptionHandler]
public static class ExceptionReporter
{
private const string ExceptionWasShownMarker = "ButterLibExceptionWasShown";

private static void OnException(Exception exception) => Show(exception);

public static void Show(Exception exception)
{
if (BEWPatch.SuppressedExceptions.Contains(BEWPatch.ExceptionIdentifier.FromException(exception)))
{
BEWPatch.SuppressedExceptions.Remove(BEWPatch.ExceptionIdentifier.FromException(exception));
if (exception.Data.Contains(ExceptionWasShownMarker) && exception.Data[ExceptionWasShownMarker] is true)
return;
}
exception.Data[ExceptionWasShownMarker] = true;

var metadata = new Dictionary<string, string>
{
Expand All @@ -53,29 +53,29 @@ public static void Show(Exception exception)
var harmonyProvider = new HarmonyProvider();
var crashReportRendererUtilities = new CrashReportRendererUtilities();

var crashReport = CrashReportInfo.Create(exception, metadata, filter, helper, helper, helper, harmonyProvider);
var crashReportModel = CrashReportInfo.ToModel(crashReport, helper, helper, helper, helper, helper, helper);
var logSources = GetLogSources().ToArray();
var crashReport = CrashReportInfo.Create(exception, metadata, filter, helper, helper, helper, harmonyProvider);
var crashReportModel = CrashReportInfo.ToModel(crashReport, helper, helper, helper, helper, helper, helper);
var logSources = GetLogSources().ToArray();
try
{
CrashReportImGui.ShowAndWait(crashReportModel, logSources, crashReportRendererUtilities);
}
catch (Exception ex)
{
try
{
CrashReportImGui.ShowAndWait(crashReportModel, logSources, crashReportRendererUtilities);
}
catch (Exception ex)
{
try
{
#if NET472 || (NET6_0 && WINDOWS)

var forms = new CrashReportWinForms(crashReportModel, logSources, crashReportRendererUtilities);
forms.ShowDialog();
var forms = new CrashReportWinForms(crashReportModel, logSources, crashReportRendererUtilities);
forms.ShowDialog();
#endif
}
catch (Exception ex2)
{
throw new AggregateException(ex, ex2);
}
}
catch (Exception ex2)
{
throw new AggregateException(ex, ex2);
}
}
}

private static IEnumerable<LogSource> GetLogSources()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BUTR.CrashReport.Models;
using BUTR.CrashReport.Models;
using BUTR.CrashReport.Renderer.Zip;

using Newtonsoft.Json;
Expand Down
8 changes: 4 additions & 4 deletions src/Bannerlord.ButterLib/ExceptionHandler/Utils/MiniDump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public enum MINIDUMP_CALLBACK_TYPE
ReadMemoryFailureCallback,
SecondaryFlagsCallback
}

public struct VS_FIXEDFILEINFO
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
Expand Down Expand Up @@ -194,7 +194,7 @@ public struct MINIDUMP_INCLUDE_MODULE_CALLBACK
public ulong BaseOfImage;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public struct MINIDUMP_IO_CALLBACK
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
Expand All @@ -204,7 +204,7 @@ public struct MINIDUMP_IO_CALLBACK
public uint BufferBytes;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public struct MINIDUMP_CALLBACK_INPUT
{
[StructLayout(LayoutKind.Explicit)]
Expand All @@ -225,7 +225,7 @@ public struct UNION
[FieldOffset(0)]
public MINIDUMP_IO_CALLBACK Io;
}

#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public uint ProcessId;
public IntPtr ProcessHandle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public IEnumerable<StacktraceEntry> Filter(ICollection<StacktraceEntry> stacktra
}
if (stacktraceEntry.ModuleInfo?.Id is "BetterExceptionWindow")
{
if (stacktraceEntry.Method is { Name: "Finalizer", DeclaringType: { Namespace: "AutoGeneratedExceptionFilter" } })
if (stacktraceEntry.Method is { Name: "Finalizer", DeclaringType: { Name: "AutoGeneratedExceptionFilter" } })
{
continue;
}
Expand Down Expand Up @@ -73,7 +73,7 @@ private IEnumerable<MethodEntry> FilterPatches(ICollection<MethodEntry> patches)
{
continue;
}
if (patch.Method is { Name: "Finalizer", DeclaringType: { Namespace: "AutoGeneratedExceptionFilter" } })
if (patch.Method is { Name: "Finalizer", DeclaringType: { Name: "AutoGeneratedExceptionFilter" } })
{
continue;
}
Expand Down

0 comments on commit 36c5efe

Please sign in to comment.