Skip to content

[net11.0] Merge main into net11.0. - #26408

Merged
rolfbjarne merged 25 commits into
net11.0from
dev/rolf/bump-main-in-net11.0-2026-08-05
Aug 7, 2026
Merged

rolfbjarne merged 25 commits into
net11.0from
dev/rolf/bump-main-in-net11.0-2026-08-05

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

No description provided.

rolfbjarne and others added 10 commits August 4, 2026 13:02
…#26377)

Several public APIs bind a native optional NSDictionary as a strongly-typed dictionary parameter, but the C# parameter itself was missing the `?` nullability annotation. In every case the code already handled null (via `param?.Dictionary`) and the underlying native API is `_Nullable` / `[NullAllowed]`, so the missing annotation was simply an oversight that surfaced unnecessary nullable-context warnings for callers passing `null`.

Adding the annotation is not a breaking change: it only makes the parameter more permissive, so existing callers keep compiling.

Fixed parameters:

* `CGContextPDF.BeginTag` (`CGPdfTagProperties`)
* `CIContext` constructor (`CIContextOptions`)
* `CIImage.FromProvider` and the `CIImage` constructor (`CIImageProviderOptions`)
* `UNNotificationAttachment.FromIdentifier` (`UNNotificationAttachmentOptions`)

While here, the placeholder XML docs on these APIs were filled in (and the two `CGContextPDF.BeginTag` overloads, previously undocumented, were documented and dropped from the cecil-tests documentation known-failures list).

I deliberately did not touch `CVPixelFormatDescription.Register`: its native API is `__nonnull` (the sibling `NSDictionary` overload throws on null), so its parameter is correctly non-nullable.

