From 2b828bb50ff87ad733403d17b2b4db0b6fea2541 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Tue, 17 Dec 2019 22:15:16 -0600 Subject: [PATCH] Use runtime instead of compile-time conditionals for result logging --- .gitignore | 3 ++- src/LibHac/Result.cs | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index a16434f5..aca4195e 100644 --- a/.gitignore +++ b/.gitignore @@ -264,4 +264,5 @@ __pycache__/ global.json -!tests/LibHac.Tests/CryptoTests/TestVectors/* \ No newline at end of file +!tests/LibHac.Tests/CryptoTests/TestVectors/* +**/DisasmoBin/ diff --git a/src/LibHac/Result.cs b/src/LibHac/Result.cs index 62c8e167..65cc4453 100644 --- a/src/LibHac/Result.cs +++ b/src/LibHac/Result.cs @@ -42,9 +42,8 @@ namespace LibHac /// The called value. public Result Log() { -#if DEBUG - LogCallback?.Invoke(this); -#endif + LogImpl(); + return this; } @@ -55,12 +54,23 @@ namespace LibHac /// The called value. public Result LogConverted(Result originalResult) { -#if DEBUG - ConvertedLogCallback?.Invoke(this, originalResult); -#endif + LogConvertedImpl(originalResult); + return this; } + [Conditional("DEBUG")] + private void LogImpl() + { + LogCallback?.Invoke(this); + } + + [Conditional("DEBUG")] + private void LogConvertedImpl(Result originalResult) + { + ConvertedLogCallback?.Invoke(this, originalResult); + } + public delegate void ResultLogger(Result result); public delegate void ConvertedResultLogger(Result result, Result originalResult); public delegate bool ResultNameGetter(Result result, out string name);