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; 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..c545937a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 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/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/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..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 { @@ -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; 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; }