Skip to content

Commit

Permalink
[release/9.0.1xx-preview6] Update dependencies from dotnet/sdk (xamar…
Browse files Browse the repository at this point in the history
…in#20773)

This pull request updates the following dependencies

## Coherency Updates

The following updates ensure that dependencies with a *CoherentParentDependency*
attribute were produced in a build used as input to the parent dependency's build.
See [Dependency Description Format](https://github.com/dotnet/arcade/blob/master/Documentation/DependencyDescriptionFormat.md#dependency-description-overview)

- **Coherency Updates**:
  - **Microsoft.NET.ILLink.Tasks**: from 9.0.0-preview.5.24256.1 to 9.0.0-preview.6.24321.8 (parent: VS.Tools.Net.Core.SDK.Resolver)
  - **Microsoft.AspNetCore.App.Ref**: from 9.0.0-preview.5.24256.2 to 9.0.0-preview.6.24322.1 (parent: VS.Tools.Net.Core.SDK.Resolver)
  - **Microsoft.NETCore.App.Ref**: from 9.0.0-preview.5.24256.1 to 9.0.0-preview.6.24321.8 (parent: VS.Tools.Net.Core.SDK.Resolver)
  - **Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport**: from 9.0.0-preview.5.24223.2 to 9.0.0-preview.6.24319.1 (parent: Microsoft.NETCore.App.Ref)
  - **Microsoft.NETCore.App.Ref**: from 9.0.0-preview.5.24256.1 to 9.0.0-preview.6.24321.8 (parent: VS.Tools.Net.Core.SDK.Resolver)
  - **Microsoft.DotNet.Cecil**: from 0.11.4-alpha.24230.1 to 0.11.4-alpha.24313.1 (parent: Microsoft.NETCore.App.Ref)

## From https://github.com/dotnet/sdk

- **Subscription**: 33f2d805-f028-40e1-9762-08dc94685a28
- **Build**: 20240624.5
- **Date Produced**: June 24, 2024 11:13:14 AM UTC
- **Commit**: 09d2448d624709773e31418b85273f02b40a8f6a
- **Branch**: refs/heads/release/9.0.1xx-preview6

- **Updates**:
  - **VS.Tools.Net.Core.SDK.Resolver**: [from 9.0.100-preview.5.24262.2 to 9.0.100-preview.6.24324.5][1]
  - **Microsoft.NET.ILLink.Tasks**: [from 9.0.0-preview.5.24256.1 to 9.0.0-preview.6.24321.8][2]
  - **Microsoft.AspNetCore.App.Ref**: [from 9.0.0-preview.5.24256.2 to 9.0.0-preview.6.24322.1][3]
  - **Microsoft.NETCore.App.Ref**: [from 9.0.0-preview.5.24256.1 to 9.0.0-preview.6.24321.8][2]
  - **Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport**: [from 9.0.0-preview.5.24223.2 to 9.0.0-preview.6.24319.1][4]
  - **Microsoft.NETCore.App.Ref**: [from 9.0.0-preview.5.24256.1 to 9.0.0-preview.6.24321.8][2]
  - **Microsoft.DotNet.Cecil**: [from 0.11.4-alpha.24230.1 to 0.11.4-alpha.24313.1][5]

[1]: dotnet/sdk@1741345...09d2448
[2]: dotnet/runtime@84b3339...89a244e
[3]: dotnet/aspnetcore@da3aa27...68adb02
[4]: dotnet/emsdk@53288f8...9880d89
[5]: dotnet/cecil@7a4a59f...d145726
  • Loading branch information
dotnet-maestro[bot] authored Jun 25, 2024
1 parent d337dbe commit a2d6bbb
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 42 deletions.
26 changes: 13 additions & 13 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="VS.Tools.Net.Core.SDK.Resolver" Version="9.0.100-preview.5.24262.2">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>1741345c6399ae203d8f259fb12fb873dac5129d</Sha>
<Dependency Name="VS.Tools.Net.Core.SDK.Resolver" Version="9.0.100-preview.6.24324.5">
<Uri>https://github.com/dotnet/sdk</Uri>
<Sha>09d2448d624709773e31418b85273f02b40a8f6a</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink" Version="9.0.0-alpha.1.23556.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>cf47d9ff6827a3e1d6f2acbf925cd618418f20dd</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="9.0.0-preview.5.24256.1" CoherentParentDependency="VS.Tools.Net.Core.SDK.Resolver">
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="9.0.0-preview.6.24321.8" CoherentParentDependency="VS.Tools.Net.Core.SDK.Resolver">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>84b33395057737db3ea342a5151feb6b90c1b6f6</Sha>
<Sha>89a244e88cdcf0242987f9f516b40d16b5382eb8</Sha>
</Dependency>
<!-- Set TRACKING_DOTNET_RUNTIME_SEPARATELY to something in Make.config if removing the CoherentParentDependency on VS.Tools.Net.Core.SDK.Resolver -->
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.5.24256.1" CoherentParentDependency="VS.Tools.Net.Core.SDK.Resolver">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.6.24321.8" CoherentParentDependency="VS.Tools.Net.Core.SDK.Resolver">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>84b33395057737db3ea342a5151feb6b90c1b6f6</Sha>
<Sha>89a244e88cdcf0242987f9f516b40d16b5382eb8</Sha>
</Dependency>
<!-- This is required for our test apps to build; in some cases Microsoft.AspNetCore.App is pulled in, and when building test apps the build needs to be able to resolve that -->
<Dependency Name="Microsoft.AspNetCore.App.Ref" Version="9.0.0-preview.5.24256.2" CoherentParentDependency="VS.Tools.Net.Core.SDK.Resolver">
<Dependency Name="Microsoft.AspNetCore.App.Ref" Version="9.0.0-preview.6.24322.1" CoherentParentDependency="VS.Tools.Net.Core.SDK.Resolver">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>da3aa27233a2cec2f6780884f71934b2f5e686ce</Sha>
<Sha>68adb02eb4217bad645d165f10355e346b693a5e</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-preview.5.24223.2" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-preview.6.24319.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>53288f87c588907e8ff01f129786820fe998573c</Sha>
<Sha>9880d891ddfddee1b1182c149468a43b89c090a0</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.24230.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.24313.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/cecil</Uri>
<Sha>7a4a59f9f66baf6711a6ce2de01d3b2c62ed72d8</Sha>
<Sha>d145726036eb9c09a0e3cf03c4f70effd3b31cd7</Sha>
</Dependency>
<!-- This is a subscription of the .NET 8 versions of our packages -->
<Dependency Name="Microsoft.MacCatalyst.Sdk" Version="17.2.8078">
Expand Down
8 changes: 4 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<PropertyGroup>
<!-- Versions updated by maestro -->
<!-- NOTE: $(VSToolsNetCoreSDKResolverPackageVersion) may be temporary -->
<VSToolsNetCoreSDKResolverPackageVersion>9.0.100-preview.5.24262.2</VSToolsNetCoreSDKResolverPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.5.24256.1</MicrosoftNETILLinkTasksPackageVersion>
<VSToolsNetCoreSDKResolverPackageVersion>9.0.100-preview.6.24324.5</VSToolsNetCoreSDKResolverPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.6.24321.8</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETILLinkPackageVersion>9.0.0-alpha.1.23556.4</MicrosoftNETILLinkPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>8.0.0-beta.24225.1</MicrosoftDotNetBuildTasksFeedPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.5.24256.1</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.6.24321.8</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>8.0.0-rtm.23511.3</MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>
<MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>9.0.0-alpha.1.23556.4</MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>
<MicrosoftTemplateEngineTasksVersion>7.0.100-alpha.1.21601.1</MicrosoftTemplateEngineTasksVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.24230.1</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.24313.1</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetXHarnessiOSSharedPackageVersion>9.0.0-prerelease.24312.3</MicrosoftDotNetXHarnessiOSSharedPackageVersion>
<!-- Manually updated versions -->
<Emscriptennet7WorkloadVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100Version)</Emscriptennet7WorkloadVersion>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "9.0.100-preview.5.24262.2"
"version": "9.0.100-preview.6.24324.5"
}
}
4 changes: 4 additions & 0 deletions src/Foundation/NSUrlSessionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ public NSUrlSessionHandler (NSUrlSessionConfiguration configuration)
allowsCellularAccess = configuration.AllowsCellularAccess;
AllowAutoRedirect = true;

