Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b89cd96
[src] Add missing nullability to strongly-typed dictionary parameters…
rolfbjarne Aug 4, 2026
16b3170
[src] Convert manual binding factories to [FactoryMethod] (#26376)
rolfbjarne Aug 4, 2026
b7caf07
[src] Generate remaining native constant accessors (#26367)
rolfbjarne Aug 4, 2026
d17ed03
[dotnet-linker] Don't preserve base type members for [Preserve (AllMe…
rolfbjarne Aug 4, 2026
aed6558
[dotnet] Default to the trimmable-static registrar for NativeAOT on .…
rolfbjarne Aug 4, 2026
a47ea1a
[docs] Improve XML docs for ten types (#26399)
rolfbjarne Aug 4, 2026
93f9d03
[dotnet-linker] Don't emit parameter names for generated proxy method…
rolfbjarne Aug 5, 2026
b354695
[docs] Improve XML docs for ten types (#26402)
rolfbjarne Aug 5, 2026
1c5afd0
[net11.0] Merge main into net11.0.
rolfbjarne Aug 5, 2026
55c5cee
[tests] Update expected sizes.
rolfbjarne Aug 5, 2026
301fbb1
[registrar] Look up trimmed-away protocol interface methods in the pr…
rolfbjarne Aug 5, 2026
3fb9479
[dotnet-linker] Set AssociatedSourceType on UnmanagedCallersOnly tram…
rolfbjarne Aug 5, 2026
acb6d65
Merge remote-tracking branch 'origin/main' into dev/rolf/bump-main-in…
rolfbjarne Aug 5, 2026
fe8ea7f
[tests] Update expected sizes.
rolfbjarne Aug 5, 2026
747470c
[tools] Report warnings as warnings in ErrorHelper.ShowInternal.
rolfbjarne Aug 5, 2026
d556da5
[nativeaot] Fix building apps with the trimmable static registrar.
rolfbjarne Aug 5, 2026
5a9d3d7
[tests] Fix monotouch-test failures in the NativeAOT variation on macOS.
rolfbjarne Aug 5, 2026
185ba62
[tests] Update known test warnings.
rolfbjarne Aug 6, 2026
4fd25b3
[tests] Fix RegistrarTest.ProtocolsTrimmedAway in the NativeAOT varia…
rolfbjarne Aug 6, 2026
63687e0
[dotnet] Write the custom linker options file locally when building r…
rolfbjarne Aug 6, 2026
c5bc505
[dotnet] Make the assembly preparer work when it runs on Windows.
rolfbjarne Aug 6, 2026
cde4ac8
[msbuild] Copy the linker item files to the Mac in ReadItemsFromFile.
rolfbjarne Aug 6, 2026
4f8f722
[msbuild] Copy the linker item files to the Mac from GetAdditionalIte…
rolfbjarne Aug 6, 2026
70705b8
[msbuild] Copy the generated registrar header to the Mac when buildin…
rolfbjarne Aug 6, 2026
dc19646
[msbuild] Only copy an additional dependency to the Mac if it's non-e…
rolfbjarne Aug 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/code/class-handles.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,10 @@ So we do the following:
3. The `_PostTrimmingProcessing` MSBuild target takes the surviving symbols
from either path, generates the corresponding native Objective-C code, and
adds it to the list of files to compile and link into the final executable.

Note that the generated native code contains a direct reference to each surviving
Objective-C class, so the native registrar must register any such class, even when
ILC trimmed away all the trampolines for the corresponding managed type (otherwise
the reference would turn into a hard link error). This is why the surviving class
names are also passed to the registrar when the native registrar code is generated
after ILC (see `Application.ClassesReferencedByInlinedClassGetHandle`).
2 changes: 2 additions & 0 deletions docs/website/generator-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ explicit name in the attribute is confusing and redundant.
To fix this error, remove the method name from the `[FactoryMethod]` attribute,
and rename the binding method if a different factory method name is desired.

### <a name='BI1128'/>BI1128: The [Field] member '\*.\*' sets SymbolAddress, but its type is '\*'; only System.IntPtr is supported.

Comment thread
rolfbjarne marked this conversation as resolved.
Resolved
<!-- 2xxx: reserved -->
<!-- 3xxx: reserved -->
<!-- 4xxx: reserved -->
Expand Down
29 changes: 29 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,35 @@
-->
<_UseNativeAot Condition="'$(PublishAot)' == 'true' And '$(_IsPublishing)' == 'true'">true</_UseNativeAot>

<!--
On .NET 11+, make the trimmable-static registrar the default for NativeAOT (it used to be
managed-static). This has to be set here, at evaluation time, and not only in the SelectRegistrar
target (which runs later), because the static _SkipILLink / _PostprocessAssembliesAfterIlc gates
check the registrar at evaluation time.

This is deliberately scoped to NativeAOT: the trimmable-static registrar only produces a *smaller*
app under NativeAOT (where the TypeMap feature and the post-ILC registrar reorder let us trim the
registered binding surface). On Mono/CoreCLR the trimmable-static registrar keeps the whole
registered NSObject surface and makes apps 2-3x *larger*, so those runtimes keep managed-static.
-->
<Registrar Condition="'$(Registrar)' == '' And '$(_UseNativeAot)' == 'true' And $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '11.0'))">trimmable-static</Registrar>

<!--
Enable the PrepareAssemblies flow by default for NativeAOT on .NET 11+. This runs our custom linker
steps in the assembly-preparer, and for the (NativeAOT-default) trimmable-static registrar it also
generates the native static registrar code *after* the NativeAOT compiler (ILC) has run (see
_PostprocessAssembliesAfterIlc), so the registrar can drop the native code for UnmanagedCallersOnly
trampolines ILC trimmed away (an app-size optimization).
-->
<PrepareAssemblies Condition="'$(PrepareAssemblies)' == '' And '$(_UseNativeAot)' == 'true' And $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '11.0'))">true</PrepareAssemblies>

<!--
PostProcessAssemblies defaults to $(PrepareAssemblies) (see Xamarin.Shared.targets), but the static
_PostprocessAssembliesAfterIlc gate reads it at evaluation time - earlier than that default runs - so
apply the same $(PrepareAssemblies) default here too, otherwise the gate wouldn't see it.
-->
<PostProcessAssemblies Condition="'$(PostProcessAssemblies)' == '' And '$(_UseNativeAot)' == 'true' And $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '11.0'))">$(PrepareAssemblies)</PostProcessAssemblies>
Comment thread
rolfbjarne marked this conversation as resolved.
Resolved

<UseMonoRuntime Condition=" '$(UseMonoRuntime)' == ''">false</UseMonoRuntime>

<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(MSBuildThisFileDirectory)Microsoft.$(_PlatformName).Sdk.targets</AfterMicrosoftNETSdkTargets>
Expand Down
13 changes: 13 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@
WarnAsError=$(_BundlerWarnAsError)
XamarinNativeLibraryDirectory=$(_XamarinNativeLibraryDirectory)
XamarinRuntime=$(_XamarinRuntime)
XcodeVersion=$(_XcodeVersion)
</_CustomLinkerOptions>
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --custom-data "LinkerOptionsFile=$(_CustomLinkerOptionsFile)"</_ExtraTrimmerArgs>
<_ExtraTrimmerArgs Condition="'$(TrimMode)' == 'copy' And '$(MarkCopiedAssemblies)' != 'true'">$(_ExtraTrimmerArgs) --custom-data DisableMarkingOfCopyAssemblies=true</_ExtraTrimmerArgs>
Expand Down Expand Up @@ -1060,6 +1061,18 @@
File="$(_CustomLinkerOptionsFile)"
Lines="$(_CustomLinkerOptions)"
Overwrite="true" />

<!--
When building remotely from Windows, the task above writes the file on the Mac (because it's passed
a SessionId), but the PrepareAssemblies task isn't remoted, so it needs the file on the local machine
as well. Write it locally too in that case (the contents are identical, since all the properties are
evaluated locally in either case).
-->
<WriteLinesToFile
Condition="'$(IsMacEnabled)' == 'true' And '$(BuildSessionId)' != '' And '$(PrepareAssemblies)' == 'true'"
File="$(_CustomLinkerOptionsFile)"
Lines="$(_CustomLinkerOptions)"
Overwrite="true" />
</Target>

<!--
Expand Down
15 changes: 15 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileNativeCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied ()
}
}
}

// Any files the source files need in order to compile (headers they #include,
// for instance) have to be copied to the Mac as well. Use the same filter as for
// any other input: if the local file doesn't exist or is empty, then it's the
// Mac's version that's the real one, and it must not be overwritten.
foreach (var info in CompileInfo) {
var dependencies = info.GetMetadata ("AdditionalDependencies");
if (string.IsNullOrEmpty (dependencies))
continue;
foreach (var dependency in dependencies.Split (new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries)) {
var item = new TaskItem (dependency);
if (ShouldCopyToBuildServer (item))
yield return item;
}
}
}

