Skip to content

Commit 02fe91b

Browse files
authored
[xcode16] Merge main into xcode16. (#21164)
2 parents ea8310c + ae99651 commit 02fe91b

File tree

17 files changed

+344
-73
lines changed

17 files changed

+344
-73
lines changed

Make.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ INCLUDE_TVOS=1
321321
INCLUDE_MACCATALYST=1
322322
INCLUDE_DEVICE=1
323323
INCLUDE_DOTNET_WATCHOS=
324-
INCLUDE_XAMARIN_LEGACY=1
324+
INCLUDE_XAMARIN_LEGACY=
325325
INCLUDE_HOTRESTART=1
326326

327327
ENABLE_DOTNET=1

NuGet.config

-23
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,13 @@
3232
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" protocolVersion="3" />
3333
<add key="Dotnet arcade" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
3434
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
35-
<!-- We've dropped support for .NET 6, but let's keep the feed in for a little while longer to make sure it's dropped throughout our entire stack and the lack of this feed doesn't break our build. -->
36-
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
3735
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
3836
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
3937
<!-- dotnet8-transport is required for Microsoft.DotNet.Cecil -->
4038
<add key="dotnet8-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8-transport/nuget/v3/index.json" />
4139
<add key="macios-dependencies" value="https://pkgs.dev.azure.com/xamarin/public/_packaging/macios-dependencies/nuget/v3/index.json" />
4240
<add key="xamarin-impl" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json" />
4341
<add key="local-tests-feed" value="tests/.nuget/packages" />
44-
<!-- These feeds are from main (6.0.4xx runtime branch) to get 6.0.9 versions of numerous .NET 6 packages. It should be possible to remove this after a while. -->
45-
<add key="darc-pub-dotnet-emsdk-3f6c45a" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-3f6c45a2/nuget/v3/index.json" />
46-
<add key="darc-pub-dotnet-runtime-531f715" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-531f715f/nuget/v3/index.json" />
47-
<!-- Need 6.0.10 feeds too -->
48-
<add key="darc-pub-dotnet-runtime-8c6bcad" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-8c6bcad1/nuget/v3/index.json" />
49-
<!-- And a 6.0.11 feed -->
50-
<add key="darc-pub-dotnet-runtime-f2980ae" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-f2980ae1/nuget/v3/index.json" />
51-
<!-- And a 6.0.12 feed -->
52-
<add key="darc-pub-dotnet-runtime-15d285f" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-15d285f3/nuget/v3/index.json" />
53-
<!-- Add a 6.0.13 feed -->
54-
<add key="darc-pub-dotnet-runtime-de84cf9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-d5edd29b-1/nuget/v3/index.json" />
55-
<!-- Add a 6.0.14 feed -->
56-
<add key="darc-pub-dotnet-runtime-2e45bc7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-2e45bc7a/nuget/v3/index.json" />
57-
<!-- Add a 7.0.11 feed -->
58-
<add key="darc-pub-dotnet-runtime-0ece505" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-0ece5051/nuget/v3/index.json" />
59-
<!-- Add a 7.0.17 feed -->
60-
<add key="darc-pub-dotnet-runtime-21f293d" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-21f293d8/nuget/v3/index.json" />
61-
<!-- Add a 7.0.18 feed -->
62-
<add key="darc-pub-dotnet-runtime-b6e8c6a" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-b6e8c6a6/nuget/v3/index.json" />
63-
<!-- Add a 7.0.19 feed -->
64-
<add key="darc-pub-dotnet-runtime-397f9ea" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-397f9eac/nuget/v3/index.json" />
6542
<!-- Add a 7.0.20 feed -->
6643
<add key="darc-pub-dotnet-runtime-fd36db5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-fd36db5f/nuget/v3/index.json" />
6744
</packageSources>

src/Network/NWConnection.cs

+13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#nullable enable
1010

1111
using System;
12+
using System.ComponentModel;
1213
using System.Runtime.InteropServices;
1314
using ObjCRuntime;
1415
using Foundation;
@@ -157,8 +158,20 @@ static void TrampolineBooleanChangeHandler (IntPtr block, byte value)
157158
[DllImport (Constants.NetworkLibrary)]
158159
static extern unsafe void nw_connection_set_viability_changed_handler (IntPtr handle, void* callback);
159160

161+
#if !XAMCORE_5_0
162+
[Obsolete ("Use 'SetViabilityChangeHandler' instead.")]
163+
[EditorBrowsable (EditorBrowsableState.Never)]
160164
[BindingImpl (BindingImplOptions.Optimizable)]
161165
public unsafe void SetBooleanChangeHandler (Action<bool> callback)
166+
{
167+
SetViabilityChangeHandler (callback);
168+
}
169+
#endif // !XAMCORE_5_0
170+
171+
/// <summary>Set a handler that is called when data can be sent or received.</summary>
172+
/// <param name="callback">The callback to call when data can be sent or received.</param>
173+
[BindingImpl (BindingImplOptions.Optimizable)]
174+
public unsafe void SetViabilityChangeHandler (Action<bool> callback)
162175
{
163176
if (callback is null) {
164177
nw_connection_set_viability_changed_handler (GetCheckedHandle (), null);

src/bgen/Generator.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,14 @@ public TrampolineInfo MakeTrampoline (Type t)
718718
}
719719
}
720720

721+
if (pi.ParameterType.IsPointer && pi.ParameterType.GetElementType ().IsValueType) {
722+
// Technically we should only allow blittable types here, but the C# compiler shows an error later on if any non-blittable types
723+
// are used, because this ends up in the signature of a UnmanagedCallersOnly method.
724+
pars.Add (new TrampolineParameterInfo (TypeManager.FormatType (null, pi.ParameterType), safe_name));
725+
invoke.Append (safe_name);
726+
continue;
727+
}
728+
721729
if (pi.ParameterType.IsSubclassOf (TypeCache.System_Delegate)) {
722730
if (!delegate_types.ContainsKey (pi.ParameterType.Name)) {
723731
delegate_types [pi.ParameterType.FullName] = pi.ParameterType.GetMethod ("Invoke");
@@ -4556,8 +4564,8 @@ void GenerateMethod (MemberInformation minfo)
45564564
argCount++;
45574565
}
45584566
if (minfo.Method.GetParameters ().Length != argCount) {
4559-
ErrorHelper.Warning (1105,
4560-
minfo.selector, argCount, minfo.Method, minfo.Method.GetParameters ().Length);
4567+
exceptions.Add (ErrorHelper.CreateWarning (1105,
4568+
minfo.selector, argCount, minfo.Method, minfo.Method.GetParameters ().Length));
45614569
}
45624570
}
45634571

@@ -4732,11 +4740,13 @@ group fullname by ns into g
47324740
print ("[MonoNativeFunctionWrapper]\n");
47334741

47344742
var accessibility = mi.DeclaringType.IsInternal (this) ? "internal" : "public";
4735-
print ("{3} delegate {0} {1} ({2});",
4743+
var isUnsafe = mi.GetParameters ().Any ((v => v.ParameterType.IsPointer)) || mi.ReturnType.IsPointer;
4744+
print ("{3}{4} delegate {0} {1} ({2});",
47364745
TypeManager.RenderType (mi.ReturnType, mi.ReturnTypeCustomAttributes),
47374746
shortName,
47384747
RenderParameterDecl (mi.GetParameters ()),
4739-
accessibility);
4748+
accessibility,
4749+
isUnsafe ? " unsafe" : string.Empty);
47404750
}
47414751

