From 7e540cf1641f111d37b0afe2903c025b9da96853 Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Fri, 4 Oct 2024 21:50:30 +0300 Subject: [PATCH 1/5] Fix --- .github/workflows/test-full.yml | 1 + .github/workflows/test.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/test-full.yml b/.github/workflows/test-full.yml index 5940f0e4..7337a307 100644 --- a/.github/workflows/test-full.yml +++ b/.github/workflows/test-full.yml @@ -21,6 +21,7 @@ on: - 'src/**' - 'tests/**' - 'build/**' + workflow_dispatch: env: # Disable the .NET logo in the console output. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ded04689..b50f27b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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); @@ -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; From 3e3ca16136c895145bfa12e12d5f6f261985f9df Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 5 Oct 2024 00:16:29 +0000 Subject: [PATCH 2/5] Automated dotnet-format update --- .../Patches/DefinitionContextPatch.cs | 16 +++++----- .../ExceptionHandlerSubSystem.cs | 3 +- .../ExceptionHandler/ExceptionReporter.cs | 32 +++++++++---------- .../ExceptionHandler/Utils/CreatorZip.cs | 2 +- .../ExceptionHandler/Utils/MiniDump.cs | 8 ++--- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/Bannerlord.ButterLib.Implementation/SaveSystem/Patches/DefinitionContextPatch.cs b/src/Bannerlord.ButterLib.Implementation/SaveSystem/Patches/DefinitionContextPatch.cs index 49f4595d..223892bd 100644 --- a/src/Bannerlord.ButterLib.Implementation/SaveSystem/Patches/DefinitionContextPatch.cs +++ b/src/Bannerlord.ButterLib.Implementation/SaveSystem/Patches/DefinitionContextPatch.cs @@ -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() ]; diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionHandlerSubSystem.cs b/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionHandlerSubSystem.cs index 236325e5..145f6c19 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionHandlerSubSystem.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionHandlerSubSystem.cs @@ -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; diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs b/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs index 819de1cc..23b2a54f 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs @@ -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 GetLogSources() { diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/Utils/CreatorZip.cs b/src/Bannerlord.ButterLib/ExceptionHandler/Utils/CreatorZip.cs index d7bc68b0..4514f420 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/Utils/CreatorZip.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/Utils/CreatorZip.cs @@ -1,4 +1,4 @@ -using BUTR.CrashReport.Models; +using BUTR.CrashReport.Models; using BUTR.CrashReport.Renderer.Zip; using Newtonsoft.Json; diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/Utils/MiniDump.cs b/src/Bannerlord.ButterLib/ExceptionHandler/Utils/MiniDump.cs index a75998e9..776ff1a8 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/Utils/MiniDump.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/Utils/MiniDump.cs @@ -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 @@ -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 @@ -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)] @@ -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; From 7e8319e4472271aae940d37fc77784e5843933ac Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Mon, 7 Oct 2024 00:56:07 +0300 Subject: [PATCH 3/5] Fixed Better Exception Window involved detection --- .../ExceptionHandler/Utils/StacktraceFilter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/Utils/StacktraceFilter.cs b/src/Bannerlord.ButterLib/ExceptionHandler/Utils/StacktraceFilter.cs index 0e490245..c6f6140d 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/Utils/StacktraceFilter.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/Utils/StacktraceFilter.cs @@ -44,7 +44,7 @@ public IEnumerable Filter(ICollection 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; } @@ -73,7 +73,7 @@ private IEnumerable FilterPatches(ICollection patches) { continue; } - if (patch.Method is { Name: "Finalizer", DeclaringType: { Namespace: "AutoGeneratedExceptionFilter" } }) + if (patch.Method is { Name: "Finalizer", DeclaringType: { Name: "AutoGeneratedExceptionFilter" } }) { continue; } From 31fe8978c0764fe6cca2c10bf7e92954feb192f7 Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Mon, 7 Oct 2024 11:37:51 +0300 Subject: [PATCH 4/5] Removed Crash Report duplicates being shown after closing --- build/common.props | 2 +- changelog.txt | 4 ++++ .../ExceptionHandler/BEWPatch.cs | 19 ++++++------------- .../ExceptionHandler/ExceptionReporter.cs | 8 ++++---- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/build/common.props b/build/common.props index 00cdf5b9..34fc217c 100644 --- a/build/common.props +++ b/build/common.props @@ -5,7 +5,7 @@ 1.0.0 - 2.9.17 + 2.9.18 2.2.2 3.2.0.77 diff --git a/changelog.txt b/changelog.txt index 674e6e79..21a1f482 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,8 @@ --------------------------------------------------------------------------------------------------- +Version: 2.9.18 +Game Versions: v1.0.x,v1.1.x,v1.2.x +* Removed Crash Report duplicates being shown after closing +--------------------------------------------------------------------------------------------------- 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 diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs b/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs index ce0ba097..9cbc7d51 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs @@ -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 SuppressedExceptions = []; - private static readonly string[] BEW = ["org.calradia.admiralnelson.betterexceptionwindow"]; @@ -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) diff --git a/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs b/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs index 23b2a54f..51c453a9 100644 --- a/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs +++ b/src/Bannerlord.ButterLib/ExceptionHandler/ExceptionReporter.cs @@ -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 { From e3030a9ba1aad4b40365a3c56d013e5f968fd2d4 Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Mon, 7 Oct 2024 11:39:23 +0300 Subject: [PATCH 5/5] Update changelog.txt --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index 21a1f482..c545937a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ 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