Skip to content

[dotnet-linker] Only override NSObjectProxyAttribute.LookupUnmanagedFunction when the type actually has any UnmanagedCallersOnly methods to look up. - #26364

Merged
rolfbjarne merged 19 commits into
mainfrom
dev/rolf/default-lookupunmanaged-impl
Aug 5, 2026
Merged

[dotnet-linker] Only override NSObjectProxyAttribute.LookupUnmanagedFunction when the type actually has any UnmanagedCallersOnly methods to look up.#26364
rolfbjarne merged 19 commits into
mainfrom
dev/rolf/default-lookupunmanaged-impl

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Only override NSObjectProxyAttribute.LookupUnmanagedFunction when the type actually has any UnmanagedCallersOnly methods to look up. The method is now virtual instead of abstract, and the base implementation returns IntPtr.Zero, which is exactly what the generated override did for types without any such methods.

Copilot-Session: 6aeeddfd-3bd8-4129-ad90-7292860c4b66

rolfbjarne and others added 2 commits July 30, 2026 12:16
Don't emit parameter names in the generated registrar code. Cecil only emits a Param row for parameters that have a name (or attributes, marshalling info or a default value), and the parameter names of these generated methods have no value to anyone.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6aeeddfd-3bd8-4129-ad90-7292860c4b66
…Function` when the type actually has any `UnmanagedCallersOnly` methods to look up.

Only override `NSObjectProxyAttribute.LookupUnmanagedFunction` when the type actually has any `UnmanagedCallersOnly` methods to look up. The method is now virtual instead of abstract, and the base implementation returns `IntPtr.Zero`, which is exactly what the generated override did for types without any such methods.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6aeeddfd-3bd8-4129-ad90-7292860c4b66
Copilot AI review requested due to automatic review settings July 30, 2026 10:20

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 reduces the size of trimmable static registrar type map assemblies by only emitting NSObjectProxyAttribute.LookupUnmanagedFunction overrides for proxy types that actually need to resolve any UnmanagedCallersOnly trampolines. It does this by making LookupUnmanagedFunction virtual with a default IntPtr.Zero implementation, and then skipping override emission when there are no entry points to look up.

Changes:

  • Make NSObjectProxyAttribute.LookupUnmanagedFunction virtual with a default implementation returning IntPtr.Zero.
  • Update the trimmable registrar step to only generate LookupUnmanagedFunction when there are any UnmanagedCallersOnly entry points for the proxied type.

Reviewed changes

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

File Description
tools/dotnet-linker/Steps/TrimmableRegistrarStep.cs Only emits a LookupUnmanagedFunction override when UnmanagedCallersOnly trampolines exist for the proxy type.
src/ObjCRuntime/TypeMaps.cs Changes LookupUnmanagedFunction from abstract to virtual, with a default IntPtr.Zero implementation to support skipping overrides.

Comment thread tools/dotnet-linker/Steps/TrimmableRegistrarStep.cs
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

⚠️ AppSizeTest expected files changed ⚠️

The AppSizeTest detected changes in the expected app size files.

To update the expected files, add a comment with the following command:

/apply-gist https://gist.github.com/vs-mobiletools-engineering-service2/6957d959a45ca8593060ebf74f17b36c
Updated files
  • iOS-NativeAOT-TrimmableStatic-size.txt
  • MacCatalyst-NativeAOT-TrimmableStatic-size.txt
  • MacOSX-CoreCLR-Interpreter-size.txt
  • MacOSX-CoreCLR-Interpreter-TrimmableStatic-size.txt
  • MacOSX-NativeAOT-TrimmableStatic-size.txt
  • TVOS-NativeAOT-size.txt
  • TVOS-NativeAOT-TrimmableStatic-size.txt

Pipeline on Agent
Hash: d76b78b4819bcdd3154fc7d68397709d8a550241 [PR build]

rolfbjarne and others added 6 commits July 31, 2026 16:07
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…gistrar-no-param-names

# Conflicts:
#	tools/dotnet-linker/Steps/TrimmableRegistrarStep.cs
@rolfbjarne

Copy link
Copy Markdown
Member Author

/apply-gist https://gist.github.com/vs-mobiletools-engineering-service2/6957d959a45ca8593060ebf74f17b36c

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

✅ Applied expected app size files from gist.

@github-actions
github-actions Bot requested a review from dalexsoto as a code owner August 3, 2026 20:10
@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne added ready-to-review This PR is ready to review/merge. and removed ready-to-review This PR is ready to review/merge. labels Aug 4, 2026
@vs-mobiletools-engineering-service2

This comment has been minimized.

Base automatically changed from dev/rolf/trimmable-registrar-no-param-names to main August 5, 2026 13:25
@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Aug 5, 2026
dalexsoto
dalexsoto previously approved these changes Aug 5, 2026
@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne
rolfbjarne force-pushed the dev/rolf/default-lookupunmanaged-impl branch from 026c029 to 39a281b Compare August 5, 2026 15:22
@vs-mobiletools-engineering-service2

This comment has been minimized.

@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: 39a281bbc3ba47589012527f7e51be00ad026c64 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #39a281b] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 203 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 19 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. [attempt 2] 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: 39a281bbc3ba47589012527f7e51be00ad026c64 [PR build]

@rolfbjarne
rolfbjarne merged commit 2ca5032 into main Aug 5, 2026
62 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/default-lookupunmanaged-impl branch August 5, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants