[tools] Report warnings as warnings in ErrorHelper.ShowInternal. - #26414
[tools] Report warnings as warnings in ErrorHelper.ShowInternal.#26414rolfbjarne wants to merge 1 commit into
Conversation
ErrorHelper.ShowInternal always logged through IToolLog.LogError, even for
warnings. That was mostly harmless when the log was the console (the message
text itself says "warning MTxxxx: ..."), but when the log is an MSBuild task -
which is the case for the assembly preparer (the PrepareAssemblies task, used
for NativeAOT) - every warning became an MSBuild error and failed the build.
This made it impossible to build monotouch-test for macOS with NativeAOT,
because the (correct) MT2387 warning about not being able to remove the dynamic
registrar failed the build:
error : warning MT2387: It's not safe to remove the dynamic registrar,
because monotouchtest references 'ObjCRuntime.Runtime.RegisterAssembly
(System.Reflection.Assembly)'.
Use IToolLog.LogWarning for warnings instead, which each IToolLog
implementation already handles correctly.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes logging severity in ErrorHelper.ShowInternal so that ProductException warnings are reported through IToolLog.LogWarning instead of always going through LogError, preventing MSBuild tasks (notably PrepareAssemblies used for NativeAOT) from treating tool warnings as build errors.
Changes:
- Route
ProductExceptioninstances toLogError(ProductException)orLogWarning(ProductException)based onIsError(log). - Add an explanatory comment describing why warnings must not be logged as errors when the logger is an MSBuild task.
| log.LogWarning (mte); | ||
| } | ||
|
|
||
| ShowInner (log, e); | ||
|
|
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
🚀 [CI Build #2a697dc] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 204 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
ErrorHelper.ShowInternal always logged through IToolLog.LogError, even for
warnings. That was mostly harmless when the log was the console (the message
text itself says "warning MTxxxx: ..."), but when the log is an MSBuild task -
which is the case for the assembly preparer (the PrepareAssemblies task, used
for NativeAOT) - every warning became an MSBuild error and failed the build.
This made it impossible to build monotouch-test for macOS with NativeAOT,
because the (correct) MT2387 warning about not being able to remove the dynamic
registrar failed the build:
Use IToolLog.LogWarning for warnings instead, which each IToolLog
implementation already handles correctly.