From 809a12647f057395ea38b3379f5dad8aaf325c82 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 23 Jul 2020 14:23:12 +0200 Subject: [PATCH 01/18] [tests] Port link sdk to .NET --- .../ios/link sdk/dotnet/iOS/link sdk.csproj | 102 ++++++++++++++++++ tests/xharness/Harness.cs | 1 + 2 files changed, 103 insertions(+) create mode 100644 tests/linker/ios/link sdk/dotnet/iOS/link sdk.csproj diff --git a/tests/linker/ios/link sdk/dotnet/iOS/link sdk.csproj b/tests/linker/ios/link sdk/dotnet/iOS/link sdk.csproj new file mode 100644 index 0000000000..cb0084575e --- /dev/null +++ b/tests/linker/ios/link sdk/dotnet/iOS/link sdk.csproj @@ -0,0 +1,102 @@ + + + + net5.0 + ios-x64 + Exe + NET + latest + linksdk + link sdk + SdkOnly + true + xamarinios10;$(AssetTargetFallback) + -disable-thread-check -xml=${ProjectDir}/../extra-linker-defs.xml "--dlsym:-link sdk" -gcc_flags="-UhoItsB0rken" + + + + + ../../support.dll + + + + + + + + + + + + + + + + + + + + + + + + + + Info.plist + + + + + + + + + + + + + + + + + + + + + + + + + + TestRuntime.cs + + + ILReader.cs + + + CommonLinkSdkTest.cs + + + CommonLinkAnyTest.cs + + + + NetworkResources.cs + + + + + + + + + + + + + + + + + + diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index 61d9d152df..2845be670a 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -396,6 +396,7 @@ namespace Xharness { IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dotnet", "iOS", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link all", "link all.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "link sdk.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); + IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "dotnet", "iOS", "link sdk.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, Ignore = true }); foreach (var flavor in new MonoNativeFlavor [] { MonoNativeFlavor.Compat, MonoNativeFlavor.Unified }) { var monoNativeInfo = new MonoNativeInfo (DevicePlatform.iOS, flavor, RootDirectory, Log); From 7d7208c86de87606e954acda2aedcb3f0fe58916 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 15:03:04 +0200 Subject: [PATCH 02/18] [tests] Exclude link sdk tests in .NET that reference OpenTK-1.0.dll OpenTK-1.0.dll isn't supported yet. --- tests/linker/ios/link sdk/LinkSdkRegressionTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 8c9b9867a8..0f40c95066 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -405,6 +405,7 @@ namespace LinkSdk { } #if !__WATCHOS__ +#if !NET // OpenTK-1.0.dll is not supported yet [Test] public void OpenTk_3049 () { @@ -430,6 +431,7 @@ namespace LinkSdk { core = GetTypeHelper ("OpenTK.Graphics.ES20.GL/Core, " + OpenTKAssembly, false); Assert.NotNull (core, "ES20/Core"); } +#endif // !NET #endif // !__WATCHOS__ [Test] From 7cf7f2d2d3adbca04402fd3fa94c3abc6bc232c9 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 15:03:04 +0200 Subject: [PATCH 03/18] [tests] Exclude link sdk tests using API that isn't available anymore in .NET. --- tests/linker/ios/link sdk/LinkSdkRegressionTest.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 0f40c95066..bf416c1a1c 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -18,7 +18,9 @@ using System.Security.Permissions; using System.Security.Principal; using System.Threading; using System.Xml; +#if !NET using Mono.Data.Sqlite; +#endif using MonoTouch; #if !__TVOS__ && !__WATCHOS__ using AddressBook; @@ -79,6 +81,7 @@ namespace LinkSdk { // the above should not throw System.Runtime.Serialization.SerializationException } +#if !NET // This test requires Mono.Data.SqliteConnection, which .NET 5+ doesn't have [Test] // http://bugzilla.xamarin.com/show_bug.cgi?id=233 public void Bug233_MonoPInvokeCallback () @@ -89,6 +92,7 @@ namespace LinkSdk { // the above should not crash c.Close (); } +#endif [Test] // http://bugzilla.xamarin.com/show_bug.cgi?id=234 @@ -226,6 +230,7 @@ namespace LinkSdk { } } +#if !NET // This test requires System.ServiceModel.dll, which .NET 5+ doesn't have [Test] // http://bugzilla.xamarin.com/show_bug.cgi?id=1415 public void Bug1415_Linker_DataMember () @@ -268,7 +273,9 @@ namespace LinkSdk { Assert.True (stack_trace, "StackTrace"); Assert.True (type, "Type"); } +#endif // !NET +#if !NET // This test requires System.ServiceModel.dll, which .NET 5+ doesn't have [Test] // http://bugzilla.xamarin.com/show_bug.cgi?id=1415 // not really part of the bug - but part of the same fix @@ -285,6 +292,7 @@ namespace LinkSdk { // should be null if application is linked (won't be if "Don't link" is used) #endif // !__WATCHOS__ } +#endif // !NET [Test] // http://bugzilla.xamarin.com/show_bug.cgi?id=1443 @@ -386,6 +394,7 @@ namespace LinkSdk { } } +#if !NET // This test requires Mono.Data.SqliteConnection, which .NET 5+ doesn't have [Test] // http://stackoverflow.com/questions/8602726/cant-open-sqlite-database-in-read-only-mode public void Sqlite_ReadOnly () @@ -395,6 +404,7 @@ namespace LinkSdk { // the above should not throw a 'misuse' exception c.Close (); } +#endif [Test] public void AsQueryable_3028 () @@ -722,11 +732,13 @@ namespace LinkSdk { Assert.IsFalse (Attribute.IsDefined (GetType (), typeof(SerializableAttribute))); } +#if !NET // This test requires System.Runtime.Remoting.dll, which .NET 5+ doesn't have [Test] public void LinkedAway () { Assert.Throws (() => new System.Runtime.Remoting.RemotingException ()); } +#endif // !NET [Test] public void ArrayClear_11184 () @@ -1000,6 +1012,7 @@ namespace LinkSdk { } #if !__WATCHOS__ +#if !NET // This test requires Mono.Security.dll, which .NET 5+ doesn't have [Test] public void TlsProvider_Apple () { @@ -1007,6 +1020,7 @@ namespace LinkSdk { Assert.NotNull (provider, "provider"); Assert.That (provider.ID, Is.EqualTo (new Guid ("981af8af-a3a3-419a-9f01-a518e3a17c1c")), "correct provider"); } +#endif [Test] public void Github5024 () From 3eeb46261a2b4765200e246ab9cf8288f2447627 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 15:02:16 +0200 Subject: [PATCH 04/18] [tests] The HttpWebRequest constructors are not publicly available in .NET 5+, so use WebRequest.CreateHttp instead. --- tests/linker/ios/link sdk/PclTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/linker/ios/link sdk/PclTest.cs b/tests/linker/ios/link sdk/PclTest.cs index 8f3129dda4..9209029613 100644 --- a/tests/linker/ios/link sdk/PclTest.cs +++ b/tests/linker/ios/link sdk/PclTest.cs @@ -33,7 +33,7 @@ namespace LinkSdk { Assert.False (this is ICommand, "ICommand"); - HttpWebRequest hwr = new HttpWebRequest (uri); + HttpWebRequest hwr = WebRequest.CreateHttp (uri); try { Assert.True (hwr.SupportsCookieContainer, "SupportsCookieContainer"); } From a44fdae53d18096e928b6fc9bad10b143914c520 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 17:15:04 +0200 Subject: [PATCH 05/18] [tests] Ignore a link sdk test that calls MulticastDelegate.BeginInvoke. MulticastDelegate.BeginInvoke isn't supported in .NET. Ref: https://github.com/dotnet/runtime/issues/16312 --- tests/linker/ios/link sdk/AotBugs.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/linker/ios/link sdk/AotBugs.cs b/tests/linker/ios/link sdk/AotBugs.cs index cbf9afc16d..5467880520 100644 --- a/tests/linker/ios/link sdk/AotBugs.cs +++ b/tests/linker/ios/link sdk/AotBugs.cs @@ -469,6 +469,9 @@ namespace LinkSdk.Aot { } [Test] +#if NET + [Ignore ("MulticastDelegate.BeginInvoke isn't supported in .NET (https://github.com/dotnet/runtime/issues/16312)")] +#endif public void Bug5354 () { Action testAction = (string s) => { s.ToString (); }; From 6a2f1dbc291a730de4bb3ab6e6d41cff938e3874 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 18:52:51 +0200 Subject: [PATCH 06/18] [tests] Disable link sdk tests that require Crypto for .NET and which cause the test app to crash Fixes unhandled exception that makes the app crash: Unhandled Exception: System.EntryPointNotFoundException: AppleCryptoNative_SecKeychainItemCopyKeychain assembly: type: member:(null) at Interop.AppleCrypto.SecKeychainItemCopyKeychain(IntPtr item) at System.Security.Cryptography.Apple.SafeTemporaryKeychainHandle.UntrackItem(IntPtr keychainItem) at System.Security.Cryptography.Apple.SafeKeychainItemHandle.ReleaseHandle() at System.Runtime.InteropServices.SafeHandle.InternalRelease(Boolean disposeOrFinalizeOperation) at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing) at System.Runtime.InteropServices.SafeHandle.Finalize() --- tests/linker/ios/link sdk/AsyncTest.cs | 3 +++ tests/linker/ios/link sdk/CryptoTest.cs | 9 +++++++++ tests/linker/ios/link sdk/LinkSdkRegressionTest.cs | 3 +++ 3 files changed, 15 insertions(+) diff --git a/tests/linker/ios/link sdk/AsyncTest.cs b/tests/linker/ios/link sdk/AsyncTest.cs index d861a2f7bf..200411ac69 100644 --- a/tests/linker/ios/link sdk/AsyncTest.cs +++ b/tests/linker/ios/link sdk/AsyncTest.cs @@ -16,6 +16,9 @@ namespace LinkSdk { return Task.Run (async () => await (new HttpClient ()).GetStringAsync (NetworkResources.MicrosoftUrl)); } +#if NET + [Ignore ("System.EntryPointNotFoundException: AppleCryptoNative_SecKeychainItemCopyKeychain")] // https://github.com/dotnet/runtime/issues/36897 +#endif [Test] public void Bug12221 () { diff --git a/tests/linker/ios/link sdk/CryptoTest.cs b/tests/linker/ios/link sdk/CryptoTest.cs index 0245e30796..084dc7a307 100644 --- a/tests/linker/ios/link sdk/CryptoTest.cs +++ b/tests/linker/ios/link sdk/CryptoTest.cs @@ -35,6 +35,9 @@ namespace LinkSdk { static int trust_validation_callback; +#if NET + [Ignore ("System.EntryPointNotFoundException: AppleCryptoNative_SecKeychainItemCopyKeychain")] // https://github.com/dotnet/runtime/issues/36897 +#endif [Test] public void TrustUsingNewCallback () { @@ -64,6 +67,9 @@ namespace LinkSdk { } } +#if NET + [Ignore ("System.EntryPointNotFoundException: AppleCryptoNative_SecKeychainItemCopyKeychain")] // https://github.com/dotnet/runtime/issues/36897 +#endif [Test] public void SSL_IP_5706 () { @@ -88,6 +94,9 @@ namespace LinkSdk { static int sne_validation_callback; +#if NET + [Ignore ("System.EntryPointNotFoundException: AppleCryptoNative_SecKeychainItemCopyKeychain")] // https://github.com/dotnet/runtime/issues/36897 +#endif [Test] public void TLS1_ServerNameExtension () { diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index bf416c1a1c..62cb667f16 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -634,6 +634,9 @@ namespace LinkSdk { Assert.NotNull (NetworkInterface.GetAllNetworkInterfaces ()); } +#if NET + [Ignore ("System.EntryPointNotFoundException: AppleCryptoNative_SecKeychainItemCopyKeychain")] // https://github.com/dotnet/runtime/issues/36897 +#endif [Test] public void WebClient_SSL_Leak () { From e8c389164deea9f171ec796e6704a9bbe6c84140 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 19:49:14 +0200 Subject: [PATCH 07/18] [tests] Disable link sdk tests that require Crypto for .NET. Fixes these link sdk test failures: LinkSdk.CryptoTest [FAIL] AesCreate : System.Core Expected: True But was: False at LinkSdk.CryptoTest.AesCreate() in [...]/xamarin-macios/tests/linker/ios/link sdk/CryptoTest.cs:line 33 [FAIL] Chain : System.EntryPointNotFoundException : AppleCryptoNative_SecKeychainCreate assembly: type: member:(null) at Interop.AppleCrypto.CreateOrOpenKeychain(String keychainPath, Boolean createAllowed) at Internal.Cryptography.Pal.StorePal.AppleKeychainStore.CreateOrOpenKeychain(String keychainPath, OpenFlags openFlags) at Internal.Cryptography.Pal.StorePal.FromCustomKeychainStore(String storeName, OpenFlags openFlags) at Internal.Cryptography.Pal.StorePal.FromSystemStore(String storeName, StoreLocation storeLocation, OpenFlags openFlags) at System.Security.Cryptography.X509Certificates.X509Store.Open(OpenFlags flags) at LinkSdk.CryptoTest.Chain() in [...]/xamarin-macios/tests/linker/ios/link sdk/CryptoTest.cs:line 149 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) [FAIL] Sha256 : System.EntryPointNotFoundException : AppleCryptoNative_SecCopyErrorMessageString assembly: type: member:(null) at Interop.AppleCrypto.GetSecErrorString(Int32 osStatus) at Interop.AppleCrypto.CreateExceptionForOSStatus(Int32 osStatus) at Internal.Cryptography.Pal.X509Pal.AppleX509Pal.GetCertContentType(ReadOnlySpan`1 rawData) at System.Security.Cryptography.X509Certificates.X509Certificate2.GetCertContentType(ReadOnlySpan`1 rawData) at Internal.Cryptography.Pal.AppleCertificatePal.FromBlob(ReadOnlySpan`1 rawData, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) at Internal.Cryptography.Pal.CertificatePal.FromBlob(ReadOnlySpan`1 rawData, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(ReadOnlySpan`1 data) at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] data) at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData) at LinkSdk.CryptoTest.Sha256() in [...]/xamarin-macios/tests/linker/ios/link sdk/CryptoTest.cs:line 228 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) --- tests/linker/ios/link sdk/CryptoTest.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/linker/ios/link sdk/CryptoTest.cs b/tests/linker/ios/link sdk/CryptoTest.cs index 084dc7a307..83033a0c6f 100644 --- a/tests/linker/ios/link sdk/CryptoTest.cs +++ b/tests/linker/ios/link sdk/CryptoTest.cs @@ -23,6 +23,9 @@ namespace LinkSdk { [Preserve (AllMembers = true)] public class CryptoTest { +#if NET + [Ignore ("https://github.com/dotnet/runtime/issues/36897")] +#endif [Test] public void AesCreate () { @@ -142,6 +145,9 @@ namespace LinkSdk { } } +#if NET + [Ignore ("System.EntryPointNotFoundException: AppleCryptoNative_SecKeychainCreate")] // https://github.com/dotnet/runtime/issues/36897 +#endif [Test] public void Chain () { @@ -222,6 +228,10 @@ namespace LinkSdk { 0x58, 0x62, 0x42, 0x43, 0x35, 0x37, 0x77, 0x3D, 0x3D, 0x0D, 0x0A, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x45, 0x4E, 0x44, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0D, 0x0A, }; + +#if NET + [Ignore ("System.EntryPointNotFoundException : AppleCryptoNative_SecCopyErrorMessageString")] // https://github.com/dotnet/runtime/issues/36897 +#endif [Test] public void Sha256 () { From 77f9a4d733ca64bc434c042c919f55b4c8e21a05 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 22:51:20 +0200 Subject: [PATCH 08/18] [tests] Ignore DllImportTest.LackOfCapget in .NET due to an issue in .NET. System.Net.NetworkInformation.Ping.Send doesn't work. Ref: https://github.com/dotnet/runtime/issues/41355 Fixes this link sdk test failure: LinkSdk.DllImportTest [FAIL] LackOfCapget : Expected: But was: System.ComponentModel.Win32Exception (2): No such file or directory at System.Diagnostics.Process.EnsureInitialized() at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Net.NetworkInformation.Ping.SendWithPingUtility(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options) at System.Net.NetworkInformation.Ping.SendPingCore(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options) at System.Net.NetworkInformation.Ping.GetAddressAndSend(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options) --- End of inner exception stack trace --- at System.Net.NetworkInformation.Ping.GetAddressAndSend(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options) at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options) at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout, Byte[] buffer) at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress) at LinkSdk.DllImportTest.<>c__DisplayClass3_0.b__0() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/DllImportTest.cs:line 88 at NUnit.Framework.Assert.Throws(IResolveConstraint expression, TestDelegate code, String message, Object[] args)> at LinkSdk.DllImportTest.LackOfCapget() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/DllImportTest.cs:line 88 --- tests/linker/ios/link sdk/DllImportTest.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/linker/ios/link sdk/DllImportTest.cs b/tests/linker/ios/link sdk/DllImportTest.cs index 0651452236..be61204176 100644 --- a/tests/linker/ios/link sdk/DllImportTest.cs +++ b/tests/linker/ios/link sdk/DllImportTest.cs @@ -75,6 +75,9 @@ namespace LinkSdk { } } +#if NET + [Ignore ("https://github.com/dotnet/runtime/issues/41355")] +#endif [Test] public void LackOfCapget () { From dea6580c7855a747314d7008fdf1327a52010224 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 19:44:52 +0200 Subject: [PATCH 09/18] [tests] Ignore CommonLinkSdkTest.TypeDescriptor_A7793 in .NET due to a linker bug. Ref: https://github.com/mono/linker/issues/1451 Fixes this link sdk test failure: LinkSdk.CommonLinkSdkTest [FAIL] TypeDescriptor_A7793 : System.MissingMethodException : Default constructor not found for type System.ComponentModel.DateTimeOffsetConverter at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean skipCheckThis, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions) at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at System.ComponentModel.ReflectTypeDescriptionProvider.CreateInstance(Type objectType, Type callingType) at System.ComponentModel.ReflectTypeDescriptionProvider.SearchIntrinsicTable(Hashtable table, Type callingType) at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetConverter(Object instance) at System.ComponentModel.ReflectTypeDescriptionProvider.GetConverter(Type type, Object instance) at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetConverter() at System.ComponentModel.TypeDescriptor.GetConverter(Type type) at LinkSdk.CommonLinkSdkTest.TypeDescriptor_A7793() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/CommonLinkSdkTest.cs:line 21 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) --- tests/linker/CommonLinkSdkTest.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/linker/CommonLinkSdkTest.cs b/tests/linker/CommonLinkSdkTest.cs index d5b2e060f7..1bb6364b2e 100644 --- a/tests/linker/CommonLinkSdkTest.cs +++ b/tests/linker/CommonLinkSdkTest.cs @@ -13,6 +13,9 @@ namespace LinkSdk { [TestFixture] // we want the test to be availble if we use the linker [Preserve (AllMembers = true)] +#if NET + [Ignore ("Type converters are linked away: https://github.com/mono/linker/issues/1451")] +#endif public class CommonLinkSdkTest { [Test] From c8b622917db1cf6d6a6f94ab7f401477381afba7 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 23:01:58 +0200 Subject: [PATCH 10/18] [tests] Adjust LinkExtraDefsTest to work with .NET. Fixes these link sdk test failures: LinkSdk.LinkExtraDefsTest [FAIL] Corlib : System.Security.PermissionSet Expected: not null But was: null at LinkSdk.LinkExtraDefsTest.Corlib() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/LinkExtraDefsTest.cs:line 33 [FAIL] System : System.Net.Mime.ContentType Expected: not null But was: null at LinkSdk.LinkExtraDefsTest.System() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/LinkExtraDefsTest.cs:line 40 --- tests/linker/ios/link sdk/LinkExtraDefsTest.cs | 6 +++++- .../ios/link sdk/dotnet/extra-linker-defs.xml | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/linker/ios/link sdk/dotnet/extra-linker-defs.xml diff --git a/tests/linker/ios/link sdk/LinkExtraDefsTest.cs b/tests/linker/ios/link sdk/LinkExtraDefsTest.cs index 434ba5015e..932b81452b 100644 --- a/tests/linker/ios/link sdk/LinkExtraDefsTest.cs +++ b/tests/linker/ios/link sdk/LinkExtraDefsTest.cs @@ -29,14 +29,18 @@ namespace LinkSdk { [Test] public void Corlib () { - Type t = Type.GetType ("System.Security.PermissionSet, mscorlib"); + Type t = Type.GetType ("System.Security.PermissionSet, " + typeof (int).Assembly.GetName ().Name); Assert.NotNull (t, "System.Security.PermissionSet"); } [Test] public void System () { +#if NET + Type t = Type.GetType ("System.Net.Mime.ContentType, System.Net.Mail"); +#else Type t = Type.GetType ("System.Net.Mime.ContentType, System"); +#endif Assert.NotNull (t, "System.Net.Mime.ContentType"); // we asked for ParseValue to be preserved Assert.NotNull (t.GetMethod ("ParseValue", BindingFlags.Instance | BindingFlags.NonPublic), "Parse"); diff --git a/tests/linker/ios/link sdk/dotnet/extra-linker-defs.xml b/tests/linker/ios/link sdk/dotnet/extra-linker-defs.xml new file mode 100644 index 0000000000..68892fa38e --- /dev/null +++ b/tests/linker/ios/link sdk/dotnet/extra-linker-defs.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + From 75fbd970e0ca331ece9bb959a3edff3bad502064 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 23:30:29 +0200 Subject: [PATCH 11/18] [tests] Adjust LinkSdkRegressionTest.Pointer_5200 to work on .NET Fixes this link sdk test failure: LinkSdk.LinkSdkRegressionTest [FAIL] Pointer_5200 : Expected: not null But was: null at LinkSdk.LinkSdkRegressionTest.Pointer_5200() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs:line 696 --- tests/linker/ios/link sdk/LinkSdkRegressionTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 62cb667f16..40fdbdba87 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -693,7 +693,7 @@ namespace LinkSdk { public void Pointer_5200 () { // ensure the linker did not remove the type, which is used by the runtime - Assert.NotNull (GetTypeHelper ("System.Reflection.Pointer, mscorlib")); + Assert.NotNull (GetTypeHelper ("System.Reflection.Pointer, " + typeof (int).Assembly.GetName ().Name)); } [Test] From ae0649f4e59c0ea435429799eeeb5f4759a4195d Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 23:30:29 +0200 Subject: [PATCH 12/18] [tests] Ignore LinkSdkRegressionTest.AsQueryable_Enumerable due to an issue in .NET Ref: https://github.com/dotnet/runtime/issues/41392 Fixes this link sdk test failure: LinkSdk.LinkSdkRegressionTest [FAIL] AsQueryable_Enumerable : System.NullReferenceException : Object reference not set to an instance of an object at System.Linq.EnumerableRewriter.FindEnumerableMethod(String name, ReadOnlyCollection`1 args, Type[] typeArgs) at System.Linq.EnumerableRewriter.VisitMethodCall(MethodCallExpression m) at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection`1 nodes) at System.Linq.EnumerableRewriter.VisitMethodCall(MethodCallExpression m) at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.EnumerableExecutor`1[[System.Linq.IGrouping`2[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Linq, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].Execute() at System.Linq.EnumerableQuery`1[[System.Linq.IGrouping`2[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Linq, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].System.Linq.IQueryProvider.Execute[IGrouping`2](Expression expression) at System.Linq.Queryable.FirstOrDefault[IGrouping`2](IQueryable`1 source) at LinkSdk.LinkSdkRegressionTest.AsQueryable_Enumerable() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs:line 1100 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) --- tests/linker/ios/link sdk/LinkSdkRegressionTest.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 40fdbdba87..7fb100e127 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -1092,6 +1092,9 @@ namespace LinkSdk { } #endif +#if NET + [Ignore ("https://github.com/mono/linker/issues/1453")] +#endif [Test] // https://github.com/xamarin/xamarin-macios/issues/6346 public void AsQueryable_Enumerable () From 14aefe55766b586e3487a8a4997832885a89d57c Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Aug 2020 23:30:29 +0200 Subject: [PATCH 13/18] [tests] Adjust LinkSdkRegressionTest.PrivateMemorySize64 in .NET to expected values. This fixes this link sdk test failure: LinkSdk.LinkSdkRegressionTest [FAIL] PrivateMemorySize64 : PrivateMemorySize64 Expected: not equal to 0 But was: 0 at LinkSdk.LinkSdkRegressionTest.PrivateMemorySize64() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs:line 805 --- tests/linker/ios/link sdk/LinkSdkRegressionTest.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 7fb100e127..5616ea9201 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -802,7 +802,12 @@ namespace LinkSdk { var mem = System.Diagnostics.Process.GetCurrentProcess ().PrivateMemorySize64; // the above used a mach call that iOS samdbox did *not* allow (sandbox) on device // but has been fixed (different call) for the same PID +#if NET + // It's not entirely clear, but it appears this is not implemented, and won't be, for mobile platforms: https://github.com/dotnet/runtime/issues/28990 + Assert.That (mem, Is.EqualTo (0), "PrivateMemorySize64"); +#else Assert.That (mem, Is.Not.EqualTo (0), "PrivateMemorySize64"); +#endif } string TestFolder (Environment.SpecialFolder folder, bool supported = true, bool exists = true, bool readOnly = false) From 39660b687cf2200ddd08bcf7025820280de64a47 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 26 Aug 2020 09:33:21 +0200 Subject: [PATCH 14/18] [tests] Assert that the Mono.Runtime type does *not* exist in .NET. Fixes this link sdk test failure: LinkSdk.LinkSdkRegressionTest [FAIL] MonoRuntime34671 : Mono.Runtime Expected: not null But was: null at LinkSdk.LinkSdkRegressionTest.MonoRuntime34671() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs:line 1007 --- tests/linker/ios/link sdk/LinkSdkRegressionTest.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 5616ea9201..769a484195 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -1009,7 +1009,11 @@ namespace LinkSdk { [Test] public void MonoRuntime34671 () { +#if NET + Assert.Null (GetTypeHelper ("Mono.Runtime"), "Mono.Runtime"); +#else Assert.NotNull (GetTypeHelper ("Mono.Runtime"), "Mono.Runtime"); +#endif } [Test] From 9cbf14500b3182a076bcffa3e308d1d708c1ba86 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 26 Aug 2020 09:35:04 +0200 Subject: [PATCH 15/18] [tests] Ignore the XmlSerializationTest.Bug1820_GenericList test in .NET due to a linker bug. Ref: https://github.com/mono/linker/issues/1454 Fixes this link sdk test failure: LinkSdk.Serialization.XmlSerializationTest [FAIL] Bug1820_GenericList : System.ArgumentNullException : Value cannot be null. (Parameter 'obj') at System.Reflection.Emit.ModuleBuilder.GetToken(MemberInfo member, Boolean create_open_instance) at System.Reflection.Emit.ModuleBuilderTokenGenerator.GetToken(MemberInfo member, Boolean create_open_instance) at System.Reflection.Emit.ILGenerator.Emit(OpCode opcode, ConstructorInfo con) at System.Xml.Serialization.CodeGenerator.Call(ConstructorInfo ctor) at System.Xml.Serialization.XmlSerializationILGen.GenerateSerializerContract(String className, XmlMapping[] xmlMappings, Type[] types, String readerType, String[] readMethods, String writerType, String[] writerMethods, Dictionary`2 serializers) at System.Xml.Serialization.TempAssembly.GenerateRefEmitAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace) at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location) at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace, String location) at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace) at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace) at System.Xml.Serialization.XmlSerializer..ctor(Type type) at LinkSdk.Serialization.XmlSerializationTest.Response.get_Serializer() in [...]/xamarin-macios/tests/linker/ios/link sdk/Bug1820Test.cs:line 38 at LinkSdk.Serialization.XmlSerializationTest.Response.Deserialize(String xml) in [...]/xamarin-macios/tests/linker/ios/link sdk/Bug1820Test.cs:line 48 at LinkSdk.Serialization.XmlSerializationTest.Bug1820_GenericList() in [...]/xamarin-macios/tests/linker/ios/link sdk/Bug1820Test.cs:line 166 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) --- tests/linker/ios/link sdk/Bug1820Test.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/linker/ios/link sdk/Bug1820Test.cs b/tests/linker/ios/link sdk/Bug1820Test.cs index e9708d0f07..800607ef50 100644 --- a/tests/linker/ios/link sdk/Bug1820Test.cs +++ b/tests/linker/ios/link sdk/Bug1820Test.cs @@ -148,6 +148,9 @@ namespace LinkSdk.Serialization { } } +#if NET + [Ignore ("https://github.com/mono/linker/issues/1454")] +#endif [Test] // http://bugzilla.xamarin.com/show_bug.cgi?id=1820 // note: this also test the linker (5.1+) ability not to remove 'unused' XML setters and .ctors used for serialization From eb79bccd749b9f1982e32d8874d847338365231c Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 26 Aug 2020 09:36:55 +0200 Subject: [PATCH 16/18] [tests] Skip testing Environment.SpecialFolder.ProgramFiles in .NET due to a .NET issue. Ref: https://github.com/dotnet/runtime/issues/41383 Fixes this link sdk test failure: [FAIL] SpecialFolder : /Users/rolf/Library/Developer/CoreSimulator/Devices/0E45B8DF-05EF-47E7-A31F-3B829DEA2628/data/Containers/Data/Application/6454039E-D5F1-4C41-BF16-6C81CBAB1724/Applications Expected: True But was: False at LinkSdk.LinkSdkRegressionTest.TestFolder(SpecialFolder folder, Boolean supported, Boolean exists, Boolean readOnly) in [...]/xamarin-macios/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs:line 815 at LinkSdk.LinkSdkRegressionTest.SpecialFolder() in [...]/xamarin-macios/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs:line 900 --- tests/linker/ios/link sdk/LinkSdkRegressionTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 769a484195..4b5df51324 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -902,8 +902,10 @@ namespace LinkSdk { Assert.That (path, Is.EqualTo ("/usr/share"), "path - CommonApplicationData"); // and the simulator is more lax +#if !NET // https://github.com/dotnet/runtime/issues/41383 path = TestFolder (Environment.SpecialFolder.ProgramFiles, readOnly: device); Assert.That (path, Is.EqualTo ("/Applications"), "path - ProgramFiles"); +#endif path = TestFolder (Environment.SpecialFolder.UserProfile, readOnly: device); var bundlePath = NSBundle.MainBundle.BundlePath; From 1adcd5e89cfa7caee06b2ee95f1fd1e36f713f96 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 26 Aug 2020 09:38:23 +0200 Subject: [PATCH 17/18] [tests] Adjust the PclTest.ServiceModel test to not throw ArgumentNullException in .NET. This fix works just as well for the current Mono BCL as well, so there's no .NET condition. This fixes this link sdk test: LinkSdk.PclTest [FAIL] ServiceModel : System.ArgumentNullException : Value cannot be null. (Parameter 'name') at System.ServiceModel.Channels.AddressHeaderCollection.FindAll(String name, String ns) at LinkSdk.PclTest.ServiceModel() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/PclTest.cs:line 73 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) --- tests/linker/ios/link sdk/PclTest.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/linker/ios/link sdk/PclTest.cs b/tests/linker/ios/link sdk/PclTest.cs index 9209029613..f53066f7dc 100644 --- a/tests/linker/ios/link sdk/PclTest.cs +++ b/tests/linker/ios/link sdk/PclTest.cs @@ -70,20 +70,30 @@ namespace LinkSdk { { AddressHeaderCollection ahc = new AddressHeaderCollection (); try { - ahc.FindAll (null, null); + ahc.FindAll ("name", "namespace"); } catch (NotImplementedException) { // feature is not available, but the symbol itself is needed } try { - FaultException.CreateFault (null, String.Empty, null); + FaultException.CreateFault (new TestFault (), String.Empty, Array.Empty ()); } catch (NotImplementedException) { // feature is not available, but the symbol itself is needed } } + class TestFault : MessageFault { + public override FaultCode Code => throw new NotImplementedException (); + public override bool HasDetail => throw new NotImplementedException (); + public override FaultReason Reason => throw new NotImplementedException (); + protected override void OnWriteDetailContents (XmlDictionaryWriter writer) + { + throw new NotImplementedException (); + } + } + [Test] public void Xml () { From 09e3631cb1a5a591f787ade3660165e56dcbdcc0 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 26 Aug 2020 10:05:21 +0200 Subject: [PATCH 18/18] [xharness] link sdk is now green on .NET! At least the Debug configuration is, there's still a test failure in the Release configuration, so skip that for now. --- tests/xharness/Harness.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index 2845be670a..8187719950 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -396,7 +396,7 @@ namespace Xharness { IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dotnet", "iOS", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link all", "link all.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "link sdk.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); - IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "dotnet", "iOS", "link sdk.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, Ignore = true }); + IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "dotnet", "iOS", "link sdk.csproj"))) { Configurations = new string [] { "Debug" /*, "Release" */ }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true }); foreach (var flavor in new MonoNativeFlavor [] { MonoNativeFlavor.Compat, MonoNativeFlavor.Unified }) { var monoNativeInfo = new MonoNativeInfo (DevicePlatform.iOS, flavor, RootDirectory, Log);