🤖 Pull request created by Copilot

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Convert five hand-written failable-initializer factory helpers to use the new bgen `[FactoryMethod]` attribute (added in #26196). Each conversion replaces an `[Internal] NativeHandle _InitWith...` helper plus a manual partial-class factory method with a `[FactoryMethod] [return: NullAllowed] NativeHandle Constructor (...)` in the binding definition, letting the generator emit the `public static T? Create (...)` factory. The manual partial-class files are deleted and their entries removed from `frameworks.sources`.

🤖 Pull request created by Copilot

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Express native constants for CFDictionary, CMTime, CMTimeRange, and cohesive analogous APIs as binding `[Field]` declarations instead of handwritten symbol-loading code.

Extend bgen with narrowly scoped support for:

- Native symbol addresses without pointer dereferencing.
- Named partial struct extensions.
- Required and optional unmanaged struct constants.

Preserve existing API shape, platform availability, nullability, mutability, and missing-symbol behavior. Add focused bgen and static-initialization regression coverage.

🤖 Pull request created by Copilot
…mbers = true)]. (#26362)

When the assembly preparer applies `[Preserve (AllMembers = true)]` (and when it preserves NSObject subclasses in user assemblies), it used to emit a single `[DynamicDependency (DynamicallyAccessedMemberTypes.…, typeof (TheType))]` attribute on the module constructor.

That's not equivalent to `[Preserve (AllMembers = true)]`: the trimmer resolves `DynamicallyAccessedMemberTypes` over the entire type hierarchy, so every member of every base type is preserved as well. For an NSObject subclass that means all of `NSObject` is preserved - and `NSObject` in turn drags in `NSNumber`, `NSValue`, `NSArray`, `ObjCRuntime.Messaging`, `System.Drawing.PointF/SizeF/ RectangleF` and, transitively, the `System.Drawing`, `System.Drawing.Primitives`, `System.ObjectModel` and `System.ComponentModel.TypeConverter` assemblies.

Emit one `DynamicDependency` attribute per member declared on the type instead, which matches `[Preserve (AllMembers = true)]` semantics exactly.

This only affects the assembly preparer (PrepareAssemblies=true); when our steps run inside ILLink we use an xml descriptor file, which already had the correct semantics.

Size impact for tests/dotnet/SizeTestApp/iOS (net11.0, ios-arm64, Release, CoreCLR + ReadyToRun, trimmable-static + PrepareAssemblies + PostProcessAssemblies):

| Configuration                       | App size     |
|-------------------------------------|--------------|
| Before                              | 11,523,224 B |
| After                               | 11,380,424 B |
| **Difference**                      | **-142,800 B (-1.24%)** |

which brings trimmable-static to within 0.38% of managed-static (11,337,504 B), down from 1.6%.

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Rolf Bjarne Kvinge <rokvin@microsoft.com>
…NET 11 (#26346)

On .NET 11+, default `Registrar` to `trimmable-static` (instead of `managed-static`) for NativeAOT, and enable the `PrepareAssemblies` / `PostProcessAssemblies` flow by default for NativeAOT.

All three are set at evaluation time (in `Xamarin.Shared.Sdk.props`) rather than in the `SelectRegistrar` target, because the static `_SkipILLink` / `_PostprocessAssembliesAfterIlc` gates read them at evaluation time. `PostProcessAssemblies` normally defaults to `$(PrepareAssemblies)` in `Xamarin.Shared.targets`, but that default runs later than the gate reads it, so the same default is applied here too.

This is a **no-op on .NET 10** — every condition requires `TargetFrameworkVersion >= 11.0`. Verified: all `AppSizeTest` NativeAOT and NativeAOT_TrimmableStatic expected sizes are unchanged on `main` (within ±5 bytes), so no expected files needed updating.

## Why NativeAOT only?

Because there would be a significant size regression with CoreCLR (fixes are in progress for this and the default will be changed for CoreCLR as well). Mono won't change to keep it as compatible as possible.

🤖 Pull request created by Copilot

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Improve XML documentation for:

- `AVAudioBuffer`
- `TimeSpec`
- `AdviceAttribute`
- `FIMenuKind`
- `SecStatusCodeExtensions`
- `RequiredFrameworkAttribute`
- `MLMediaSourceType`
- `SLRequestMethod`
- `MLMediaType`
- `SLComposeViewControllerResult`

Each type is documented in a separate commit.

🤖 Pull request created by Copilot

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…s. (#26363)

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.

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Rolf Bjarne Kvinge <rokvin@microsoft.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Improve XML documentation for:

- `NSZone`
- `GLKMesh`
- `MTKMesh`
- `HMService`
- `VTPropertyOptions`
- `VTUtilities`
- `INPriceRangeOption`
- `INPriceRange`
- `NSRunLoop`
- `NSRunLoopModeExtensions`

Each type is documented in a separate commit. The Cecil documentation baseline is updated for the newly documented `VTUtilities` API.

🤖 Pull request created by Copilot

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 5, 2026 15:23
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner August 5, 2026 15:23
@rolfbjarne
rolfbjarne enabled auto-merge August 5, 2026 15:23
@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Aug 5, 2026
@rolfbjarne rolfbjarne added do-not-merge Do not merge this pull request and removed ready-to-review This PR is ready to review/merge. labels Aug 5, 2026

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

Syncs the net11.0 branch with main, bringing in updates across the linker/registrar tooling, binding generation, documentation, and expected test baselines.

Changes:

  • Adds linker/registrar infrastructure updates (metadata-size reduction for generated methods and improved “preserve all members” handling).
  • Extends bgen [Field] generation (value-type field access via Dlfcn.GetStruct, and SymbolAddress support with validation + diagnostics).
  • Moves several manually-implemented “Create” helpers into binding definitions via [FactoryMethod], and updates xtro ignore lists + app-size/preserved-API baselines accordingly.

Reviewed changes

Copilot reviewed 98 out of 99 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/dotnet-linker/Steps/TrimmableRegistrarStep.cs Use unnamed generated parameters to shrink metadata
tools/dotnet-linker/Steps/ManagedRegistrarStep.cs Use unnamed generated parameters to shrink metadata
tools/dotnet-linker/Steps/ManagedRegistrarLookupTablesStep.cs Use unnamed generated parameters to shrink metadata
tools/dotnet-linker/RegistrarCompanionAssembly.cs Use unnamed generated parameter to shrink metadata
tools/dotnet-linker/MarkNSObjectsStep.cs Switch “preserve all members” to new helper path
tools/dotnet-linker/CecilExtensions.cs Add overload to add unnamed parameters
tools/dotnet-linker/ApplyPreserveAttributeStep.cs Route Preserve(AllMembers) through new helper path
tools/dotnet-linker/AppBundleRewriter.cs Add per-member DynamicDependency generation helper
tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-UIKit.ignore Remove ignore entry now bound
tests/xtro-sharpie/api-annotations-dotnet/iOS-UIKit.ignore Remove ignore entry now bound
tests/xtro-sharpie/api-annotations-dotnet/common-CoreVideo.ignore Remove ignore entries now bound
tests/xtro-sharpie/api-annotations-dotnet/common-CoreMedia.ignore Remove ignore entries now bound
tests/xtro-sharpie/api-annotations-dotnet/common-CoreFoundation.ignore Remove ignore entries now bound
tests/dotnet/UnitTests/expected/TVOS-NativeAOT-TrimmableStatic-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/TVOS-NativeAOT-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/TVOS-MonoVM-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/TVOS-MonoVM-interpreter-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/TVOS-CoreCLR-R2R-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/TVOS-CoreCLR-Interpreter-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/MacOSX-NativeAOT-TrimmableStatic-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/MacOSX-NativeAOT-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/MacOSX-CoreCLR-R2R-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/MacOSX-CoreCLR-Interpreter-TrimmableStatic-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/MacOSX-CoreCLR-Interpreter-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/MacCatalyst-NativeAOT-TrimmableStatic-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/MacCatalyst-NativeAOT-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/MacCatalyst-MonoVM-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/MacCatalyst-MonoVM-interpreter-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/MacCatalyst-CoreCLR-R2R-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/MacCatalyst-CoreCLR-Interpreter-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/iOS-NativeAOT-TrimmableStatic-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/iOS-NativeAOT-size.txt Update app-size baseline
tests/dotnet/UnitTests/expected/iOS-MonoVM-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/iOS-MonoVM-interpreter-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/iOS-CoreCLR-R2R-preservedapis.txt Update preserved-API baseline
tests/dotnet/UnitTests/expected/iOS-CoreCLR-Interpreter-preservedapis.txt Update preserved-API baseline
tests/cecil-tests/Test.cs Update backing-field expectations for new initialization pattern
tests/cecil-tests/Documentation.KnownFailures.txt Remove known-failure entries now documented/bound
tests/cecil-tests/ConstructorTest.KnownFailures.cs Remove known-failure entries now handled
tests/cecil-tests/ConstructorTest.cs Filter to visible ctors for error-out-parameter test
tests/bgen/tests/native-field-generation.cs Add test input for struct fields + symbol addresses
tests/bgen/ErrorTests.cs Add BI1128 regression test
tests/bgen/BGenTests.cs Add native field generation assertions
src/WebKit/WKWebExtensionMatchPattern.cs Remove manual factory wrapper (now generated)
src/webkit.cs Bind failable inits via [FactoryMethod] constructors
src/Vision/VNUtils.cs Remove manual field property (now generated)
src/vision.cs Add [Field] for VNNormalizedIdentityRect
src/VideoToolbox/VTUtilities.cs Improve XML docs + add docs for new API
src/VideoToolbox/VTPropertyOptions.cs Improve XML docs
src/UserNotifications/UNNotificationAttachment.cs Make options nullable + improve XML docs
src/UIKit/UITypes.cs Route pointer accessory positions through generated fields
src/UIKit/UIListSeparatorConfiguration.cs Remove manual constant wrapper (now generated)
src/uikit.cs Bind UIListSeparatorAutomaticInsets + add pointer position fields container
src/Social/Enums.cs Improve enum XML docs
src/SensitiveContentAnalysis/SCVideoStreamAnalyzer.cs Remove manual factory wrapper (now generated)
src/sensitivecontentanalysis.cs Bind failable init via [FactoryMethod] constructor
src/Security/SecStatusCodeExtensions.cs Improve type/method XML docs
src/Resources.resx Add BI1128 resource string
src/Resources.Designer.cs Add BI1128 strongly-typed resource accessor
src/ObjCRuntime/RequiredFrameworkAttribute.cs Improve XML docs
src/MetalPerformanceShaders/MPSKernel.cs Remove manual constant wrapper (now generated)
src/metalperformanceshaders.cs Bind MPSRectNoClip via [Field]
src/MetalKit/MTKMesh.cs Improve XML docs
src/MediaLibrary/Enums.cs Improve enum XML docs
src/Intents/INPriceRange.cs Improve XML docs + clarify exceptions
src/HomeKit/HMService.cs Improve XML docs for sync/async methods
src/GLKit/GLKMesh.cs Improve XML docs
src/frameworks.sources Remove deleted manual wrapper files from build lists
src/Foundation/NSZone.cs Improve XML docs
src/Foundation/NSRunLoop.cs Improve XML docs + add null-argument exception docs
src/Foundation/FieldAttribute.cs Add SymbolAddress property to [Field]
src/Foundation/AdviceAttribute.cs Improve XML docs
src/FinderSync/Enums.cs Improve enum XML docs
src/Darwin/TimeSpec.cs Improve struct XML docs
src/CoreVideo/CVTime.cs Use generated field accessors for CVTime constants
src/corevideo.cs Add CVTime field container for constants
src/CoreMedia/CoreMedia.cs Replace static ctor constant loads with generated fields
src/CoreMedia/CMTime.cs Replace static ctor constant loads with generated fields
src/coremedia.cs Add field containers for CMTime/CMTimeRange constants
src/CoreImage/CIImage.cs Make options nullable + improve docs
src/CoreImage/CIContext.cs Make options nullable + improve docs
src/CoreGraphics/CGRect.cs Use generated field accessors for CGRect constants
src/CoreGraphics/CGContextPDF.cs Make tag properties nullable + improve docs
src/coregraphics.cs Add CGRect field container
src/CoreFoundation/CFDictionary.cs Switch callback pointers to generated symbol-address fields
src/CoreFoundation/CFArray.cs Switch callback pointer to generated symbol-address field
src/corefoundation.cs Add symbol-address [Field]s for CFArray/CFDictionary callbacks
src/CoreAnimation/CAFrameRateRange.cs Use generated field accessor for default constant
src/coreanimation.cs Add CAFrameRateRange field container
src/bgen/Generator.cs Add SymbolAddress validation + struct-field generation + attribute emission
src/BackgroundAssets/BAAssetPackManifest.cs Remove manual factory wrapper (now generated)
src/backgroundassets.cs Bind failable inits via [FactoryMethod] constructors
src/AVKit/AVCaptureEventSound.cs Remove manual factory wrapper (now generated)
src/avkit.cs Bind failable init via [FactoryMethod] constructor
src/AVFoundation/AVSpeechSynthesisProviderAudioUnit.cs Remove manual factory wrapper (now generated)
src/AVFoundation/AVAudioBuffer.cs Improve XML docs
src/avfoundation.cs Bind failable init via [FactoryMethod] constructor
dotnet/targets/Xamarin.Shared.Sdk.props Change net11+ NativeAOT defaults (registrar + prepare/postprocess assemblies)
docs/website/generator-errors.md Add BI1128 documentation entry
Files not reviewed (1)
  • src/Resources.Designer.cs: Generated file

Comment thread docs/website/generator-errors.md Resolved
Comment thread dotnet/targets/Xamarin.Shared.Sdk.props Resolved
Comment thread src/corevideo.cs Resolved
…e-trim assemblies. (#26403)

The static registrar needs the protocol interface methods to figure out which selector an implicit protocol implementation should be registered with (the implementing method typically has no `[Export]` attribute of its own):

```csharp
class MyDataSource : NSObject, IUITableViewDataSource {
    // No [Export] here - the selector comes from IUITableViewDataSource.RowsInSection
    public nint RowsInSection (UITableView tableView, nint section) => 1;
}
```

The trimmer removes these interface methods, so `CollectUnmarkedMembersSubStep` stores them in the `DerivedLinkContext` for the registrar to use later. That handoff is in-memory, so it only works when the registrar runs in the same process as the trimmer - which isn't the case when post-processing assemblies.

The result was that no selector was registered at all for implicit protocol implementations in that flow, and calling the method from Objective-C failed with `unrecognized selector sent to instance`.

Look the missing methods up in the pre-trim assemblies instead, which we already have access to when post-processing assemblies (`GetProtocolMemberAttributes` already uses them to read `[ProtocolMember]` attributes that have been trimmed away).

### Testing

Verified on a branch where the trimmable-static registrar is the default for CoreCLR.

🤖 Pull request created by Copilot

---------

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

This comment has been minimized.

…polines. Fixes #25631.

Set the AssociatedSourceType field on the UnmanagedCallersOnly attributes the managed registrar emits, so the NativeAOT compiler (ILC) can drop a trampoline's native export when the associated type (the NSObject subclass declaring the exported method) can't be constructed.

Fixes #25631
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

❌ [CI Build #60f3ab0] Prepare .NET Release failed ❌

The following jobs reported a non-successful result:

Job Result
Sign NuGets ✅ Succeeded
Convert NuGet to MSI ✅ Succeeded
Push NuGets ❌ Failed
📦 Signed NuGet packages (32 packages)

iOS

  • Microsoft.iOS.Ref.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.iOS.Runtime.ios-arm64.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.iOS.Runtime.ios.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.iOS.Runtime.iossimulator-arm64.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.iOS.Runtime.iossimulator-x64.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.iOS.Sdk.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.iOS.Templates.26.5.12096-net11-rc.1.nupkg
  • Microsoft.iOS.Windows.Sdk.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.NET.Sdk.iOS.Manifest-11.0.100-preview.7.26.5.12096-net11-rc.1.nupkg

MacCatalyst

  • Microsoft.MacCatalyst.Ref.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.MacCatalyst.Runtime.maccatalyst-arm64.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.MacCatalyst.Runtime.maccatalyst-x64.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.MacCatalyst.Runtime.maccatalyst.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.MacCatalyst.Sdk.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.MacCatalyst.Templates.26.5.12096-net11-rc.1.nupkg
  • Microsoft.NET.Sdk.MacCatalyst.Manifest-11.0.100-preview.7.26.5.12096-net11-rc.1.nupkg

macOS

  • Microsoft.macOS.Ref.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.macOS.Runtime.osx-arm64.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.macOS.Runtime.osx-x64.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.macOS.Runtime.osx.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.macOS.Sdk.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.macOS.Templates.26.5.12096-net11-rc.1.nupkg
  • Microsoft.NET.Sdk.macOS.Manifest-11.0.100-preview.7.26.5.12096-net11-rc.1.nupkg

tvOS

  • Microsoft.NET.Sdk.tvOS.Manifest-11.0.100-preview.7.26.5.12096-net11-rc.1.nupkg
  • Microsoft.tvOS.Ref.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.tvOS.Runtime.tvos-arm64.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.tvOS.Runtime.tvos.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.tvOS.Runtime.tvossimulator-arm64.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.tvOS.Runtime.tvossimulator-x64.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.tvOS.Sdk.net11.0_26.5.26.5.12096-net11-rc.1.nupkg
  • Microsoft.tvOS.Templates.26.5.12096-net11-rc.1.nupkg

Other

  • Sharpie.Bind.Tool.26.6.0.700-net11-rc.1.nupkg

Pipeline on Agent
Hash: 60f3ab01a8102f8474b2680109b930aece1bff1a [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne removed the do-not-merge Do not merge this pull request label Aug 5, 2026
ErrorHelper.ShowInternal always logged through IToolLog.LogError, even for
warnings. That was mostly harmless when the log was the console (the message
text itself says "warning MTxxxx: ..."), but when the log is an MSBuild task -
which is the case for the assembly preparer (the PrepareAssemblies task, used
for NativeAOT) - every warning became an MSBuild error and failed the build.

This made it impossible to build monotouch-test for macOS with NativeAOT,
because the (correct) MT2387 warning about not being able to remove the dynamic
registrar failed the build:

    error : warning MT2387: It's not safe to remove the dynamic registrar,
    because monotouchtest references 'ObjCRuntime.Runtime.RegisterAssembly
    (System.Reflection.Assembly)'.

Use IToolLog.LogWarning for warnings instead, which each IToolLog
implementation already handles correctly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Five tests failed when running monotouch-test for macOS with
TEST_VARIATION=nativeaot. They all assert build-time behavior that no
longer applies in the NativeAOT + PrepareAssemblies flow on .NET 11+,
where ILLink isn't executed at all (ILC does all the trimming, see
'_SkipILLink' in Xamarin.Shared.Sdk.targets), and where monotouch-test
tells ILC to keep complete reflection metadata (NUnit requires
$(IlcGenerateCompleteTypeMetadata)=true and $(IlcTrimMetadata)=false).

* ProtocolTest.OnlyProtocol / ProtocolWithBaseType /
  ProtocolWithBaseTypeAndModel: the [Protocol] attributes are removed by
  a custom trimmer step (RemoveAttributesStep), which doesn't run when
  ILLink is skipped, so the attributes are still there. Added
  TestRuntime.IsILLinkSkipped and use it to expect the attributes.

* RegistrarTest.RegistrarRemoval: ILC trims all the dynamic registrar's
  code, but keeps the reflection metadata for its types (complete type
  metadata promotes any type referenced from a kept member, and
  ObjCRuntime.Runtime has a static field of type DynamicRegistrar). So
  looking for the types says nothing about the removal; verify that
  Runtime.DynamicRegistrationSupported is false instead.

* StrongEnumTest.GetConstant: reflection finds smart enum conversion
  methods ILC didn't generate any code for (the metadata is kept, the
  code isn't), and invoking those throws NotSupportedException. Skip
  such methods.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rolfbjarne
rolfbjarne requested a review from mauroa as a code owner August 6, 2026 05:45
@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Aug 6, 2026
@vs-mobiletools-engineering-service2

This comment has been minimized.

…tion.

The test failed when running monotouch-test for Mac Catalyst with
TEST_VARIATION=nativeaot: it expects all the members of
IUIApplicationDelegate to have been trimmed away, but they're still
there.

When using NativeAOT on .NET 11+, ILLink isn't executed at all (ILC does
all the trimming, see '_SkipILLink' in Xamarin.Shared.Sdk.targets), and
monotouch-test tells ILC to keep complete reflection metadata (NUnit
requires $(IlcGenerateCompleteTypeMetadata)=true and
$(IlcTrimMetadata)=false). This means that even though ILC trims away
the code, the reflection metadata for the members is still there, so
don't expect the members to be gone in that configuration.

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

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…emotely from Windows.

The custom linker options file is written by a `WriteLinesToFile` task that's
passed a `SessionId`, which means that when building remotely from Windows the
file is only written on the Mac.

That was fine as long as the only consumer was ILLink (which runs on the Mac),
but the `PrepareAssemblies` task isn't remoted (it doesn't need a Mac), so it
looks for the file on the local machine, and fails:

    Xamarin.Shared.targets(3703): error: Unexpected exception 'PrepareAssemblies': Could not find file 'obj\Release\net11.0-ios\ios-arm64\custom-linker-options.txt'.

This shows up in `DotNetProjectTest.PublishAotOnWindows`, because on .NET 11+
with NativeAOT + PrepareAssemblies, ILLink is skipped entirely, leaving
`PrepareAssemblies` as the only consumer of the file.

So write the file locally as well in that case. The contents are identical
either way, since all the properties are evaluated locally in both cases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b169a463-6209-484f-9a6a-cb4a0e13b000
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

The `PrepareAssemblies` task isn't remoted (it doesn't need a Mac), which means
it runs on Windows for remote builds. Two things went wrong there:

* `Application.GetRealPath` P/Invokes `realpath` in libc, which doesn't exist on
  Windows ("Unable to load DLL 'libc' or one of its dependencies"). It's hit
  early on, when setting the linker cache directory. There are no symlinks to
  resolve on Windows anyway, so just return the full path (this is what
  `PathUtils.ResolveSymbolicLinks` already does).

* `LinkerConfiguration` calls `Driver.ValidateXcode`, but the `SdkDevPath` value
  points to Xcode on the *Mac*, so validation would fail on Windows. Xcode only
  exists on macOS, so skip the validation there, and instead pass the Xcode
  version MSBuild already fetched from the Mac ($(_XcodeVersion)) as a new
  `XcodeVersion` linker option. The static registrar needs it.

Additionally, log the stack trace (and any inner exceptions) for unexpected
exceptions in `XamarinTask`. `TaskLoggingHelper.LogErrorFromException` doesn't
show the stack trace by default, which made the two failures above quite hard to
diagnose - the binlog only contained the exception message.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b169a463-6209-484f-9a6a-cb4a0e13b000
@vs-mobiletools-engineering-service2

This comment has been minimized.

When building remotely from Windows with NativeAOT, the assembly preparer runs
locally on Windows (the PrepareAssemblies task is not remoted), which means the
`linker-items/*.items` files it produces only exist on Windows. The
ReadItemsFromFile task, on the other hand, is remoted, and it returned false
from ShouldCopyToBuildServer for every file, so the files were never copied to
the Mac:

    error: MessagingRemoteException: An error occurred on client [...] while
    executing a reply for topic [...]ReadItemsFromFile
    DirectoryNotFoundException: Could not find a part of the path
    '/Users/builder/[...]/obj/Release/net11.0-ios/ios-arm64/linker-items/_MainFile.items'.

Copy the files that exist locally and are non-empty, which is the same approach
already used by CompileNativeCode, LinkNativeCode, ILStrip and others: an
existing, non-empty file was produced on Windows and has to be copied, while a
missing or 0-length file belongs to the Mac and must not overwrite it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b169a463-6209-484f-9a6a-cb4a0e13b000
@rolfbjarne
rolfbjarne disabled auto-merge August 6, 2026 17:45
@vs-mobiletools-engineering-service2

This comment has been minimized.

…msToBeCopied.

The previous attempt implemented ShouldCopyToBuildServer, but that callback is
never invoked for ReadItemsFromFile's 'File' property, because the remoting
infrastructure ignores [Output] properties when it computes the set of inputs to
copy to the build server (Xamarin.Messaging.Build.Client.TaskRunner):

    var isOutput = p.GetCustomAttributes (typeof (OutputAttribute), true).Any ();
    var include = isOutput ? false : p.CanWrite;
    if (!IsBuiltinTaskType (p.DeclaringType) && include)
        yield return p;

'File' is declared [Output] (as well as [Required]), so it was filtered out and
the files were still missing on the Mac:

    error: MessagingRemoteException [...] ReadItemsFromFile
    DirectoryNotFoundException: Could not find a part of the path
    '/Users/builder/[...]/linker-items/_MainFile.items'.

Report the files from GetAdditionalItemsToBeCopied instead, which TaskRunner
appends to the list of items to copy after the ShouldCopyToBuildServer filter,
and which doesn't care about [Output]. Keep the same "exists and is non-empty"
condition, and keep ShouldCopyToBuildServer consistent with it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b169a463-6209-484f-9a6a-cb4a0e13b000
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…g from Windows.

With the previous fix the linker item files make it to the Mac, and the build
gets as far as compiling the generated registrar code, which then fails:

    error: clang exited with code 1:
    .../linker-cache/registrar.mm:2:10: fatal error: 'registrar.h' file not found

registrar.mm and registrar.h are both generated by the assembly preparer, which
runs locally on Windows (the PrepareAssemblies task is not remoted). registrar.mm
is copied to the Mac because it's an item in CompileNativeCode's CompileInfo, but
registrar.h is only ever referenced by the '#include "registrar.h"' in the
generated code, so nothing copied it.

Add an 'AdditionalDependencies' metadata to the _RegistrarFile item pointing at
the generated header, and make CompileNativeCode copy any file listed there to
the build server. This is a generic mechanism: any source file can now declare
the extra files it needs in order to compile.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b169a463-6209-484f-9a6a-cb4a0e13b000
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…mpty.

When building remotely from Windows, the additional dependencies of a native
source file (the registrar's header file, in particular) were copied to the Mac
whenever a file existed at the corresponding path on Windows.

That's wrong when the file was in fact created on the Mac: the remoting
infrastructure leaves behind a 0-length placeholder on Windows for such files,
and copying that placeholder back to the Mac overwrote the real file. This broke
every remote Windows build where the linker (and thus the registrar) runs on the
Mac, with errors like:

    registrar.mm:104:22: error: variable has incomplete type 'struct objc_super'

Use the same filter as for every other input instead (the file must exist *and*
be non-empty), which is exactly what ShouldCopyToBuildServer already implements.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b169a463-6209-484f-9a6a-cb4a0e13b000
@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: dc19646aedde663f4aa07dd252c161d7675d9fa3 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #dc19646] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 260 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 7 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 31 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 31 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 31 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 24 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 24 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 24 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 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: dc19646aedde663f4aa07dd252c161d7675d9fa3 [PR build]

@rolfbjarne
rolfbjarne merged commit 21edc1a into net11.0 Aug 7, 2026
54 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/bump-main-in-net11.0-2026-08-05 branch August 7, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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