Skip to content

[net11.0] [tools/msbuild] Add InlineDlfcnMethodsStep as an opt-in custom linker step#24889

Closed
rolfbjarne wants to merge 30 commits intonet11.0from
dev/rolf/inline-dlfcn-net11.0
Closed

[net11.0] [tools/msbuild] Add InlineDlfcnMethodsStep as an opt-in custom linker step#24889
rolfbjarne wants to merge 30 commits intonet11.0from
dev/rolf/inline-dlfcn-net11.0

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member


⚠️ This is a pull request only to see what happens after #24888 gets merged into net11.0. ⚠️

⚠️ No need to review this, it won't be merged. ⚠️


@rolfbjarne rolfbjarne requested a review from Copilot March 12, 2026 12:35
@rolfbjarne rolfbjarne added the do-not-merge Do not merge this pull request label Mar 12, 2026
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 brings the [tools/msbuild] InlineDlfcnMethodsStep work into the net11.0 branch, wiring up an opt-in (and for .NET 11+ defaulted) custom linker step that inlines ObjCRuntime.Dlfcn symbol lookups and adds post-trimming MSBuild processing to generate native glue only for surviving symbols. It also updates tests and documentation around native symbol handling.

Changes:

  • Add linker steps to inline Dlfcn calls and emit a symbol list for later build steps.
  • Add MSBuild targets/tasks to collect post-trim surviving symbols (ILTrim + NativeAOT) and generate/compile native C glue.
  • Update runtime/framework code and tests for new array/enum helpers, symbol handling, and Xcode 26.3 support.

Reviewed changes

Copilot reviewed 42 out of 44 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tools/mtouch/Errors.resx Adds new MX225x messages for InlineDlfcnMethodsStep warnings.
tools/mtouch/Errors.designer.cs Regenerates resource accessors for new MX225x strings.
tools/linker/MonoTouch.Tuner/ProcessExportedFields.cs Collects [Field] symbol names for compatibility mode.
tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs Avoids exported symbol listing logic when inline-dlfcn is enabled.
tools/dotnet-linker/Steps/InlineDlfcnMethodsStep.cs New linker step that rewrites ObjCRuntime.Dlfcn call sites to generated P/Invokes.
tools/dotnet-linker/Steps/GenerateInlinedDlfcnNativeCodeStep.cs New linker step that writes a symbol list to intermediate output.
tools/dotnet-linker/LinkerConfiguration.cs Plumbs new InlineDlfcnMethods settings and symbol collections through linker configuration.
tools/dotnet-linker/AppBundleRewriter.cs Adds a few additional type/method references used by new rewriting logic.
tools/common/SdkVersions.cs Updates max iOS simulator version to 26.3.
tools/common/MachO.cs Adds LC_SYMTAB parsing and support for reading unresolved symbols from Mach-O/object/static libraries.
tests/xharness/Jenkins/TestVariationsFactory.cs Adds new test variations to exercise inline-dlfcn modes.
tests/monotouch-test/VideoToolbox/VTDecompressionSessionTests.cs Ensures async frames complete via WaitForAsynchronousFrames in tests.
tests/monotouch-test/ObjCRuntime/RegistrarTest.cs Uses global-qualified MetalKit types to avoid ambiguity.
tests/monotouch-test/ObjCRuntime/DlfcnTest.cs Adds test coverage for [Field]-backed constants and caching behavior.
tests/monotouch-test/NetworkExtension/NEHotspotEapSettingsTest.cs New tests for SupportedEapTypes roundtrip/null behavior.
tests/monotouch-test/Metal/MTKMeshTest.cs New test for MTKMesh.FromAsset API behavior.
tests/monotouch-test/Foundation/NSArray1Test.cs Adds tests for NSArray.EnumsFromHandle behavior.
tests/monotouch-test/Foundation/AttributedStringTest.cs Removes a field-symbol existence test that is no longer relevant.
tests/monotouch-test/CoreText/FontTest.cs Makes AppleColorEmoji font creation resilient and loosens a bounds assertion.
tests/monotouch-test/CoreGraphics/BitmapContextTest.cs Computes adaptive buffer sizes from parameters and adds checked arithmetic.
tests/monotouch-test/CoreFoundation/ProxyTest.cs Removes a field-symbol existence test that is no longer relevant.
tests/common/test-variations.csproj Adds variations for static registrar and inline-dlfcn modes (plus define).
tests/common/TestRuntime.cs Adds Xcode 26.3 mapping logic for version checks.
tests/cecil-tests/Documentation.KnownFailures.txt Removes a known-failure entry tied to NSArray.EnumsFromHandle docs.
src/bgen/Generator.cs Updates generator output for wrapped-array properties to deal with nullable changes.
src/UIKit/UIFontDescriptor.cs Switches CascadeList to a non-null array helper that drops nulls.
src/NetworkExtension/NEHotspotEapSettings.cs Uses new enum-array helper to return a non-null array.
src/MetalKit/MTKMesh.cs Makes sourceMeshes out parameter nullable.
src/Foundation/NSArray.cs Adds new array helpers, updates EnumsFromHandle signature/implementation, and adds non-null enum helper.
src/CoreGraphics/CGFont.cs Makes CreateWithFontName return nullable and switches to TransientCFString usage.
msbuild/Xamarin.MacDev.Tasks/Tasks/PostTrimmingProcessing.cs New task to generate native C glue for surviving symbols.
msbuild/Xamarin.MacDev.Tasks/Tasks/ComputeNativeAOTSurvivingNativeSymbols.cs New task to compute surviving inline-dlfcn symbols from NativeAOT unresolved list.
msbuild/Xamarin.MacDev.Tasks/Tasks/CompileNativeCode.cs Ensures output directory exists before compiling native code.
msbuild/Xamarin.MacDev.Tasks/Tasks/CollectUnresolvedNativeSymbols.cs New task to extract unresolved symbols from a native static library/object file.
msbuild/Xamarin.MacDev.Tasks/Tasks/CollectPostILTrimInformation.cs New task to scan trimmed assemblies for surviving inline-dlfcn P/Invokes (with caching).
global.json Updates pinned SDK/tooling versions.
eng/Version.Details.props Dependency-flow version details update (but currently invalid XML).
dotnet/targets/Xamarin.Shared.Sdk.targets Wires custom linker steps + post-trimming MSBuild targets; adds .NET 11 defaults for InlineDlfcnMethods.
docs/code/native-symbols.md New documentation describing native symbol handling + inline-dlfcn pipeline.
docs/building-apps/build-properties.md Documents the InlineDlfcnMethods property and defaults.
NuGet.config Adds a new package source entry.
Make.config Special-cases Xcode 26.3 for simulator runtime selection.
.github/copilot-instructions.md Notes a repo-specific MSBuild convention about DeviceSpecificIntermediateOutputPath.
Files not reviewed (1)
  • tools/mtouch/Errors.designer.cs: Language not supported
