From 46f616df909ceff470d9a87a1b5a942c7ab3c6c1 Mon Sep 17 00:00:00 2001 From: David Sarno Date: Mon, 11 Aug 2025 16:52:42 -0700 Subject: [PATCH] read_console: correct compiler diagnostic categorization (CSxxxx), preserve Debug.Log as Log without mode fallback, add explicit Debug.Log detection helper --- UnityMcpBridge/Editor/Tools/ReadConsole.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/UnityMcpBridge/Editor/Tools/ReadConsole.cs b/UnityMcpBridge/Editor/Tools/ReadConsole.cs index 12350d2..cbeb4e4 100644 --- a/UnityMcpBridge/Editor/Tools/ReadConsole.cs +++ b/UnityMcpBridge/Editor/Tools/ReadConsole.cs @@ -267,8 +267,8 @@ namespace UnityMcpBridge.Editor.Tools // --- Filtering --- // Prefer classifying severity from message/stacktrace; fallback to mode bits if needed LogType unityType = InferTypeFromMessage(message); - bool isExplicitDebugLog = IsExplicitDebugLog(message); - if (!isExplicitDebugLog && unityType == LogType.Log) + bool isExplicitDebug = IsExplicitDebugLog(message); + if (!isExplicitDebug && unityType == LogType.Log) { unityType = GetLogTypeFromMode(mode); } @@ -423,10 +423,16 @@ namespace UnityMcpBridge.Editor.Tools return LogType.Error; if (fullMessage.IndexOf("LogWarning", StringComparison.OrdinalIgnoreCase) >= 0) return LogType.Warning; - if (IsExplicitDebugLog(fullMessage)) - return LogType.Log; - // Exceptions often include the word "Exception" in the first lines + // Compiler diagnostics (C#): "warning CSxxxx" / "error CSxxxx" + if (fullMessage.IndexOf(" warning CS", StringComparison.OrdinalIgnoreCase) >= 0 + || fullMessage.IndexOf(": warning CS", StringComparison.OrdinalIgnoreCase) >= 0) + return LogType.Warning; + if (fullMessage.IndexOf(" error CS", StringComparison.OrdinalIgnoreCase) >= 0 + || fullMessage.IndexOf(": error CS", StringComparison.OrdinalIgnoreCase) >= 0) + return LogType.Error; + + // Exceptions (avoid misclassifying compiler diagnostics) if (fullMessage.IndexOf("Exception", StringComparison.OrdinalIgnoreCase) >= 0) return LogType.Exception; @@ -439,7 +445,6 @@ namespace UnityMcpBridge.Editor.Tools private static bool IsExplicitDebugLog(string fullMessage) { - // Detect explicit Debug.Log in the stacktrace/message to lock type to Log if (string.IsNullOrEmpty(fullMessage)) return false; if (fullMessage.IndexOf("Debug:Log (", StringComparison.OrdinalIgnoreCase) >= 0) return true; if (fullMessage.IndexOf("UnityEngine.Debug:Log (", StringComparison.OrdinalIgnoreCase) >= 0) return true;