#pragma warning disable SYSLIB0014
// SYSLIB0014: 'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.' (https://aka.ms/dotnet-warnings/SYSLIB0014)
// https://github.com/xamarin/xamarin-macios/issues/20764
var sp = ServicePointManager.SecurityProtocol;
#pragma warning restore SYSLIB0014
if ((sp & SecurityProtocolType.Ssl3) != 0)
configuration.TLSMinimumSupportedProtocol = SslProtocol.Ssl_3_0;
else if ((sp & SecurityProtocolType.Tls) != 0)
Expand Down
2 changes: 2 additions & 0 deletions tests/common/BinLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ public static bool TryFindPropertyValue (string binlog, string property, [NotNul
if (propname == property)
value = propvalue;
}
} else if (bmea.Message?.StartsWith ($"TaskOutput: {property}") == true) {
value = bmea.Message?.Substring ($"TaskOutput: {property}".Length).Trim ();
}
}
}
Expand Down
19 changes: 16 additions & 3 deletions tests/dotnet/UnitTests/PostBuildTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,22 @@ public void ArchiveTest (ApplePlatform platform, string runtimeIdentifiers)
var result = DotNet.AssertBuild (project_path, properties);
var recordArgs = BinLog.ReadBuildEvents (result.BinLogPath).ToList ();
var findString = "Output Property: ArchiveDir";
var archiveDirRecord = recordArgs.Where (v => v?.Message?.Contains (findString) == true).ToList ();
Assert.That (archiveDirRecord.Count, Is.GreaterThan (0), "ArchiveDir");
var archiveDir = archiveDirRecord [0].Message?.Substring (findString.Length + 1)?.Trim ();
var findString2 = "TaskOutput: ArchiveDir";
var archiveDirs = recordArgs.
Select (v => v?.Message).
Select (v => {
if (v is null)
return null;
if (v.Contains (findString))
return v.Substring (findString.Length + 1);
if (v.Contains (findString2))
return v.Substring (findString2.Length + 1);
return null;
}).
Where (v => v is not null).
ToList ();
Assert.That (archiveDirs.Count, Is.GreaterThan (0), "ArchiveDir");
var archiveDir = archiveDirs [0]!.Trim ();
Assert.That (archiveDir, Does.Exist, "Archive directory existence");
AssertDSymDirectory (appPath);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/introspection/ApiTypeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public void StaticCtor ()
if (Skip (t))
continue;