47424752
if (group.Namespace is not null) {
@@ -5075,6 +5085,7 @@ void GenerateProtocolTypes (Type type, string class_visibility, string TypeName,
50755085
foreach (var docId in docIds) {
50765086
print ($"[DynamicDependencyAttribute (\"{docId}\")]");
50775087
}
5088+
print ("[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]");
50785089
print ($"static I{TypeName} ()");
50795090
print ("{");
50805091
print ("\tGC.KeepAlive (null);"); // need to do _something_ (doesn't seem to matter what), otherwise the static cctor (and the DynamicDependency attributes) are trimmed away.

tests/cecil-tests/Documentation.KnownFailures.txt

-1
Original file line numberDiff line numberDiff line change
@@ -43619,7 +43619,6 @@ M:Network.NWConnection.Send(System.Byte[],System.Int32,System.Int32,Network.NWCo
4361943619
M:Network.NWConnection.SendIdempotent(CoreFoundation.DispatchData,Network.NWContentContext,System.Boolean)
4362043620
M:Network.NWConnection.SendIdempotent(System.Byte[],Network.NWContentContext,System.Boolean)
4362143621
M:Network.NWConnection.SetBetterPathAvailableHandler(System.Action{System.Boolean})
43622-
M:Network.NWConnection.SetBooleanChangeHandler(System.Action{System.Boolean})
4362343622
M:Network.NWConnection.SetPathChangedHandler(System.Action{Network.NWPath})
4362443623
M:Network.NWConnection.SetQueue(CoreFoundation.DispatchQueue)
4362543624
M:Network.NWConnection.SetStateChangeHandler(System.Action{Network.NWConnectionState,Network.NWError})

tests/common/shared-dotnet.mk

+20-14
Original file line numberDiff line numberDiff line change
@@ -72,44 +72,50 @@ ifeq ($(PLATFORM),)
7272
PLATFORM=$(shell basename "$(CURDIR)")
7373
endif
7474

75-
ifeq ($(RUNTIMEIDENTIFIERS),)
75+
ifneq ($(RUNTIMEIDENTIFIERS)$(RUNTIMEIDENTIFIER),)
76+
$(error "Don't set RUNTIMEIDENTIFIER or RUNTIMEIDENTIFIERS, set RID instead")
77+
endif
78+
79+
ifeq ($(RID),)
7680
ifeq ($(PLATFORM),iOS)
77-
RUNTIMEIDENTIFIERS=ios-arm64
81+
RID=ios-arm64
7882
else ifeq ($(PLATFORM),tvOS)
79-
RUNTIMEIDENTIFIERS=tvos-arm64
83+
RID=tvos-arm64
8084
else ifeq ($(PLATFORM),MacCatalyst)
8185
ifeq ($(CONFIG),Release)
82-
RUNTIMEIDENTIFIERS=maccatalyst-x64;maccatalyst-arm64
86+
RID=maccatalyst-x64;maccatalyst-arm64
8387
else ifneq ($(UNIVERSAL),)
84-
RUNTIMEIDENTIFIERS=maccatalyst-x64;maccatalyst-arm64
88+
RID=maccatalyst-x64;maccatalyst-arm64
8589
else ifeq ($(shell arch),arm64)
86-
RUNTIMEIDENTIFIERS=maccatalyst-arm64
90+
RID=maccatalyst-arm64
8791
else
88-
RUNTIMEIDENTIFIERS=maccatalyst-x64
92+
RID=maccatalyst-x64
8993
endif
9094
else ifeq ($(PLATFORM),macOS)
9195
ifeq ($(CONFIG),Release)
92-
RUNTIMEIDENTIFIERS=osx-x64;osx-arm64
96+
RID=osx-x64;osx-arm64
9397
else ifneq ($(UNIVERSAL),)
94-
RUNTIMEIDENTIFIERS=osx-x64;osx-arm64
98+
RID=osx-x64;osx-arm64
9599
else ifeq ($(shell arch),arm64)
96-
RUNTIMEIDENTIFIERS=osx-arm64
100+
RID=osx-arm64
97101
else
98-
RUNTIMEIDENTIFIERS=osx-x64
102+
RID=osx-x64
99103
endif
100104
else
101-
RUNTIMEIDENTIFIERS=unknown-platform-$(PLATFORM)
105+
RID=unknown-platform-$(PLATFORM)
102106
endif
103107
endif
104108

105109
ifneq ($(UNIVERSAL),)
106110
UNIVERSAL_ARGUMENT=/p:UniversalBuild=true
107111
endif
108112

109-
ifeq ($(findstring ;,$(RUNTIMEIDENTIFIERS)),;)
113+
ifeq ($(findstring ;,$(RID)),;)
110114
PATH_RID=
115+
export RUNTIMEIDENTIFIERS=$(RID)
111116
else
112-
PATH_RID=$(RUNTIMEIDENTIFIERS)/
117+
PATH_RID=$(RID)/
118+
export RUNTIMEIDENTIFIER=$(RID)
113119
endif
114120

115121

tests/generator/BGenTests.cs

+15
Original file line numberDiff line numberDiff line change
@@ -1719,5 +1719,20 @@ public void DelegatesWithNullableReturnType (Profile profile)
17191719
var delegateCallback = bgen.ApiAssembly.MainModule.GetType ("NS", "MyCallback").Methods.First ((v) => v.Name == "EndInvoke");
17201720
Assert.That (delegateCallback.MethodReturnType.CustomAttributes.Any (v => v.AttributeType.Name == "NullableAttribute"), "Nullable return type");
17211721
}
1722+
1723+
[Test]
1724+
[TestCase (Profile.iOS)]
1725+
public void DelegatesWithPointerTypes (Profile profile)
1726+
{
1727+
Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ());
1728+
var bgen = BuildFile (profile, "tests/delegate-types.cs");
1729+
bgen.AssertNoWarnings ();
1730+
1731+
var delegateCallback = bgen.ApiAssembly.MainModule.GetType ("NS", "MyCallback").Methods.First ((v) => v.Name == "EndInvoke");
1732+
Assert.IsTrue (delegateCallback.MethodReturnType.ReturnType.IsPointer, "Pointer return type");
1733+
foreach (var p in delegateCallback.Parameters.Where (v => v.Name != "result")) {
1734+
Assert.IsTrue (p.ParameterType.IsPointer, $"Pointer parameter type: {p.Name}");
1735+
}
1736+
}
17221737
}
17231738
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
using Foundation;
4+
using ObjCRuntime;
5+
6+
namespace NS {
7+
unsafe delegate byte* MyCallback (sbyte* a, short* b, ushort* c, int* d, uint* e, long* f, ulong* g, float* h, double* i);
8+
9+
[BaseType (typeof (NSObject))]
10+
interface Widget {
11+
[Export ("foo")]
12+
[NullAllowed]
13+
MyCallback Foo { get; set; }
14+
}
15+
}

