Skip to content

[mtouch] Remove unused code from mtouch#25428

Open
rolfbjarne wants to merge 5 commits into
mainfrom
dev/rolf/mtouch-cleanup
Open

[mtouch] Remove unused code from mtouch#25428
rolfbjarne wants to merge 5 commits into
mainfrom
dev/rolf/mtouch-cleanup

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

The mtouch tool is only ever invoked with --runregistrar, so a lot of code in the shared tools/common/ files is never executed by mtouch. This PR removes ~520 lines of dead code.

Changes

Fully deleted (dead code with no callers anywhere):

  • Target.cs: GatherFrameworks (91 lines), ValidateAssembliesBeforeLink
  • Application.cs: GetArchitectures
  • Assembly.cs: ReadManifest, ParseAttributeWithDefault
  • cache.cs: CompareDirectories, CompareAssemblies, AssemblyReader class (~230 lines)
  • MachO.cs: GetNativeDependencies + native_dependencies field, SelectArchitectures (was behind #if MTOUCH which is never defined)

Guarded with #if !LEGACY_TOOLS (used by dotnet-linker but not mtouch):

  • Target.cs: AddAssembly, ExtractNativeLinkInfo, ComputeLinkerFlags
  • Application.cs: 19 methods/properties including CreateCache, ParseCustomLinkFlags, ParseInterpreter, ValidateAbi, MonoGCParams, LibMonoLinkMode, etc.
  • Driver.cs: 16 methods including ValidateXcode, FindTool, XcrunFind, RunClang, RunLipo, CreateDsym, RunStrip, etc.

Build infrastructure:

  • Made mtouch build work without Xcode (it only runs the static registrar, which doesn't need Xcode)
  • Added --ignore-xcode configure option

Verification

  • make all install -C tools
  • make all install -C msbuild

🤖 Pull request created by Copilot

rolfbjarne and others added 4 commits May 14, 2026 14:58
Remove GatherFrameworks and ValidateAssembliesBeforeLink which are dead
code (never called by anyone). Guard AddAssembly, ExtractNativeLinkInfo,
and ComputeLinkerFlags with #if !LEGACY_TOOLS since they are only called
from dotnet-linker.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Guard methods only called from dotnet-linker with #if !LEGACY_TOOLS:
CreateCache, ParseCustomLinkFlags, ParseInterpreter, UnsetInterpreter,
IsTodayExtension, IsTVExtension, ExtensionIdentifier, InfoPListPath,
RequiresPInvokeWrappers, TryParseManagedExceptionMode,
TryParseObjectiveCExceptionMode, ValidateAbi, ClearAbi, MonoGCParams,
LibMonoLinkMode, LibXamarinLinkMode, LibMonoNativeLinkMode, and
VerifyDynamicFramework.

Delete GetArchitectures (dead code - never called by anyone).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Guard methods only called from dotnet-linker with #if !LEGACY_TOOLS:
ValidateXcode, FindSystemXcode, FromPList, XcodeProductVersion, FindTool,
XcrunFind, RunXcodeTool, RunClang, RunInstallNameTool, RunBitcodeStrip,
RunLipo, RunLipoAndCreateDsym, CreateDsym, RunDsymUtil, and RunStrip.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove dead code that is never called from any project:
- Assembly.cs: ReadManifest, ParseAttributeWithDefault
- cache.cs: CompareDirectories, CompareAssemblies, AssemblyReader class
- MachO.cs: GetNativeDependencies + native_dependencies field,
  SelectArchitectures (was behind #if MTOUCH which is never defined)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Un-guard ValidateXcode, FindSystemXcode, FromPList, and
XcodeProductVersion so they compile for mtouch (LEGACY_TOOLS).
Restore the ValidateXcode call in mtouch.cs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne marked this pull request as ready for review May 15, 2026 06:53
Copilot AI review requested due to automatic review settings May 15, 2026 06:53
@rolfbjarne rolfbjarne enabled auto-merge (squash) May 15, 2026 06:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 trims dead or non-mtouch code from shared tooling so the legacy mtouch registrar path carries less unused functionality.

Changes:

  • Removes unused assembly/cache/Mach-O helper code.
  • Wraps dotnet-linker-only Application, Target, and Driver functionality in #if !LEGACY_TOOLS.
  • Keeps the remaining common code focused on mtouch’s static registrar usage.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/common/Target.cs Removes obsolete link-time assembly/framework helpers and guards non-legacy linker APIs.
tools/common/MachO.cs Removes unused native dependency and architecture selection helpers.
tools/common/Driver.cs Guards Xcode tool execution helpers for non-legacy builds.
tools/common/cache.cs Removes unused directory/assembly comparison support and AssemblyReader.
tools/common/Assembly.cs Removes unused native reference manifest parsing helpers.
tools/common/Application.cs Guards linker/bundling-only properties and helpers away from legacy mtouch.

Comment thread tools/common/Driver.cs
return result;
}

#if !LEGACY_TOOLS
@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #6dc8708] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 6dc8708441354a232d3338e395a066d2b38e0993 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #6dc8708] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 6dc8708441354a232d3338e395a066d2b38e0993 [PR build]

@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: 6dc8708441354a232d3338e395a066d2b38e0993 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #6dc8708] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 6dc8708441354a232d3338e395a066d2b38e0993 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🔥 [CI Build #6dc8708] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 4 tests failed, 171 tests passed.

Failures

❌ fsharp tests

2 tests failed, 2 tests passed.

Failed tests

  • fsharp/iOS - simulator/Debug: LaunchTimedOut
  • fsharp/tvOS - simulator/Debug: LaunchTimedOut

Html Report (VSDrops) Download

❌ monotouch tests (iOS)

1 tests failed, 15 tests passed.

Failed tests

  • monotouch-test/iOS - simulator/Release (strict inline dlfcn, link sdk): Failed

Html Report (VSDrops) Download

❌ monotouch tests (tvOS)

1 tests failed, 15 tests passed.

Failed tests

  • monotouch-test/tvOS - simulator/Release (NativeAOT, .NET 11 defaults): Failed

Html Report (VSDrops) Download

Successes

✅ 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 Publish failed ⚠️) Download
✅ framework: All 2 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 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 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: 6dc8708441354a232d3338e395a066d2b38e0993 [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