if (t.IsGenericTypeDefinition) {
// https://github.com/dotnet/runtime/issues/103891
continue;
}

var cctor = t.GetConstructor (BindingFlags.Static | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
if (cctor is null)
continue;
Expand Down
18 changes: 12 additions & 6 deletions tests/linker/ios/link sdk/ReflectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ namespace Linker.Shared.Reflection {
// we want the tests to be available because we use the linker
[Preserve (AllMembers = true)]
public class ReflectionTest {

public void MethodWithParameters (string firstParameter, int secondParameter)
{
}

[Test]
public void ParameterInfoName ()
{
// linker will disable the metadata removal optimization if that property is used by user code
// however it's used inside mscorlib.dll (and SDK) so it cannot be checked while testing
//Assert.Null (typeof (ParameterInfo).GetProperty ("Name"), "Name");

var mi = this.GetType ().GetMethod ("MethodWithParameters");
// Call the method we want to test, so that the linker doesn't remove it.
// The method needs to be in a different class, because this class has the Preserve attribute,
// and the linker will keep the parameter names inside such classes.
ReflectionTestClass.MethodWithParameters (null, 0);

var mi = GetType ().Assembly.GetType ("Linker.Shared.Reflection.ReflectionTestClass").GetMethod ("MethodWithParameters");
var p = mi.GetParameters ();
#if DEBUG && !NET
// dotnet has adopted (and adapted) the metadata reducer and runs it on it's own conditions
Expand All @@ -43,4 +43,10 @@ public void ParameterInfoName ()
}
}
}

class ReflectionTestClass {
public static void MethodWithParameters (string firstParameter, int secondParameter)
{
}
}
}
31 changes: 16 additions & 15 deletions tests/monotouch-test/CoreMidi/MidiThruConnectionParamsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ static byte [] DefaultChannelMap {
}
}