tests/monotouch-test/ObjCRuntime/RegistrarTest.cs

+32
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics.CodeAnalysis;
44
using System.Drawing;
55
using System.Linq;
6+
using System.Reflection;
67
using System.Runtime.InteropServices;
78
using System.Runtime.Versioning;
89
using System.Threading;
@@ -5536,6 +5537,37 @@ public void RefEnumValues ()
55365537
Assert.AreEqual (EnumUL.b, ul, "out: UL");
55375538
}
55385539
}
5540+
5541+
#if NET && HAS_UIKIT
5542+
[Test]
5543+
public void ProtocolsTrimmedAway ()
5544+
{
5545+
PreserveIUIApplicationDelegate (null);
5546+
5547+
// A little indirection to try to make the trimmer not be helpful and preserve all the methods on IUIApplicationDelegate.
5548+
AssertMemberCount (typeof (IUIApplicationDelegate));
5549+
}
5550+
5551+
void AssertMemberCount (Type type)
5552+
{
5553+
var members = type.GetMembers (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
5554+
#if OPTIMIZEALL || NATIVEAOT
5555+
var expectNoMembers = true;
5556+
#else
5557+
var expectNoMembers = false;
5558+
#endif
5559+
if (expectNoMembers) {
5560+
Assert.AreEqual (0, members.Length, $"All members should be trimmed away in {type.FullName}:\n\t{string.Join ("\n\t", members.Select (v => v.ToString ()))}");
5561+
} else {
5562+
Assert.AreNotEqual (0, members.Length, $"All members should not be trimmed away in {type.FullName}");
5563+
}
5564+
}
5565+
5566+
void PreserveIUIApplicationDelegate (IUIApplicationDelegate obj)
5567+
{
5568+
GC.KeepAlive (obj);
5569+
}
5570+
#endif // NET && HAS_UIKIT
55395571
}
55405572

55415573
#if !__WATCHOS__

tests/xharness/Harness.cs

-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ void AutoConfigureIOS ()
606606
IOSTestProjects.Add (new iOSTestProject (TestLabel.Binding, Path.GetFullPath (Path.Combine (RootDirectory, "bindings-test", "iOS", "bindings-test.csproj")), false) { Name = "bindings-test" });
607607

608608
IOSTestProjects.Add (new iOSTestProject (TestLabel.InterdependentBindingProjects, Path.GetFullPath (Path.Combine (RootDirectory, "interdependent-binding-projects", "interdependent-binding-projects.csproj"))) { Name = "interdependent-binding-projects" });
609-
IOSTestProjects.Add (new iOSTestProject (TestLabel.Introspection, Path.GetFullPath (Path.Combine (RootDirectory, "introspection", "iOS", "introspection-ios.csproj"))) { Name = "introspection" });
610609
IOSTestProjects.Add (new iOSTestProject (TestLabel.Linker, Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dont link.csproj"))) {
611610
Configurations = new string [] { "Debug", "Release" },
612611
});

0 commit comments

Comments
 (0)