From b34903aeada179cc546998a091b9a2ff8625dfd6 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Sun, 31 Dec 2023 00:31:37 +0500 Subject: [PATCH] feat: assert that a Result is successful via the profiler in Debug builds Signed-off-by: Octol1ttle --- src/Octobot.cs | 5 +++++ src/Services/Profiler/Profiler.cs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/Octobot.cs b/src/Octobot.cs index 063bd14..3049602 100644 --- a/src/Octobot.cs +++ b/src/Octobot.cs @@ -20,6 +20,11 @@ using Remora.Rest.Core; using Serilog.Extensions.Logging; namespace Octobot; +// TODO: better organizing of interaction checks (and other related chains of method calls) +// TODO: avoid nesting as much as possible (like embed sending :/) +// TODO: remove stuff that doesn't need to be profiled +// if it needs to be profiled, try to put it inside of 'if' blocks so it doesn't appear all the time +// (so we know e.g. if a feature is active or not) public sealed class Octobot { diff --git a/src/Services/Profiler/Profiler.cs b/src/Services/Profiler/Profiler.cs index 2cd4dd8..0047493 100644 --- a/src/Services/Profiler/Profiler.cs +++ b/src/Services/Profiler/Profiler.cs @@ -58,6 +58,7 @@ public sealed class Profiler /// The original result. public Result PopWithResult(Result result) { + Debug.Assert(result.IsSuccess); Pop(); return result; } @@ -115,6 +116,7 @@ public sealed class Profiler /// The original result. public Result ReportWithResult(Result result) { + Debug.Assert(result.IsSuccess); PopAndReport(); return result; }