Comments suppressed due to low confidence (1)

eng/Version.Details.props:33

  • The top-level is missing its closing tag before starting the next (the file now has a nested PropertyGroup), which makes this XML invalid and will break MSBuild imports. Add the missing after the last property in the first group (after MicrosoftDotNetXHarnessiOSSharedPackageVersion).
    <MicrosofttvOSSdknet100_262PackageVersion>26.2.10223</MicrosofttvOSSdknet100_262PackageVersion>
    <!-- dotnet-xharness dependencies -->
    <MicrosoftDotNetXHarnessiOSSharedPackageVersion>10.0.0-prerelease.25516.4</MicrosoftDotNetXHarnessiOSSharedPackageVersion>
  <!--Property group for alternate package version names-->
  <PropertyGroup>
    <!-- dotnet-dotnet dependencies -->
    <MicrosoftDotNetArcadeSdkVersion>$(MicrosoftDotNetArcadeSdkPackageVersion)</MicrosoftDotNetArcadeSdkVersion>

You can also share your feedback on Copilot code review. Take the survey.

Comment thread tools/common/MachO.cs
Comment thread src/CoreGraphics/CGFont.cs Outdated
Comment thread tests/monotouch-test/CoreText/FontTest.cs
Comment thread tools/mtouch/Errors.resx
Comment thread src/Foundation/NSArray.cs
@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 force-pushed the dev/rolf/inline-dlfcn-net11.0 branch from fd820f0 to 297c02d Compare March 12, 2026 15:15
@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 force-pushed the dev/rolf/inline-dlfcn-net11.0 branch from 297c02d to 8bf1c02 Compare March 19, 2026 07:52
@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 force-pushed the dev/rolf/inline-dlfcn-net11.0 branch from 8bf1c02 to 8762e67 Compare April 24, 2026 09:00
@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.