#if NET
#if RELEASE
string ParameterSuffix = " Arg_ParamName_Name, value";
#else
string ParameterSuffix = " (Parameter 'value')";
#endif
#else
string ParameterSuffix = "\nParameter name: value";
#endif
string [] parameterSuffixes = new string [] {
" Arg_ParamName_Name, value",
" (Parameter 'value')",
"\nParameter name: value",
};

void AssertAreEqualWithAnySuffix (string expectedWithoutSuffix, string actual, string message)
{
Assert.That (actual, Is.AnyOf (parameterSuffixes.Select (suffix => expectedWithoutSuffix + suffix).ToArray ()), message);
}

[Test]
public void ParamsTest ()
Expand Down Expand Up @@ -112,7 +113,7 @@ public void PropertiesTest_Sources ()

// Set to more than 8 sources
var ex = Assert.Throws<ArgumentOutOfRangeException> (() => { p.Sources = new MidiThruConnectionEndpoint [9]; }, "Sources 4");
Assert.AreEqual ($"A maximum of 8 endpoints are allowed{ParameterSuffix}", ex.Message, "Sources 4b");
AssertAreEqualWithAnySuffix ($"A maximum of 8 endpoints are allowed", ex.Message, "Sources 4b");
}

[Test]
Expand All @@ -138,7 +139,7 @@ public void PropertiesTest_Destinations ()

// Set to more than 8 destinations
var ex = Assert.Throws<ArgumentOutOfRangeException> (() => { p.Destinations = new MidiThruConnectionEndpoint [9]; }, "Sources 4");
Assert.AreEqual ($"A maximum of 8 endpoints are allowed{ParameterSuffix}", ex.Message, "Destinations 4b");
AssertAreEqualWithAnySuffix ($"A maximum of 8 endpoints are allowed", ex.Message, "Destinations 4b");
}

[Test]
Expand Down Expand Up @@ -199,7 +200,7 @@ public void PropertiesTest_ChannelMap ()

// Set to more than 16 channels
var ex = Assert.Throws<ArgumentOutOfRangeException> (() => { p.ChannelMap = new byte [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }; }, "ChannelMap 4");
Assert.AreEqual ($"A maximum of 16 channels are allowed{ParameterSuffix}", ex.Message, "ChannelMap 4b");
AssertAreEqualWithAnySuffix ($"A maximum of 16 channels are allowed", ex.Message, "ChannelMap 4b");
}

