[net11.0] [tools/msbuild] Add InlineDlfcnMethodsStep as an opt-in custom linker step#24889
[net11.0] [tools/msbuild] Add InlineDlfcnMethodsStep as an opt-in custom linker step#24889rolfbjarne wants to merge 30 commits intonet11.0from
Conversation
rolfbjarne
commented
Mar 12, 2026
There was a problem hiding this comment.
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
Dlfcncalls 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.
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.
fd820f0 to
297c02d
Compare
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.
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.
297c02d to
8bf1c02
Compare
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.
8bf1c02 to
8762e67
Compare
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.
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.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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>
…rolf/inline-dlfcn-net11.0
6636edb to
49aab94
Compare
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.
✅ [CI Build #35e8d5d] Prepare .NET Release succeeded ✅📦 Published NuGet packages (32 packages)iOS
MacCatalyst
macOS
tvOS
Other
Pipeline on Agent |
This comment has been minimized.
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>
✅ [PR Build #747c09d] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #1c0238c] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #1c0238c] Build passed (Build macOS tests) ✅Pipeline on Agent |
🔥 [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 tests2 tests failed, 2 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (tvOS)11 tests failed, 11 tests passed.Failed tests
Html Report (VSDrops) Download ❌ windows tests🔥 Failed catastrophically on VSTS: test results - windows (no summary found). Html Report (VSDrops) Download ❌ xcframework tests2 tests failed, 2 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |