[dotnet-linker] Only override NSObjectProxyAttribute.LookupUnmanagedFunction when the type actually has any UnmanagedCallersOnly methods to look up. - #26364
Conversation
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
There was a problem hiding this comment.
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.LookupUnmanagedFunctionvirtual with a default implementation returningIntPtr.Zero. - Update the trimmable registrar step to only generate
LookupUnmanagedFunctionwhen there are anyUnmanagedCallersOnlyentry 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. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…gistrar-no-param-names
…gistrar-no-param-names # Conflicts: # tools/dotnet-linker/Steps/TrimmableRegistrarStep.cs
|
✅ Applied expected app size files from gist. |
…param-names' into dev/rolf/default-lookupunmanaged-impl
…gistrar-no-param-names
…param-names' into dev/rolf/default-lookupunmanaged-impl
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.
026c029 to
39a281b
Compare
This comment has been minimized.
This comment has been minimized.
✅ 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 |
This comment has been minimized.
This comment has been minimized.
🚀 [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 macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Only override
NSObjectProxyAttribute.LookupUnmanagedFunctionwhen the type actually has anyUnmanagedCallersOnlymethods to look up. The method is now virtual instead of abstract, and the base implementation returnsIntPtr.Zero, which is exactly what the generated override did for types without any such methods.Copilot-Session: 6aeeddfd-3bd8-4129-ad90-7292860c4b66