public void Cancel ()
Expand Down
6 changes: 6 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/PrepareAssemblies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public override bool Execute ()
survivingSymbols.Add (name);
}
preparer.Configuration.Application.SurvivingTrampolineSymbols = survivingSymbols;

// A class whose trampolines were all trimmed away by ILC must still be registered if
// managed code that survived ILC looks up its class handle, because the generated
// inlined Class.GetHandle native code references the Objective-C class.
var referencedClasses = new HashSet<string> (CollectPostILTrimInformation.FilterToClassSymbols (Xamarin.StaticLibrary.GetUnresolvedSymbols (NativeAOTObjectFile)));
preparer.Configuration.Application.ClassesReferencedByInlinedClassGetHandle = referencedClasses;
}
rv = preparer.PostProcess (out exceptions);
} else {
Expand Down
25 changes: 23 additions & 2 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/ReadItemsFromFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,31 @@ ITaskItem CreateItemFromElement (XElement element, string sourceFile)
return item;
}

public bool ShouldCopyToBuildServer (ITaskItem item) => false;
public bool ShouldCopyToBuildServer (ITaskItem item) => ShouldCopyFileToBuildServer (item);

public bool ShouldCreateOutputFile (ITaskItem item) => false;

public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
// The 'File' property is the input we need on the Mac, but it's declared as an
// [Output] property, and the remoting infrastructure never copies [Output]
// properties to the build server. Report the files here instead, because
// GetAdditionalItemsToBeCopied is copied unconditionally.
public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied ()
{
return File.Where (ShouldCopyFileToBuildServer);
}

