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] 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 (); }; 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/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 diff --git a/tests/linker/ios/link sdk/CryptoTest.cs b/tests/linker/ios/link sdk/CryptoTest.cs index 0245e30796..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 () { @@ -35,6 +38,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 +70,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 +97,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 () { @@ -133,6 +145,9 @@ namespace LinkSdk { } } +#if NET + [Ignore ("System.EntryPointNotFoundException: AppleCryptoNative_SecKeychainCreate")] // https://github.com/dotnet/runtime/issues/36897 +#endif [Test] public void Chain () { @@ -213,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 () { 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 () { 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/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 8c9b9867a8..4b5df51324 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 () @@ -405,6 +415,7 @@ namespace LinkSdk { } #if !__WATCHOS__ +#if !NET // OpenTK-1.0.dll is not supported yet [Test] public void OpenTk_3049 () { @@ -430,6 +441,7 @@ namespace LinkSdk { core = GetTypeHelper ("OpenTK.Graphics.ES20.GL/Core, " + OpenTKAssembly, false); Assert.NotNull (core, "ES20/Core"); } +#endif // !NET #endif // !__WATCHOS__ [Test] @@ -622,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 () { @@ -678,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] @@ -720,11 +735,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 () @@ -785,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) @@ -880,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; @@ -987,7 +1011,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] @@ -998,6 +1026,7 @@ namespace LinkSdk { } #if !__WATCHOS__ +#if !NET // This test requires Mono.Security.dll, which .NET 5+ doesn't have [Test] public void TlsProvider_Apple () { @@ -1005,6 +1034,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 () @@ -1073,6 +1103,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 () diff --git a/tests/linker/ios/link sdk/PclTest.cs b/tests/linker/ios/link sdk/PclTest.cs index 8f3129dda4..f53066f7dc 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"); } @@ -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 () { 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 @@ + + + + + + + + + + + + + + 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..8187719950 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 }); foreach (var flavor in new MonoNativeFlavor [] { MonoNativeFlavor.Compat, MonoNativeFlavor.Unified }) { var monoNativeInfo = new MonoNativeInfo (DevicePlatform.iOS, flavor, RootDirectory, Log);