From fb4af4d526525051f1f861c20c2267feeba75e87 Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Fri, 11 Oct 2024 17:46:22 +0300 Subject: [PATCH] Fixed empty callstack render issue --- .../CrashReportParser.cs | 7 ++++--- .../Renderer/ImGuiRenderer.02.Exception.cs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/BUTR.CrashReport.Bannerlord.Parser/CrashReportParser.cs b/src/BUTR.CrashReport.Bannerlord.Parser/CrashReportParser.cs index a0a4051..a6d39a5 100644 --- a/src/BUTR.CrashReport.Bannerlord.Parser/CrashReportParser.cs +++ b/src/BUTR.CrashReport.Bannerlord.Parser/CrashReportParser.cs @@ -145,7 +145,7 @@ public static IEnumerable ParseLegacyHtmlLogs(string content) { case >= 13: { - return Enumerable.Empty(); + return []; } default: { @@ -364,8 +364,9 @@ static IList GetModuleSubModules(IReadOnlyList lin IsMultiplayer = GetField(lines, "Multiplayer").Equals("true", StringComparison.OrdinalIgnoreCase), Url = GetField(lines, "Url"), UpdateInfo = null, - DependencyMetadatas = GetModuleDependencyMetadatas(GetRange(lines, version == 1 ? "Dependency Metadatas" : "Dependencies", new[] { "SubModules", "Additional Assemblies", "Url" })), - SubModules = GetModuleSubModules(GetRange(lines, "SubModules", new[] { "Additional Assemblies" })), + DependencyMetadatas = GetModuleDependencyMetadatas(GetRange(lines, version == 1 ? "Dependency Metadatas" : "Dependencies", ["SubModules", "Additional Assemblies", "Url" + ])), + SubModules = GetModuleSubModules(GetRange(lines, "SubModules", ["Additional Assemblies"])), Capabilities = Array.Empty(), AdditionalMetadata = new List { new() { Key = "METADATA:MANAGED_BY_VORTEX", Value = isVortex.ToString() } }.Concat(lines.SkipWhile(l => !l.StartsWith("Additional Assemblies:")).Skip(1).Select(l => { diff --git a/src/BUTR.CrashReport.Renderer.ImGui/Renderer/ImGuiRenderer.02.Exception.cs b/src/BUTR.CrashReport.Renderer.ImGui/Renderer/ImGuiRenderer.02.Exception.cs index 20710ae..cfdfb15 100644 --- a/src/BUTR.CrashReport.Renderer.ImGui/Renderer/ImGuiRenderer.02.Exception.cs +++ b/src/BUTR.CrashReport.Renderer.ImGui/Renderer/ImGuiRenderer.02.Exception.cs @@ -38,7 +38,7 @@ private void InitializeExceptionRecursively() curr = _crashReport.Exception; while (curr is not null) { - var callStackLines = curr.CallStack.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Select(x => x).ToArray(); + var callStackLines = curr.CallStack.Split([Environment.NewLine], StringSplitOptions.RemoveEmptyEntries).Select(x => x).ToArray(); var sb = new StringBuilder(); for (var i = 0; i < callStackLines.Length; i++) @@ -49,7 +49,7 @@ private void InitializeExceptionRecursively() _exceptionsUtf8[level] = UnsafeHelper.ToUtf8Array(sb.ToString()); - var fistCallstackLine = callStackLines[0].Trim(); + var fistCallstackLine = callStackLines.Length > 0 ? callStackLines[0].Trim() : string.Empty; _stacktracesUtf8[level] = _crashReport.EnhancedStacktrace.FirstOrDefault(x => fistCallstackLine == $"at {x.FrameDescription}"); _callstackLineCount[level] = callStackLines.Length;