[Test]
Expand Down Expand Up @@ -534,7 +535,7 @@ public void PropertiesTest_Controls ()
// Set to a big array; the field with the number of controls is a UInt16, so overflow by one
var toobigArray = new MidiControlTransform [1 + (int) ushort.MaxValue];
var ex = Assert.Throws<ArgumentOutOfRangeException> (() => { p.Controls = toobigArray; }, "Controls 4");
Assert.AreEqual ($"A maximum of {ushort.MaxValue} controls are allowed{ParameterSuffix}", ex?.Message, "Controls 4b");
AssertAreEqualWithAnySuffix ($"A maximum of {ushort.MaxValue} controls are allowed", ex?.Message, "Controls 4b");

// Set to the maximum sized array; the field with the number of maps is a UInt16, so create exactly that
var bigArray = new MidiControlTransform [ushort.MaxValue];
Expand Down Expand Up @@ -575,7 +576,7 @@ public void PropertiesTest_Maps ()
// Set to a too big array; the field with the number of maps is a UInt16, so overflow by one
var toobigArray = new MidiValueMap [1 + (int) ushort.MaxValue];
var ex = Assert.Throws<ArgumentOutOfRangeException> (() => { p.Maps = toobigArray; }, "Maps 4");
Assert.AreEqual ($"A maximum of {ushort.MaxValue} maps are allowed{ParameterSuffix}", ex?.Message, "Maps 4b");
AssertAreEqualWithAnySuffix ($"A maximum of {ushort.MaxValue} maps are allowed", ex?.Message, "Maps 4b");

// Set to the maximum sized array; the field with the number of maps is a UInt16, so create exactly that
var bigArray = new MidiValueMap [ushort.MaxValue];
Expand Down Expand Up @@ -1029,7 +1030,7 @@ public void MidiValueMapTest ()

var bytes = new byte [42];
var ex = Assert.Throws<ArgumentOutOfRangeException> (() => { map.Value = bytes; }, "Invalid byte array");
Assert.AreEqual ($"The length of the Value array must be 128{ParameterSuffix}", ex.Message, "Ex Message");
AssertAreEqualWithAnySuffix ($"The length of the Value array must be 128", ex.Message, "Ex Message");

bytes = new byte [128];
bytes [42] = 36;
Expand Down
8 changes: 8 additions & 0 deletions tests/monotouch-test/System.Net.Http/MessageHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,9 @@ public void RejectSslCertificatesServicePointManager (Type handlerType)
// return false, since we want to test that the exception is raised
return false;
};
#pragma warning disable SYSLIB0014 // 'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.' (https://aka.ms/dotnet-warnings/SYSLIB0014)
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => {
#pragma warning restore SYSLIB0014
invalidServicePointManagerCbWasExcuted = true;
return false;
};
Expand Down Expand Up @@ -511,7 +513,9 @@ public void RejectSslCertificatesServicePointManager (Type handlerType)
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue ("Basic", Convert.ToBase64String (byteArray));
result = await client.GetAsync (NetworkResources.Httpbin.GetRedirectUrl (3));
} finally {
#pragma warning disable SYSLIB0014 // 'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.' (https://aka.ms/dotnet-warnings/SYSLIB0014)
ServicePointManager.ServerCertificateValidationCallback = null;
#pragma warning restore SYSLIB0014
}
}, out var ex);

Expand Down Expand Up @@ -551,7 +555,9 @@ public void AcceptSslCertificatesServicePointManager (Type handlerType)
return true;
};
} else {
#pragma warning disable SYSLIB0014 // 'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.' (https://aka.ms/dotnet-warnings/SYSLIB0014)
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => {
#pragma warning restore SYSLIB0014
// servicePointManagerCbWasExcuted = true;
return true;
};
Expand All @@ -565,7 +571,9 @@ public void AcceptSslCertificatesServicePointManager (Type handlerType)
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue ("Basic", Convert.ToBase64String (byteArray));
var result = await client.GetAsync (NetworkResources.Httpbin.GetRedirectUrl (3));
} finally {
#pragma warning disable SYSLIB0014 // 'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.' (https://aka.ms/dotnet-warnings/SYSLIB0014)
ServicePointManager.ServerCertificateValidationCallback = null;
#pragma warning restore SYSLIB0014
}
}, out var ex);