static bool ShouldCopyFileToBuildServer (ITaskItem item)
{
// Some of these files are created on the Mac (by the linker), and in that case
// we either don't have the file on Windows at all, or we have a 0-length
// placeholder, and we don't want to overwrite the Mac's version with that.
// However, some of these files are created on Windows (by the assembly
// preparer, which doesn't run on the Mac), and those have to be copied to the
// Mac, otherwise they won't be there when this task executes remotely.
var finfo = new FileInfo (item.ItemSpec);
if (!finfo.Exists || finfo.Length == 0)
return false;
return true;
}
}
}
2 changes: 1 addition & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void ICustomLogger.LogError (string message, Exception? ex)
if (ex is ProductException pe) {
LogDiagnostic (pe);
} else if (ex is not null) {
Log.LogErrorFromException (ex);
Log.LogErrorFromException (ex, showStackTrace: true, showDetail: true, file: null);
}
}

Expand Down
9 changes: 3 additions & 6 deletions src/AVFoundation/AVAudioBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@

namespace AVFoundation {
/// <summary>A buffer for audio data.</summary>
/// <remarks>To be added.</remarks>
/// <related type="externalDocumentation" href="https://developer.apple.com/documentation/avfaudio/avaudiobuffer">Apple documentation for <c>AVAudioBuffer</c></related>
public partial class AVAudioBuffer {
/// <summary>To be added.</summary>
/// <value>To be added.</value>
/// <remarks>To be added.</remarks>
/// <summary>Gets the audio buffer list containing the buffer's audio data.</summary>
/// <value>The audio buffer list.</value>
public AudioBuffers AudioBufferList {
get {
return new AudioBuffers (audioBufferList);
}
}

/// <summary>Gets a mutable version of the underlying <see cref="AudioToolbox.AudioBuffers" />.</summary>
/// <value>To be added.</value>
/// <remarks>To be added.</remarks>
/// <value>The mutable audio buffer list.</value>
public AudioBuffers MutableAudioBufferList {
get {
return new AudioBuffers (mutableAudioBufferList);
Expand Down
27 changes: 0 additions & 27 deletions src/AVFoundation/AVSpeechSynthesisProviderAudioUnit.cs

This file was deleted.

23 changes: 0 additions & 23 deletions src/AVKit/AVCaptureEventSound.cs

This file was deleted.

37 changes: 0 additions & 37 deletions src/BackgroundAssets/BAAssetPackManifest.cs

This file was deleted.

5 changes: 3 additions & 2 deletions src/CoreAnimation/CAFrameRateRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#nullable enable

namespace CoreAnimation {
/// <summary>Specifies minimum, maximum, and preferred frame rates.</summary>
[SupportedOSPlatform ("tvos15.0")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios15.0")]
Expand All @@ -24,8 +25,8 @@ public bool IsEqualTo (CAFrameRateRange other)
=> IsEqualTo (this, other) != 0;

#if !COREBUILD
[Field ("CAFrameRateRangeDefault", "CoreAnimation")]
public static CAFrameRateRange Default => Marshal.PtrToStructure<CAFrameRateRange> (Dlfcn.GetIndirect (Libraries.CoreAnimation.Handle, "CAFrameRateRangeDefault"))!;
/// <summary>Gets the default frame-rate range.</summary>
public static CAFrameRateRange Default => CAFrameRateRangeFields.Default;
#endif

}
Expand Down
11 changes: 1 addition & 10 deletions src/CoreFoundation/CFArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,7 @@ internal CFArray (NativeHandle handle, bool owns)
[DllImport (Constants.CoreFoundationLibrary, EntryPoint = "CFArrayGetTypeID")]
internal extern static /* CFTypeID */ nint GetTypeID ();

// pointer to a const struct (REALLY APPLE?)
static IntPtr kCFTypeArrayCallbacks_ptr_value;
static IntPtr kCFTypeArrayCallbacks_ptr {
get {
// FIXME: right now we can't use [Fields] for GetIndirect
if (kCFTypeArrayCallbacks_ptr_value == IntPtr.Zero)
kCFTypeArrayCallbacks_ptr_value = Dlfcn.GetIndirect (Libraries.CoreFoundation.Handle, "kCFTypeArrayCallBacks");
return kCFTypeArrayCallbacks_ptr_value;
}
}
static IntPtr kCFTypeArrayCallbacks_ptr = _CFTypeArrayCallbacks;

internal static CFArray FromIntPtrs (params NativeHandle [] values)
{
Expand Down
16 changes: 6 additions & 10 deletions src/CoreFoundation/CFDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@

namespace CoreFoundation {

class CFDictionary : NativeObject {
public static IntPtr KeyCallbacks;
public static IntPtr ValueCallbacks;
partial class CFDictionary : NativeObject {
/// <summary>The address of the Core Foundation callback table used for dictionary keys.</summary>
public static IntPtr KeyCallbacks = _KeyCallbacks;

/// <summary>The address of the Core Foundation callback table used for dictionary values.</summary>
public static IntPtr ValueCallbacks = _ValueCallbacks;

[Preserve (Conditional = true)]
internal CFDictionary (NativeHandle handle, bool owns)
Expand All @@ -45,13 +48,6 @@ internal CFDictionary (NativeHandle handle, bool owns)
[DllImport (Constants.CoreFoundationLibrary, EntryPoint = "CFDictionaryGetTypeID")]
public extern static nint GetTypeID ();

static CFDictionary ()
{
var lib = Libraries.CoreFoundation.Handle;
KeyCallbacks = Dlfcn.GetIndirect (lib, "kCFTypeDictionaryKeyCallBacks");
ValueCallbacks = Dlfcn.GetIndirect (lib, "kCFTypeDictionaryValueCallBacks");
}

public static CFDictionary FromObjectAndKey (INativeObject obj, INativeObject key)
{
CFDictionary result = new CFDictionary (CFDictionaryCreate (IntPtr.Zero, new IntPtr [] { key.Handle }, new IntPtr [] { obj.Handle }, 1, KeyCallbacks, ValueCallbacks), true);
Expand Down
12 changes: 10 additions & 2 deletions src/CoreGraphics/CGContextPDF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,21 +414,29 @@ public void SetDestination (string name, CGRect rect)
[DllImport (Constants.CoreGraphicsLibrary)]
static extern void CGPDFContextBeginTag (/* CGContextRef* */ IntPtr context, CGPdfTagType tagType, /* CFDictionaryRef* _Nullable */ IntPtr tagProperties);

/// <summary>Opens a tagged content sequence of the specified <paramref name="tagType" /> in the PDF context.</summary>
/// <param name="tagType">The type of the tag to open.</param>
/// <param name="tagProperties">A dictionary of properties for the tag, or <see langword="null" /> if there are none.</param>
/// <remarks>Every call to <c>BeginTag</c> must be balanced by a matching call to <see cref="EndTag" />.</remarks>
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("maccatalyst")]
public void BeginTag (CGPdfTagType tagType, NSDictionary tagProperties)
public void BeginTag (CGPdfTagType tagType, NSDictionary? tagProperties)
{
CGPDFContextBeginTag (Handle, tagType, tagProperties.GetHandle ());
GC.KeepAlive (tagProperties);
}

/// <summary>Opens a tagged content sequence of the specified <paramref name="tagType" /> in the PDF context.</summary>
/// <param name="tagType">The type of the tag to open.</param>
/// <param name="tagProperties">The properties for the tag, or <see langword="null" /> if there are none.</param>
/// <remarks>Every call to <c>BeginTag</c> must be balanced by a matching call to <see cref="EndTag" />.</remarks>
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("maccatalyst")]
public void BeginTag (CGPdfTagType tagType, CGPdfTagProperties tagProperties)
public void BeginTag (CGPdfTagType tagType, CGPdfTagProperties? tagProperties)
{
var d = tagProperties?.Dictionary;
CGPDFContextBeginTag (Handle, tagType, d.GetHandle ());
Expand Down
14 changes: 2 additions & 12 deletions src/CoreGraphics/CGRect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,10 @@ public struct CGRect : IEquatable<CGRect> {

#if !COREBUILD
/// <summary>Gets an invalid, or null, rectangle.</summary>
/// <value>To be added.</value>
/// <remarks>To be added.</remarks>
[Field ("CGRectNull", "CoreGraphics")] // unused but helps xtro
public static CGRect Null {
get { return Dlfcn.GetCGRect (Libraries.CoreGraphics.Handle, "CGRectNull"); }
}
public static CGRect Null => CGRectFields.Null;

/// <summary>Gets an infinitely large rectangle.</summary>
/// <value>To be added.</value>
/// <remarks>To be added.</remarks>
[Field ("CGRectInfinite", "CoreGraphics")] // unused but helps xtro
public static CGRect Infinite {
get { return Dlfcn.GetCGRect (Libraries.CoreGraphics.Handle, "CGRectInfinite"); }
}
public static CGRect Infinite => CGRectFields.Infinite;

public static bool operator == (CGRect left, CGRect right)
{
Expand Down
Loading