[tools] Remove the IntPtr.Size inline optimization.#24597
Conversation
We don't have any code paths conditions on IntPtr.Size anymore (because we only support 64-bit architectures now), so the size benefits for the optimizations are slim to non-existent (it's used in a few mathematical expressions, pointer arithmetic, etc., nothing that affects final app size if IntPtr.Size gets inlined or not).
There was a problem hiding this comment.
Pull request overview
This PR removes the IntPtr.Size inline optimization from the .NET for iOS/macOS/tvOS build tools. Since the platform now only supports 64-bit architectures, the optimization that inlined IntPtr.Size to a constant value no longer provides meaningful app size benefits.
Changes:
- Removed the code implementing the IntPtr.Size optimization from the linker
- Disabled the optimization while preserving backward compatibility for existing build configurations
- Removed documentation for the optimization and updated code examples
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/linker/CoreOptimizeGeneratedCode.cs | Removed ProcessIntPtrSize method, GetInlineIntPtrSize method, _inlineIntPtrSize dictionary, and the switch case that invoked the optimization |
| tools/common/Optimizations.cs | Set InlineIntPtrSize valid platforms to empty array while keeping the optimization name for backward compatibility |
| docs/website/optimizations.md | Removed the "Inline IntPtr.Size" section and updated code examples to remove IntPtr.Size checks |
| builds/Versions-tvOS.plist.in | Removed inline-intptr-size entry from Optimizations dictionary |
| builds/Versions-macOS.plist.in | Removed inline-intptr-size entry from Optimizations dictionary |
| builds/Versions-iOS.plist.in | Removed inline-intptr-size entry from Optimizations dictionary |
| builds/Versions-MacCatalyst.plist.in | Removed inline-intptr-size entry from Optimizations dictionary |
✅ [CI Build #42be985] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #42be985] Build passed (Detect API changes) ✅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 |
✅ [CI Build #42be985] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #42be985] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #42be985] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #42be985] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #42be985] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #42be985] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
🚀 [CI Build #42be985] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 117 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
We don't have any code paths conditions on IntPtr.Size anymore (because we
only support 64-bit architectures now), so the size benefits for the
optimizations are slim to non-existent (it's used in a few mathematical
expressions, pointer arithmetic, etc., nothing that affects final app size if
IntPtr.Size gets inlined or not).