Expand Down
14 changes: 14 additions & 0 deletions tools/common/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -933,19 +933,33 @@ void GenerateIOSMain (StringWriter sw, Abi abi)
sw.WriteLine ("}");
}

#if NET
static readonly char [] charsToReplaceAot = new [] { '.', '-', '+', '<', '>' };
#endif
static string EncodeAotSymbol (string symbol)
{
var sb = new StringBuilder ();
/* This mimics what the aot-compiler does */
// https://github.com/dotnet/runtime/blob/2f08fcbfece0c09319f237a6aee6f74c4a9e14e8/src/mono/mono/metadata/native-library.c#L1265-L1284
// https://github.com/dotnet/runtime/blob/2f08fcbfece0c09319f237a6aee6f74c4a9e14e8/src/tasks/Common/Utils.cs#L419-L445
foreach (var b in System.Text.Encoding.UTF8.GetBytes (symbol)) {
char c = (char) b;
if ((c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z')) {
sb.Append (c);
continue;
#if NET
} else if (charsToReplaceAot.Contains (c)) {
sb.Append ('_');
} else {
// Append the hex representation of b between underscores
sb.Append ($"_{b:X}_");
#endif
}
#if !NET
sb.Append ('_');
#endif
}
return sb.ToString ();
}
Expand Down
18 changes: 18 additions & 0 deletions tools/dotnet-linker/Steps/ManagedRegistrarLookupTablesStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,27 @@ void GenerateConstructINativeObject (TypeDefinition registrarType)
il.Emit (OpCodes.Ret);
}

void AddTypeInterfaceImplementation (TypeDefinition type, TypeReference iface)
{
if (type.HasInterfaces && type.Interfaces.Any (v => v.InterfaceType == iface))
return;

var ifaceImplementation = new InterfaceImplementation (iface);
type.Interfaces.Add (ifaceImplementation);
Annotations.Mark (ifaceImplementation);
Annotations.Mark (ifaceImplementation.InterfaceType);
Annotations.Mark (ifaceImplementation.InterfaceType.Resolve ());
}

void ImplementConstructNSObjectFactoryMethod (TypeDefinition type, MethodReference ctor)
{
// skip creating the factory for NSObject itself
if (type.Is ("Foundation", "NSObject"))
return;

// Make sure the type implements INSObjectFactory, otherwise we can't override the _Xamarin_ConstructNSObject method from it.
AddTypeInterfaceImplementation (type, abr.Foundation_INSObjectFactory);

var createInstanceMethod = type.AddMethod ("_Xamarin_ConstructNSObject", MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.NewSlot | MethodAttributes.HideBySig, abr.Foundation_NSObject);
var nativeHandleParameter = createInstanceMethod.AddParameter ("nativeHandle", abr.ObjCRuntime_NativeHandle);
abr.Foundation_INSObjectFactory.Resolve ().IsPublic = true;
Expand Down Expand Up @@ -456,6 +471,9 @@ void ImplementConstructINativeObjectFactoryMethod (TypeDefinition type, MethodRe
if (nsobjectConstructor is null && ctor is null)
return;

// Make sure the type implements INativeObject, otherwise we can't override the _Xamarin_ConstructINativeObject method from it.
AddTypeInterfaceImplementation (type, abr.ObjCRuntime_INativeObject);

var createInstanceMethod = type.AddMethod ("_Xamarin_ConstructINativeObject", MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.NewSlot | MethodAttributes.HideBySig, abr.ObjCRuntime_INativeObject);
var nativeHandleParameter = createInstanceMethod.AddParameter ("nativeHandle", abr.ObjCRuntime_NativeHandle);
var ownsParameter = createInstanceMethod.AddParameter ("owns", abr.System_Boolean);
Expand Down

0 comments on commit a2d6bbb

Please sign in to comment.