Skip to content

[tools] Report warnings as warnings in ErrorHelper.ShowInternal. - #26414

Open
rolfbjarne wants to merge 1 commit into
mainfrom
dev/rolf/fix-warning-reporting
Open

[tools] Report warnings as warnings in ErrorHelper.ShowInternal.#26414
rolfbjarne wants to merge 1 commit into
mainfrom
dev/rolf/fix-warning-reporting

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

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.

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>
Copilot AI review requested due to automatic review settings August 5, 2026 21:00
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner August 5, 2026 21:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ProductException instances to LogError(ProductException) or LogWarning(ProductException) based on IsError(log).
  • Add an explanatory comment describing why warnings must not be logged as errors when the logger is an MSBuild task.

Comment on lines +329 to 333
log.LogWarning (mte);
}

ShowInner (log, e);

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 2a697dc58395c0002a73d6ab29b8b19ba90a8b9b [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [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
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 2a697dc58395c0002a73d6ab29b8b19ba90a8b9b [PR build]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants