From 7aa39d071f547c0044acbe02dbd0d553247f12b4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Dec 2021 18:14:35 +0900 Subject: [PATCH] Fix incorrect usages of `ConditionalAttribute` for debug isolation These are cases we expect to work when a framework consumer (running a release framework build) builds as debug. The attribute won't work as it is compile-time baked. --- osu.Framework/Logging/LoadingComponentsLogger.cs | 11 +++++++---- osu.Framework/Logging/Logger.cs | 7 ++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/osu.Framework/Logging/LoadingComponentsLogger.cs b/osu.Framework/Logging/LoadingComponentsLogger.cs index 5b0d7deb00..86c3ba96ca 100644 --- a/osu.Framework/Logging/LoadingComponentsLogger.cs +++ b/osu.Framework/Logging/LoadingComponentsLogger.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Diagnostics; +using osu.Framework.Development; using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Graphics; using osu.Framework.Lists; @@ -12,23 +12,26 @@ internal static class LoadingComponentsLogger { private static readonly WeakList loading_components = new WeakList(); - [Conditional("DEBUG")] public static void Add(Drawable component) { + if (!DebugUtils.IsDebugBuild) return; + lock (loading_components) loading_components.Add(component); } - [Conditional("DEBUG")] public static void Remove(Drawable component) { + if (!DebugUtils.IsDebugBuild) return; + lock (loading_components) loading_components.Remove(component); } - [Conditional("DEBUG")] public static void LogAndFlush() { + if (!DebugUtils.IsDebugBuild) return; + lock (loading_components) { Logger.Log("⏳ Currently loading components"); diff --git a/osu.Framework/Logging/Logger.cs b/osu.Framework/Logging/Logger.cs index c8d1698514..8b069d3ffc 100644 --- a/osu.Framework/Logging/Logger.cs +++ b/osu.Framework/Logging/Logger.cs @@ -3,13 +3,12 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.IO; -using osu.Framework.Platform; using System.Linq; using System.Threading; using osu.Framework.Development; +using osu.Framework.Platform; using osu.Framework.Statistics; using osu.Framework.Threading; @@ -267,9 +266,11 @@ public static Logger GetLogger(string name) /// Logs a new message with the and will only be logged if your project is built in the Debug configuration. Please note that the default setting for is so unless you increase the to messages printed with this method will not appear in the output. /// /// The message that should be logged. - [Conditional("DEBUG")] public void Debug(string message = @"") { + if (!DebugUtils.IsDebugBuild) + return; + Add(message, LogLevel.Debug); }