From 04dc0723b0c5876c897d74bdee786718500193aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 15 Aug 2025 23:14:49 +0200 Subject: [PATCH 1/4] Tweaks to warning formatting Fixes #118788 --- .../Compiler/Logging/MessageContainer.cs | 2 +- .../aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageContainer.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageContainer.cs index a73816d388713e..8e5fa07ec8da8a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageContainer.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageContainer.cs @@ -271,7 +271,7 @@ private MessageContainer(MessageCategory category, DiagnosticId id, string subca public string ToMSBuildString() { - const string originApp = "ILC"; + const string originApp = "ILC "; // extra space for MSBuild sake: https://github.com/dotnet/runtime/issues/118788 string origin = Origin?.ToString() ?? originApp; StringBuilder sb = new StringBuilder(); diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs index 98b214e2b4785a..32d5352c889849 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs @@ -213,16 +213,18 @@ private void CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeN if (exception != null) { + var mdOwningType = method.OwningType as MetadataType; + string owningAssembly = mdOwningType?.Module?.Assembly?.GetName()?.Name ?? ""; if (exception is TypeSystemException.InvalidProgramException - && method.OwningType is MetadataType mdOwningType + && mdOwningType != null && mdOwningType.HasCustomAttribute("System.Runtime.InteropServices", "ClassInterfaceAttribute")) { Logger.LogWarning(method, DiagnosticId.COMInteropNotSupportedInFullAOT); } if ((_compilationOptions & RyuJitCompilationOptions.UseResilience) != 0) - Logger.LogMessage($"Method '{method}' will always throw because: {exception.Message}"); + Logger.LogMessage($"Method '{method}' in assembly '{owningAssembly}' will always throw because: {exception.Message}"); else - Logger.LogError($"Method will always throw because: {exception.Message}", 1005, method, MessageSubCategory.AotAnalysis); + Logger.LogError($"Method in '{owningAssembly}' will always throw because: {exception.Message}", 1005, method, MessageSubCategory.AotAnalysis); // Try to compile the method again, but with a throwing method body this time. MethodIL throwingIL = TypeSystemThrowingILEmitter.EmitIL(method, exception); From eea3ac2b83f92ebf2fae9a1f482182738317301d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 15 Aug 2025 23:19:46 +0200 Subject: [PATCH 2/4] Okay I just read what it prints --- .../tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs index 32d5352c889849..dfee1abd071305 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs @@ -222,7 +222,7 @@ private void CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeN Logger.LogWarning(method, DiagnosticId.COMInteropNotSupportedInFullAOT); } if ((_compilationOptions & RyuJitCompilationOptions.UseResilience) != 0) - Logger.LogMessage($"Method '{method}' in assembly '{owningAssembly}' will always throw because: {exception.Message}"); + Logger.LogMessage($"Method '{method}' in assembly will always throw because: {exception.Message}"); else Logger.LogError($"Method in '{owningAssembly}' will always throw because: {exception.Message}", 1005, method, MessageSubCategory.AotAnalysis); From c3ef2567e7a97977961c959078c4130c4dd9930c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 15 Aug 2025 23:20:17 +0200 Subject: [PATCH 3/4] Update RyuJitCompilation.cs --- .../tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs index dfee1abd071305..c47a0a8af4472f 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs @@ -222,7 +222,7 @@ private void CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeN Logger.LogWarning(method, DiagnosticId.COMInteropNotSupportedInFullAOT); } if ((_compilationOptions & RyuJitCompilationOptions.UseResilience) != 0) - Logger.LogMessage($"Method '{method}' in assembly will always throw because: {exception.Message}"); + Logger.LogMessage($"Method '{method}' will always throw because: {exception.Message}"); else Logger.LogError($"Method in '{owningAssembly}' will always throw because: {exception.Message}", 1005, method, MessageSubCategory.AotAnalysis); From 20552fe5c60601a7efc756e7448716fde312069a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 15 Aug 2025 14:31:10 -0700 Subject: [PATCH 4/4] Update MessageContainer.cs --- src/tools/illink/src/linker/Linker/MessageContainer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/illink/src/linker/Linker/MessageContainer.cs b/src/tools/illink/src/linker/Linker/MessageContainer.cs index cf104999fd123a..cad211eea84037 100644 --- a/src/tools/illink/src/linker/Linker/MessageContainer.cs +++ b/src/tools/illink/src/linker/Linker/MessageContainer.cs @@ -293,7 +293,8 @@ private MessageContainer(MessageCategory category, DiagnosticId id, string subca public string ToMSBuildString() { const string originApp = Constants.ILLink; - string origin = Origin?.ToString() ?? originApp; + string origin = Origin?.ToString() + ?? $"{originApp} "; // extra space for MSBuild sake: https://github.com/dotnet/runtime/issues/118788 StringBuilder sb = new StringBuilder(); sb.Append(origin).Append(':');