[tools] Use instance-based Log methods.#25566
Conversation
This will become important soon, because much of the code here will run from inside an MSBuild task, and we mustn't call Console.[Error.]WriteLine from inside an MSBuild task (it can cause tasks to deadlock). With these changes it'll be much easier to remap Log calls to MSBuild's Task.LogMessage method.
There was a problem hiding this comment.
Pull request overview
This PR refactors tool logging from static Driver/console-based calls to instance-based IToolLog plumbing, preparing shared tooling code to run safely inside MSBuild tasks without direct console writes.
Changes:
- Introduces
IToolLogand implements it for tool applications, bgen, console logging, and MSBuild tasks. - Threads logging instances through shared helpers such as
Driver,ErrorHelper,FileCopier, cache, resolver, Mach-O, and linker steps. - Updates MSBuild task verbosity and file-copy integration to use the new logging abstraction.
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/mtouch/mtouch.csproj | Links the shared logging abstraction into mtouch. |
| tools/mtouch/AssemblyResolver.cs | Threads Application logging into assembly resolution. |
| tools/linker/RegistrarRemovalTrackingStep.cs | Uses application-scoped logging/warnings. |
| tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs | Replaces static logging with linker context app logging. |
| tools/linker/CoreOptimizeGeneratedCode.cs | Threads logging through optimization helpers and warnings. |
| tools/dotnet-linker/Steps/ManagedRegistrarStep.cs | Passes app logger to error reporting. |
| tools/dotnet-linker/Steps/ManagedRegistrarLookupTablesStep.cs | Uses app logging for diagnostic messages. |
| tools/dotnet-linker/Steps/InlineDlfcnMethodsStep.cs | Uses app logging for inlining diagnostics. |
| tools/dotnet-linker/Steps/InlineClassGetHandleStep.cs | Uses app logging and instance-based file writes. |
| tools/dotnet-linker/Steps/ExceptionalMarkHandler.cs | Exposes Application to derived handlers. |
| tools/dotnet-linker/PreserveSmartEnumConversionsStep.cs | Adds app logging for smart enum diagnostics. |
| tools/dotnet-linker/LinkerConfiguration.cs | Moves linker verbosity/log output to Application/IToolLog. |
| tools/dotnet-linker/DotNetResolver.cs | Adds constructor shape for app-aware resolver creation. |
| tools/dotnet-linker/dotnet-linker.csproj | Links the shared logging abstraction into dotnet-linker. |
| tools/dotnet-linker/BackingFieldDelayHandler.cs | Passes app logger into validation helpers. |
| tools/common/Target.cs | Threads logging through realpath, file writes, and generated main verbosity. |
| tools/common/StaticRegistrar.cs | Updates registrar logging/error reporting to use App. |
| tools/common/PInvokeWrapperGenerator.cs | Uses instance-aware file writing. |
| tools/common/MachO.cs | Replaces console diagnostics with IToolLog. |
| tools/common/IToolLog.cs | Adds the shared logging interface, extensions, and console implementation. |
| tools/common/Frameworks.cs | Uses app logging for framework filtering diagnostics. |
| tools/common/FileCopier.cs | Reworks copy/update logging and callbacks around IToolLog. |
| tools/common/ErrorHelper.tools.cs | Makes warning/error display logger-aware. |
| tools/common/Driver.execution.cs | Makes command execution logger-aware. |
| tools/common/Driver.cs | Removes static verbosity/log helpers and threads IToolLog. |
| tools/common/CoreResolver.cs | Threads logging through resolver load/search warnings. |
| tools/common/cache.cs | Makes cache location/comparison logging instance-aware. |
| tools/common/Assembly.cs | Uses application logging/cache APIs throughout assembly processing. |
| tools/common/Application.cs | Implements IToolLog and initializes app-scoped resolver/verbosity. |
| src/ObjCRuntime/Registrar.cs | Updates registrar warning dispatch/signatures. |
| src/ObjCRuntime/DynamicRegistrar.cs | Updates override signature for nullable args. |
| src/bgen/BindingTouch.cs | Implements IToolLog for bgen and uses instance verbosity. |
| src/bgen/bgen.csproj | Includes the shared logging abstraction in bgen. |
| msbuild/Xamarin.MacDev.Tasks/Xamarin.MacDev.Tasks.csproj | Links the shared logging abstraction into MSBuild tasks. |
| msbuild/Xamarin.MacDev.Tasks/VerbosityUtils.cs | Converts verbosity rendering/parsing to integer levels. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs | Implements IToolLog for MSBuild tasks. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/ParseBundlerArguments.cs | Hides base verbosity for existing output property. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/MergeAppBundles.cs | Uses task logging with FileCopier. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/CreateBindingResourcePackage.cs | Uses task logging with FileCopier. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/BGen.cs | Renders verbosity through the new helper. |
| msbuild/Xamarin.MacDev.Tasks/Decompress.cs | Uses task logging with FileCopier up-to-date checks. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
✅ [PR Build #5dac028] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #5dac028] Build passed (Build packages) ✅Pipeline on Agent |
✅ 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 |
✅ [PR Build #5dac028] Build passed (Build macOS tests) ✅Pipeline on Agent |
🚀 [CI Build #5dac028] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 193 tests passed 🎉 Tests counts✅ cecil: 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 |
This will become important soon, because much of the code here will run from
inside an MSBuild task, and we mustn't call Console.[Error.]WriteLine from
inside an MSBuild task (it can cause tasks to deadlock). With these changes
it'll be much easier to remap Log calls to MSBuild's Task.LogMessage method.