@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 and others added 11 commits May 5, 2026 11:04
Reset patterns:
- global.json
- NuGet.config
- eng/Version.Details.xml
- eng/Version.Details.props
- eng/common/*
The previous fix unconditionally skipped adding inlined dlfcn P/Invoke
wrappers as required native symbols. This broke non-NativeAOT builds
because those wrappers are resolved via dlsym at runtime and need -u
flags to be exported from the binary. Restrict the skip to NativeAOT
builds only, where the wrappers are statically linked and don't need
force-linking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rolfbjarne rolfbjarne force-pushed the dev/rolf/inline-dlfcn-net11.0 branch from 6636edb to 49aab94 Compare May 5, 2026 17:24
@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
Copy link
Copy Markdown
Collaborator

✅ [CI Build #35e8d5d] Prepare .NET Release succeeded ✅

📦 Published NuGet packages (32 packages)

iOS

  • Microsoft.iOS.Ref.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.iOS.Runtime.ios-arm64.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.iOS.Runtime.ios.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.iOS.Runtime.iossimulator-arm64.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.iOS.Runtime.iossimulator-x64.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.iOS.Sdk.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.iOS.Templates.26.4.11551-net11-p5.nupkg
  • Microsoft.iOS.Windows.Sdk.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.NET.Sdk.iOS.Manifest-11.0.100-preview.5.26.4.11551-net11-p5.nupkg

MacCatalyst

  • Microsoft.MacCatalyst.Ref.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.MacCatalyst.Runtime.maccatalyst-arm64.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.MacCatalyst.Runtime.maccatalyst-x64.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.MacCatalyst.Runtime.maccatalyst.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.MacCatalyst.Sdk.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.MacCatalyst.Templates.26.4.11551-net11-p5.nupkg
  • Microsoft.NET.Sdk.MacCatalyst.Manifest-11.0.100-preview.5.26.4.11551-net11-p5.nupkg

macOS

  • Microsoft.macOS.Ref.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.macOS.Runtime.osx-arm64.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.macOS.Runtime.osx-x64.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.macOS.Runtime.osx.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.macOS.Sdk.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.macOS.Templates.26.4.11551-net11-p5.nupkg
  • Microsoft.NET.Sdk.macOS.Manifest-11.0.100-preview.5.26.4.11551-net11-p5.nupkg

tvOS

  • Microsoft.NET.Sdk.tvOS.Manifest-11.0.100-preview.5.26.4.11551-net11-p5.nupkg
  • Microsoft.tvOS.Ref.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.tvOS.Runtime.tvos-arm64.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.tvOS.Runtime.tvos.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.tvOS.Runtime.tvossimulator-arm64.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.tvOS.Runtime.tvossimulator-x64.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.tvOS.Sdk.net11.0_26.4.26.4.11551-net11-p5.nupkg
  • Microsoft.tvOS.Templates.26.4.11551-net11-p5.nupkg

Other

  • Sharpie.Bind.Tool.26.4.0.551-net11-p5.nupkg

Pipeline on Agent
Hash: 35e8d5d78122a504a63f072f42191473a8a21f26 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

…cn namespace

The InlineDlfcnMethodsStep now checks for [Field] attributes on the calling
method (or its property), and if the attribute has a second string argument
(the library name), uses that as the namespace for the Dlfcn type instead of
the calling type's namespace.

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

✅ [PR Build #747c09d] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 747c09d606a281446cca6944308c6bc273d7abf2 [PR build]

@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

✅ 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: 747c09d606a281446cca6944308c6bc273d7abf2 [PR build]

@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
Copy link
Copy Markdown
Collaborator

✅ [PR Build #1c0238c] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 1c0238cd909c986766658e9e453bcdfa7bc2fe4e [PR build]

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

✅ [PR Build #1c0238c] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 1c0238cd909c986766658e9e453bcdfa7bc2fe4e [PR build]

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

🔥 [CI Build #1c0238c] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

1 tests crashed, 15 tests failed, 169 tests passed.

Failures

❌ interdependent-binding-projects tests

2 tests failed, 2 tests passed.

Failed tests

  • interdependent-binding-projects/iOS - simulator/Debug: LaunchTimedOut
  • interdependent-binding-projects/tvOS - simulator/Debug: LaunchTimedOut

Html Report (VSDrops) Download

❌ monotouch tests (tvOS)

11 tests failed, 11 tests passed.

Failed tests

  • monotouch-test/tvOS - simulator/Debug: Failed
  • monotouch-test/tvOS - simulator/Debug (CoreCLR): Failed
  • monotouch-test/tvOS - simulator/Release (CoreCLR, ARM64): Failed
  • monotouch-test/tvOS - simulator/Release (CoreCLR, Universal): Failed
  • monotouch-test/tvOS - simulator/Debug (static registrar): Failed
  • monotouch-test/tvOS - simulator/Debug (ARM64): Failed
  • monotouch-test/tvOS - simulator/Debug (managed static registrar): Failed
  • monotouch-test/tvOS - simulator/Debug (trimmable static registrar): Failed
  • monotouch-test/tvOS - simulator/Debug (interpreter): Failed
  • monotouch-test/tvOS - simulator/Release (interpreter): Failed
  • monotouch-test/tvOS - simulator/Release (compat inline dlfcn): Failed

Html Report (VSDrops) Download

❌ windows tests

🔥 Failed catastrophically on VSTS: test results - windows (no summary found).

Html Report (VSDrops) Download

❌ xcframework tests

2 tests failed, 2 tests passed.

Failed tests

  • xcframework-test/iOS - simulator/Debug: LaunchTimedOut
  • xcframework-test/tvOS - simulator/Debug: LaunchTimedOut

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 (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
✅ introspection: All 9 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 22 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 25 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
✅ xtro: All 1 tests passed. (⚠️ Html Report Publish failed ⚠️) Download

macOS tests

✅ 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: 1c0238cd909c986766658e9e453bcdfa7bc2fe4e [PR build]

@rolfbjarne rolfbjarne closed this May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge Do not merge this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants