{
+
+ public static List CreateList
()
+ {
+ return new List
();
+ }
+
+ public static List StringList = CreateList ();
+ public static List IntList = CreateList ();
+ }
+
+ public class Class1 : Base {
+ }
+
+ [Test]
+ public void Bug8379_a ()
+ {
+ new Base ();
+ }
+
+ [Test]
+ public void Bug8379_b ()
+ {
+ new Class1 ();
+ }
+
+ [Test]
+ public void Bug5354 ()
+ {
+ Action testAction = (string s) => { s.ToString (); };
+ testAction.BeginInvoke ("Teszt", null, null);
+ }
+
+ public static IEnumerable GetStringList() where T : struct, IConvertible
+ {
+ return Enum.GetValues(typeof(T)).Cast().Select(x=>x.ToString());
+ }
+
+ [Test]
+ public void Bug12811a ()
+ {
+ int n = 1;
+ foreach (var e in GetStringList ()) {
+ Assert.NotNull (e, n.ToString ());
+ n++;
+ }
+ }
+
+ [Test]
+ public void Bug12811b ()
+ {
+ int n = 1;
+ foreach (var e in Enum.GetValues (typeof (NSFileManagerItemReplacementOptions)).Cast ().Select (x=>x.ToString ())) {
+ Assert.NotNull (e, n.ToString ());
+ n++;
+ }
+ }
+
+ public enum MyEnum8ElementsInInt32 : int
+ {
+ Zero = 0
+ , One = 1
+ , Two = 2
+ , Three = 3
+ , Four = 4
+ , Five = 5
+ , Six = 6
+ , Seven = 7
+ }
+
+ public enum MyEnum8ElementsInUInt32 : uint
+ {
+ Zero = 0
+ , One = 1
+ , Two = 2
+ , Three = 3
+ , Four = 4
+ , Five = 5
+ , Six = 6
+ , Seven = 7
+ }
+
+ public enum MyEnum7ElementsInUInt16 : ushort
+ {
+ Zero = 0
+ , One = 1
+ , Two = 2
+ , Three = 3
+ , Four = 4
+ , Five = 5
+ , Six = 6
+ }
+
+ public enum MyEnum8ElementsInUInt16 : ushort
+ {
+ Zero = 0
+ , One = 1
+ , Two = 2
+ , Three = 3
+ , Four = 4
+ , Five = 5
+ , Six = 6
+ , Seven = 7
+ }
+
+ [Test]
+ public void Bug12605 ()
+ {
+ Assert.AreEqual ("One", Convert.ToString ((MyEnum8ElementsInInt32) 1), "1");
+ Assert.AreEqual ("One", Convert.ToString ((MyEnum8ElementsInUInt32) 1), "2");
+ Assert.AreEqual ("One", Convert.ToString ((MyEnum7ElementsInUInt16) 1), "3");
+ Assert.AreEqual ("One", Convert.ToString ((MyEnum8ElementsInUInt16) 1), "4");
+ }
+
+ [Test]
+ public void Bug12895 ()
+ {
+ var r = new System.Text.RegularExpressions.Regex (@"(?\G[ ]+)|(?\G?
+)|(?\G[][{}:,])|(?\G[A-Za-z]+)|(?\G
+ \"" # Opening quote
+ (?:
+ \\u[0-9a-fA-F]{4} | # Unicode escape
+ \\b | \\f | \ | \ | \ | # Backspace, form-feed, newline, carriage-return, tab
+ \\\\ | \\/ | # Escaped backslash, slash
+ \\"" | # Escaped quotes
+ [^\p{Cc}\\""] # Any unicode character except a control code, a backslash or a double quote
+ )* # Zero of more of any of the previous classes
+ \"" # Closing quote
+ )|(?\G
+ -? # Optional minus
+ (?:
+ 0 | # Leading zero only allowed on its own (e.g. 0, 0.1, 0e1)
+ [1-9][0-9]* # Otherwise leading digit must be non-zero (so no 0123, 0001)
+ )
+ (?:[.][0-9]*)? # Optional fraction
+ (?:[Ee][+-]?[0-9]+)? # Optional exponent
+ (?![A-Za-z0-9_]) # Must not be followed by an alphanumeric character
+ )", System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace);
+ Assert.NotNull (r); // looking got EEE while executing, on devices, the above code
+ }
+
+ [Test]
+ public void Bug26245 ()
+ {
+ var c = new Collection ();
+ c.Add (new PointF (50, 50)); // crashed under ARM64
+ Assert.That (c.Count, Is.EqualTo (1));
+ }
+
+ [Test]
+ public void Bug39443 ()
+ {
+ // un-reproducible test case (added to have large pool of QA devices run iton different CPU)
+ var nfe = nfloat.Epsilon.ToString ();
+ if (IntPtr.Size == 4) {
+ Assert.That (float.Epsilon.ToString (), Is.EqualTo (nfe), "Epsilon");
+ } else {
+ Assert.That (double.Epsilon.ToString (), Is.EqualTo (nfe), "Epsilon");
+ }
+ }
+ }
+}
diff --git a/tests/linker-ios/link sdk/AppDelegate.cs b/tests/linker-ios/link sdk/AppDelegate.cs
new file mode 100644
index 000000000000..6b6315b6c400
--- /dev/null
+++ b/tests/linker-ios/link sdk/AppDelegate.cs
@@ -0,0 +1,53 @@
+
+#if !__WATCHOS__
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+#if XAMCORE_2_0
+using Foundation;
+using UIKit;
+#else
+using MonoTouch.Foundation;
+using MonoTouch.UIKit;
+#endif
+using MonoTouch.NUnit.UI;
+
+namespace LinkSdk
+{
+ // The UIApplicationDelegate for the application. This class is responsible for launching the
+ // User Interface of the application, as well as listening (and optionally responding) to
+ // application events from iOS.
+ [Register ("AppDelegate")]
+ public partial class AppDelegate : UIApplicationDelegate
+ {
+ // class-level declarations
+ UIWindow window;
+ TouchRunner runner;
+
+ //
+ // This method is invoked when the application has loaded and is ready to run. In this
+ // method you should instantiate the window, load the UI into it and then make the window
+ // visible.
+ //
+ // You have 17 seconds to return from this method, or iOS will terminate your application.
+ //
+ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
+ {
+ // create a new window instance based on the screen size
+ window = new UIWindow (UIScreen.MainScreen.Bounds);
+ runner = new TouchRunner (window);
+
+ // tests can be inside the main assembly
+ runner.Add (Assembly.GetExecutingAssembly ());
+ runner.Add (typeof (BundledResources.ResourcesTest).Assembly);
+
+ window.RootViewController = new UINavigationController (runner.GetViewController ());
+ // make the window visible
+ window.MakeKeyAndVisible ();
+
+ return true;
+ }
+ }
+}
+#endif // !__WATCHOS__
diff --git a/tests/linker-ios/link sdk/AsyncTest.cs b/tests/linker-ios/link sdk/AsyncTest.cs
new file mode 100644
index 000000000000..9776afb5d8eb
--- /dev/null
+++ b/tests/linker-ios/link sdk/AsyncTest.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Net.Http;
+using System.Threading.Tasks;
+#if XAMCORE_2_0
+using Foundation;
+#else
+using MonoTouch.Foundation;
+#endif
+using NUnit.Framework;
+
+namespace LinkSdk {
+
+ [TestFixture]
+ [Preserve (AllMembers = true)]
+ public class AsyncTests {
+
+ public Task LoadCategories ()
+ {
+ return Task.Run (async () => await (new HttpClient ()).GetStringAsync ("http://google.com"));
+ }
+
+ [Test]
+ public void Bug12221 ()
+ {
+ LoadCategories ().Wait ();
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/linker-ios/link sdk/Bug1820Test.cs b/tests/linker-ios/link sdk/Bug1820Test.cs
new file mode 100644
index 000000000000..64062f527ef3
--- /dev/null
+++ b/tests/linker-ios/link sdk/Bug1820Test.cs
@@ -0,0 +1,177 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+#if XAMCORE_2_0
+using Foundation;
+#else
+using MonoTouch.Foundation;
+#endif
+using NUnit.Framework;
+
+namespace LinkSdk.Serialization {
+
+ [TestFixture]
+ // we want the test to be availble if we use the linker
+ [Preserve (AllMembers = true)]
+ public partial class XmlSerializationTest {
+
+ [Serializable]
+ [XmlType (AnonymousType = true)]
+ [XmlRoot (Namespace = "", IsNullable = false)]
+ public class Response {
+ private DataUpdates dataUpdatesField;
+ private static XmlSerializer serializer;
+
+ public Response ()
+ {
+ this.dataUpdatesField = new DataUpdates ();
+ }
+
+ [XmlElement (Order = 0)]
+ public DataUpdates DataUpdates {
+ get { return this.dataUpdatesField; }
+ set { this.dataUpdatesField = value; }
+ }
+
+ private static XmlSerializer Serializer {
+ get {
+ if ((serializer == null))
+ serializer = new XmlSerializer (typeof (Response));
+ return serializer;
+ }
+ }
+
+ public static Response Deserialize (string xml)
+ {
+ StringReader stringReader = null;
+ try {
+ stringReader = new StringReader (xml);
+ return ((Response)(Serializer.Deserialize (XmlReader.Create (stringReader))));
+ } finally {
+ if ((stringReader != null)) {
+ stringReader.Dispose ();
+ }
+ }
+ }
+ }
+
+ [Serializable]
+ [XmlType (AnonymousType = true)]
+ [XmlRoot (Namespace = "", IsNullable = false)]
+ public class DataUpdates {
+ private List dataUpdateInfoField;
+ private static XmlSerializer serializer;
+
+ public DataUpdates ()
+ {
+ this.dataUpdateInfoField = new List ();
+ }
+
+ // BUG1820 is here! remove Order = 0 and it works
+ [XmlElement ("DataUpdateInfo", Form = XmlSchemaForm.Unqualified, Order = 0)]
+ public List DataUpdateInfo {
+ get { return this.dataUpdateInfoField; }
+ set { this.dataUpdateInfoField = value; }
+ }
+
+ private static XmlSerializer Serializer {
+ get {
+ if ((serializer == null))
+ serializer = new XmlSerializer (typeof (DataUpdates));
+ return serializer;
+ }
+ }
+
+ public static DataUpdates Deserialize (string xml)
+ {
+ StringReader stringReader = null;
+ try {
+ stringReader = new StringReader (xml);
+ return ((DataUpdates)(Serializer.Deserialize (XmlReader.Create (stringReader))));
+ } finally {
+ if ((stringReader != null)) {
+ stringReader.Dispose ();
+ }
+ }
+ }
+ }
+
+ [Serializable]
+ [XmlType (AnonymousType = true)]
+ public class DataUpdatesDataUpdateInfo {
+
+ private DateTime dataDateField;
+ private string dataTypeField;
+ private DateTime lastUpdatedDateField;
+ private static XmlSerializer serializer;
+
+ public DataUpdatesDataUpdateInfo ()
+ {
+ }
+
+ [XmlAttribute]
+ public DateTime DataDate {
+ get { return this.dataDateField; }
+ set { this.dataDateField = value; }
+ }
+
+ [XmlAttribute]
+ public string DataType {
+ get { return this.dataTypeField; }
+ set { this.dataTypeField = value; }
+ }
+
+ [XmlAttribute]
+ public DateTime LastUpdatedDate {
+ get { return this.lastUpdatedDateField; }
+ set { this.lastUpdatedDateField = value; }
+ }
+
+ private static XmlSerializer Serializer {
+ get {
+ if ((serializer == null))
+ serializer = new XmlSerializer (typeof(DataUpdatesDataUpdateInfo));
+ return serializer;
+ }
+ }
+
+ public static DataUpdatesDataUpdateInfo Deserialize (string xml)
+ {
+ StringReader stringReader = null;
+ try {
+ stringReader = new StringReader (xml);
+ return ((DataUpdatesDataUpdateInfo)(Serializer.Deserialize (XmlReader.Create (stringReader))));
+ } finally {
+ if ((stringReader != null)) {
+ stringReader.Dispose ();
+ }
+ }
+ }
+ }
+
+ [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
+ public void Bug1820_GenericList ()
+ {
+ string input = @"
+
+
+
+
+
+
+
+
+ ".Trim ();
+ Response r = Response.Deserialize (input);
+ Assert.That (r.DataUpdates.DataUpdateInfo.Count, Is.EqualTo (3), "Count");
+ Assert.That (r.DataUpdates.DataUpdateInfo [0].DataDate.Day, Is.EqualTo (13), "0");
+ Assert.That (r.DataUpdates.DataUpdateInfo [1].DataDate.Day, Is.EqualTo (14), "1");
+ Assert.That (r.DataUpdates.DataUpdateInfo [2].DataDate.Day, Is.EqualTo (15), "2");
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/linker-ios/link sdk/Bug2096Test.cs b/tests/linker-ios/link sdk/Bug2096Test.cs
new file mode 100644
index 000000000000..eecd05b4833b
--- /dev/null
+++ b/tests/linker-ios/link sdk/Bug2096Test.cs
@@ -0,0 +1,58 @@
+using System;
+#if XAMCORE_2_0
+using Foundation;
+using ObjCRuntime;
+#else
+using MonoTouch.Foundation;
+using MonoTouch.ObjCRuntime;
+#endif
+using NUnit.Framework;
+
+namespace LinkSdk.Aot {
+
+ [TestFixture]
+ // we want the test to be availble if we use the linker
+ [Preserve (AllMembers = true)]
+ public partial class AotBugsTest {
+
+ public struct VT {
+ public Action a;
+ }
+
+ public class D {
+ }
+
+ public class A {
+ public void OuterMethod (TArg1 value)
+ {
+ this.InnerMethod (value, 0);
+ }
+
+ private void InnerMethod (TArg1 v1, TArg2 v2)
+ {
+ Console.WriteLine ("{0} {1}", v1, v2);
+ }
+ }
+
+ [Test]
+ public void Bug2096_Aot ()
+ {
+ var a = new A ();
+
+ a.OuterMethod (1);
+ a.OuterMethod (DateTime.Now);
+ // works with 5.0.2 (5.1)
+
+ var v = new VT ();
+ a.OuterMethod (v);
+ // works with 5.0.2 (5.1)
+
+ var x = new D ();
+ a.OuterMethod (x);
+ // fails with 5.0.2 (5.1) when running on devices with
+ // Attempting to JIT compile method 'A:InnerMethod (D,long)' while running with --aot-only.
+ if (Runtime.Arch == Arch.SIMULATOR)
+ Assert.Inconclusive ("only fails on devices");
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/linker-ios/link sdk/CalendarTest.cs b/tests/linker-ios/link sdk/CalendarTest.cs
new file mode 100644
index 000000000000..004bedc38662
--- /dev/null
+++ b/tests/linker-ios/link sdk/CalendarTest.cs
@@ -0,0 +1,42 @@
+// Copyright 2013 Xamarin Inc. All rights reserved.
+
+using System;
+using System.Globalization;
+#if XAMCORE_2_0
+using Foundation;
+#else
+using MonoTouch.Foundation;
+#endif
+using NUnit.Framework;
+
+namespace LinkSdk.Calendars {
+
+ [TestFixture]
+ // we want the tests to be available because we use the linker
+ [Preserve (AllMembers = true)]
+ public class CalendarTest {
+
+ // application must *NOT* be build with I18N.MidEast and I18N.Other (Thai)
+
+ [Test]
+ public void UmAlQura ()
+ {
+ var ci = CultureInfo.GetCultureInfo ("ar");
+ Assert.That (ci.Calendar.ToString (), Is.EqualTo ("System.Globalization.GregorianCalendar"), "Calendar");
+ }
+
+ [Test]
+ public void Hijri ()
+ {
+ var ci = CultureInfo.GetCultureInfo ("ps");
+ Assert.That (ci.Calendar.ToString (), Is.EqualTo ("System.Globalization.GregorianCalendar"), "Calendar");
+ }
+
+ [Test]
+ public void ThaiBuddhist ()
+ {
+ var ci = CultureInfo.GetCultureInfo ("th");
+ Assert.That (ci.Calendar.ToString (), Is.EqualTo ("System.Globalization.GregorianCalendar"), "Calendar");
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/linker-ios/link sdk/CryptoTest.cs b/tests/linker-ios/link sdk/CryptoTest.cs
new file mode 100644
index 000000000000..dcdd431ed3e4
--- /dev/null
+++ b/tests/linker-ios/link sdk/CryptoTest.cs
@@ -0,0 +1,218 @@
+//
+// Cryptographic Unit Tests - for about everything that can go wrong wrt linking
+//
+// Authors:
+// Sebastien Pouliot
+//
+// Copyright 2012 Xamarin Inc.
+//
+
+using System;
+using System.Net;
+using System.Net.Security;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+#if XAMCORE_2_0
+using Foundation;
+#else
+using MonoTouch.Foundation;
+#endif
+using NUnit.Framework;
+
+namespace LinkSdk {
+
+ [TestFixture]
+ // we want the test to be availble if we use the linker
+ [Preserve (AllMembers = true)]
+ public class CryptoTest {
+
+ [Test]
+ public void AesCreate ()
+ {
+ // Aes resides in mscorlib.dll but needs to create instance of types that are
+ // located inside System.Core.dll - IOW the linker needs to be aware of this
+ Aes aes = Aes.Create ();
+ Assert.NotNull (aes, "Aes");
+ Assert.True (aes.GetType ().Assembly.FullName.StartsWith ("System.Core, ", StringComparison.Ordinal), "System.Core");
+ }
+
+ static int trust_validation_callback;
+
+ [Test]
+ public void TrustUsingNewCallback ()
+ {
+ // Three similar tests exists in dontlink, linkall and linksdk to test 3 different cases
+ // untrusted, custom ICertificatePolicy and ServerCertificateValidationCallback without
+ // having caching issues (in S.Net or the SSL handshake cache)
+ try {
+ ServicePointManager.ServerCertificateValidationCallback = delegate (object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors errors) {
+ Assert.That (errors, Is.EqualTo (SslPolicyErrors.None), "certificateProblem");
+ X509Certificate2 c2 = new X509Certificate2 (cert.GetRawCertData ());
+ Assert.False (chain.Build (c2), "Build");
+ Assert.AreSame (c2, chain.ChainElements [0].Certificate, "ChainElements");
+ trust_validation_callback++;
+ return true;
+ };
+ WebClient wc = new WebClient ();
+ Assert.IsNotNull (wc.DownloadString ("https://wrench.internalx.com/Wrench/Login.aspx"));
+ // caching means it will be called at least for the first run, but it might not
+ // be called again in subsequent requests (unless it expires)
+ Assert.That (trust_validation_callback, Is.GreaterThan (0), "validation done");
+ }
+ finally {
+ ServicePointManager.ServerCertificateValidationCallback = null;
+ }
+ }
+
+ [Test]
+ public void SSL_IP_5706 ()
+ {
+ WebClient wc = new WebClient ();
+ // the certificate contains (several rules) the host name
+ Assert.NotNull (wc.DownloadString ("https://www.google.com"));
+
+ // IP are (generally) not allowed
+ foreach (var ip in Dns.GetHostAddresses ("www.google.com")) {
+ if (ip.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork)
+ continue;
+
+ Assert.Throws (delegate {
+ wc.DownloadString ("https://" + ip.ToString ());
+ }, ip.ToString ());
+ return; // checking a single IP is enough to prove the point
+ }
+ }
+
+ static int sne_validation_callback;
+
+ [Test]
+ public void TLS1_ServerNameExtension ()
+ {
+ // without support for the "server_name" TLS extension (RFC3546) we receive the "general"
+ // certificate of a server, which might not be the right one if a single server instance
+ // is used for many hosts (without a common name)
+
+ // note: SSLv3 won't work, test is inside linkall.app (due to result caching)
+
+ var actual = ServicePointManager.SecurityProtocol;
+ try {
+ ServicePointManager.ServerCertificateValidationCallback = delegate (object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors errors) {
+ Assert.That (errors, Is.EqualTo (SslPolicyErrors.None), "certificateProblem");
+ X509Certificate2 c2 = new X509Certificate2 (cert.GetRawCertData ());
+ Assert.False (chain.Build (c2), "Build");
+ Assert.AreSame (c2, chain.ChainElements [0].Certificate, "ChainElements");
+ sne_validation_callback++;
+ return true;
+ };
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
+ WebClient wc = new WebClient ();
+ Assert.IsNotNull (wc.DownloadString ("https://api.imgur.com/2/stats"));
+ }
+ catch (WebException we) {
+ // failing to get data does not mean the SSL/TLS session was not established
+ if (sne_validation_callback == 0) {
+ // The remote server returned an error: (502) Bad Gateway.
+ // The remote server returned an error: (503) Service Unavailable.
+ if (we.Message.Contains ("(502)") || we.Message.Contains ("(503)"))
+ Assert.Inconclusive (we.Message);
+ throw;
+ }
+ }
+ finally {
+ ServicePointManager.ServerCertificateValidationCallback = null;
+ ServicePointManager.SecurityProtocol = actual;
+ // caching means it will be called at least for the first run, but it might not
+ // be called again in subsequent requests (unless it expires)
+ Assert.That (sne_validation_callback, Is.GreaterThan (0), "validation done");
+ }
+ }
+
+ [Test]
+ public void Chain ()
+ {
+ X509Store store = new X509Store ("Trust");
+ store.Open (OpenFlags.ReadWrite);
+
+ string certString = "MIIDGjCCAgKgAwIBAgICApowDQYJKoZIhvcNAQEFBQAwLjELMAkGA1UEBhMCQ1oxDjAMBgNVBAoTBVJlYmV4MQ8wDQYDVQQDEwZUZXN0Q0EwHhcNMDAwMTAxMDAwMDAwWhcNNDkxMjMxMDAwMDAwWjAuMQswCQYDVQQGEwJDWjEOMAwGA1UEChMFUmViZXgxDzANBgNVBAMTBlRlc3RDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMgeRAcaNLTFaaBhFx8RDJ8b9K655dNUXmO11mbImDbPq4qVeZXDgAjnzPov8iBscwfqBvBpF38LsxBIPA2i1d0RMsQruOhJHttA9I0enElUXXj63sOEVNMSQeg1IMyvNeEotag+Gcx6SF+HYnariublETaZGzwAOD2SM49mfqUyfkgeTjdO6qp8xnoEr7dS5pEBHDg70byj/JEeZd3gFea9TiOXhbCrI89dKeWYBeoHFYhhkaSB7q9EOaUEzKo/BQ6PBHFu6odfGkOjXuwfPkY/wUy9U4uj75LmdhzvJf6ifsJS9BQZF4//JcUYSxiyzpxDYqSbTF3g9w5Ds2LOAscCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgB/MA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFD1v20tPgvHTEK/0eLO09j0rL2qXMA0GCSqGSIb3DQEBBQUAA4IBAQAZIjcdR3EZiFJ67gfCnPBrxVgFNvaRAMCYEYYIGDCAUeB4bLTu9dvun9KFhgVNqjgx+xTTpx9d/5mAZx5W3YAG6faQPCaHccLefB1M1hVPmo8md2uw1a44RHU9LlM0V5Lw8xTKRkQiZz3Ysu0sY27RvLrTptbbfkE4Rp9qAMguZT9cFrgPAzh+0zuo8NNj9Jz7/SSa83yIFmflCsHYSuNyKIy2iaX9TCVbTrwJmRIB65gqtTb6AKtFGIPzsb6nayHvgGHFchrFovcNrvRpE71F38oVG+eCjT23JfiIZim+yJLppSf56167u8etDcQ39j2b9kzWlHIVkVM0REpsKF7S";
+ X509Certificate2 rootCert = new X509Certificate2 (Convert.FromBase64String (certString));
+ if (!store.Certificates.Contains (rootCert))
+ store.Add (rootCert);
+
+ store.Close();
+
+ byte[] certData = new byte[] {0x30,0x82,0x02,0xFA,0x30,0x82,0x01,0xE2,0xA0,0x03,0x02,0x01,0x02,0x02,0x03,0x01,0x4F,0x55,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x30,0x2E,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x5A,0x31,0x0E,0x30,0x0C,0x06,0x03,0x55,0x04,0x0A,0x13,0x05,0x52,0x65,0x62,0x65,0x78,0x31,0x0F,0x30,0x0D,0x06,0x03,0x55,0x04,0x03,0x13,0x06,0x54,0x65,0x73,0x74,0x43,0x41,0x30,0x1E,0x17,0x0D,0x31,0x32,0x30,0x34,0x32,0x32,0x31,0x38,0x33,0x31,0x35,0x33,0x5A,0x17,0x0D,0x34,0x39,0x31,0x32,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x30,0x37,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x5A,0x31,0x0E,0x30,0x0C,0x06,0x03,0x55,0x04,0x0A,0x13,0x05,0x52,0x65,0x62,0x65,0x78,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x03,0x13,0x0F,0x77,0x69,0x6E,0x30,0x31,0x2E,0x64,0x30,0x35,0x2E,0x6C,0x6F,0x63,0x61,0x6C,0x30,0x81,0x9F,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8D,0x00,0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xF1,0x4F,0xAC,0x71,0x70,0x8F,0x8A,0xFE,0x38,0x67,0xA7,0x21,0x56,0x8B,0x34,0xBC,0xF5,0xCD,0x48,0x1C,0x69,0xEB,0x83,0x98,0x69,0x3D,0x33,0x2A,0x7B,0x04,0xB1,0x0A,0xA9,0x2C,0x17,0xDD,0x41,0xEC,0x21,0x91,0xB8,0x12,0x95,0xB0,0x4C,0x2A,0x53,0xBF,0x06,0x47,0x72,0xBB,0x68,0xCA,0x49,0x34,0x15,0x7B,0x78,0x4F,0x42,0x03,0xD9,0x58,0xEE,0x9D,0x72,0x61,0xAD,0xAD,0x0C,0x28,0x65,0x61,0x48,0xF8,0x68,0xB5,0x16,0x19,0xD0,0xDD,0x47,0x44,0x86,0xE3,0xA6,0x93,0x81,0xD5,0xA1,0x70,0x23,0x05,0x74,0x33,0xD1,0xD2,0x21,0x17,0x68,0xAF,0x5F,0x25,0xD5,0x8C,0x72,0xF6,0x28,0xF4,0x1F,0x42,0x24,0xCF,0x18,0x7B,0x5D,0xCE,0x29,0x43,0xF2,0x10,0xB6,0x73,0x65,0x4C,0x0A,0x17,0x02,0x03,0x01,0x00,0x01,0xA3,0x81,0x9B,0x30,0x81,0x98,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0x14,0x00,0x58,0x48,0x55,0x6C,0x45,0xC6,0xCC,0x06,0x25,0x2D,0xD3,0xBA,0x0C,0x08,0x81,0x00,0x58,0xDF,0x30,0x13,0x06,0x03,0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x01,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x3D,0x6F,0xDB,0x4B,0x4F,0x82,0xF1,0xD3,0x10,0xAF,0xF4,0x78,0xB3,0xB4,0xF6,0x3D,0x2B,0x2F,0x6A,0x97,0x30,0x31,0x06,0x03,0x55,0x1D,0x1F,0x04,0x2A,0x30,0x28,0x30,0x26,0xA0,0x24,0xA0,0x22,0x86,0x20,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x74,0x65,0x73,0x74,0x2D,0x63,0x61,0x2E,0x6C,0x6F,0x63,0x61,0x6C,0x2F,0x74,0x65,0x73,0x74,0x2D,0x63,0x61,0x2E,0x63,0x72,0x6C,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x22,0x48,0xC3,0x95,0x3A,0x51,0x72,0x15,0x41,0x5B,0x47,0xC4,0xC5,0x4E,0x2E,0x97,0xAC,0x1D,0x0B,0xD1,0xA4,0x38,0xF2,0xFB,0x6E,0x33,0x9D,0xC8,0x93,0x4C,0x88,0x34,0xA3,0x68,0xC7,0xC6,0x42,0x51,0x54,0x31,0x72,0x72,0xEB,0xEE,0x5C,0xF0,0x7D,0xC9,0xC8,0xAE,0x24,0x9F,0xA0,0x1D,0x2E,0xEE,0x84,0x55,0xC3,0x3A,0xC4,0xCE,0xE1,0xB3,0xA2,0xD2,0x1F,0x44,0xC8,0x81,0x0F,0x9C,0xED,0x5B,0x17,0xBB,0x2C,0xDA,0x4A,0x9D,0xF7,0x7D,0x5A,0x08,0x6C,0xA3,0xF4,0xCB,0x55,0xE6,0x1A,0xAA,0xC7,0x14,0x16,0x7D,0x46,0xD0,0x7C,0x71,0xA8,0xA7,0xEA,0xBF,0xA6,0x92,0xD4,0xC5,0x7A,0xB8,0x45,0x3A,0x00,0xB3,0xDC,0x76,0x2E,0xEB,0xB9,0xF4,0x6B,0xDC,0xF2,0xC4,0x7C,0x0C,0xD5,0x1C,0x73,0xE8,0xE1,0xBB,0xC1,0x5C,0xCC,0xD9,0xBE,0xDE,0x61,0x4D,0xEF,0x2B,0x23,0xFA,0xA6,0xF6,0xED,0x4F,0x5F,0x2C,0xCA,0x68,0x29,0x59,0x27,0x82,0x41,0x5E,0xAD,0xC8,0x93,0xBF,0x83,0x01,0x8F,0x32,0xCB,0x79,0xEE,0x93,0x4C,0xCB,0x87,0x48,0x62,0x0D,0x44,0xD7,0x80,0x31,0x87,0x41,0x72,0x2D,0x12,0xA0,0x2C,0x99,0x89,0x08,0x5F,0xE9,0xFE,0x5E,0xB4,0xEC,0xCB,0x6C,0x23,0xC1,0xB8,0xE4,0xD6,0x1E,0x4B,0x9C,0x88,0x0A,0x63,0x65,0x78,0xC0,0x37,0xAC,0x54,0xCB,0xDE,0xA9,0x0F,0x59,0x43,0x1E,0x41,0xF5,0x32,0xAC,0x85,0x69,0xE9,0xBA,0xA6,0x78,0x87,0x88,0x8B,0x71,0xFB,0xE4,0x51,0xC0,0xF5,0xB7,0x4C,0x1F,0xCF,0x6A,0x1C,0xF6,0x1B,0x27,0x50,0xE9,0xAC,0xBF,0xB7,0x4E};
+
+ X509Certificate2 cert = new X509Certificate2 (certData);
+ X509Chain chain = new X509Chain (false);
+ Assert.False (chain.Build (cert), "Online");
+
+ chain.ChainPolicy.RevocationMode = X509RevocationMode.Offline;
+ Assert.False (chain.Build (cert), "Offline");
+
+ chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
+ Assert.True (chain.Build (cert), "NoCheck");
+ }
+
+ byte[] sha256_data = {
+ 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41,
+ 0x54, 0x45, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0D, 0x0A, 0x4D, 0x49, 0x49, 0x43, 0x78, 0x44, 0x43, 0x43, 0x41, 0x61, 0x79,
+ 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x44, 0x41, 0x4B, 0x37, 0x6C, 0x4D, 0x41, 0x30, 0x47, 0x43, 0x53, 0x71,
+ 0x47, 0x53, 0x49, 0x62, 0x33, 0x44, 0x51, 0x45, 0x42, 0x43, 0x77, 0x55, 0x41, 0x4D, 0x43, 0x34, 0x78, 0x43, 0x7A, 0x41,
+ 0x4A, 0x42, 0x67, 0x4E, 0x56, 0x42, 0x41, 0x59, 0x54, 0x41, 0x6B, 0x4E, 0x61, 0x0D, 0x0A, 0x4D, 0x51, 0x34, 0x77, 0x44,
+ 0x41, 0x59, 0x44, 0x56, 0x51, 0x51, 0x4B, 0x45, 0x77, 0x56, 0x53, 0x5A, 0x57, 0x4A, 0x6C, 0x65, 0x44, 0x45, 0x50, 0x4D,
+ 0x41, 0x30, 0x47, 0x41, 0x31, 0x55, 0x45, 0x41, 0x78, 0x4D, 0x47, 0x56, 0x47, 0x56, 0x7A, 0x64, 0x45, 0x4E, 0x42, 0x4D,
+ 0x42, 0x34, 0x58, 0x44, 0x54, 0x45, 0x7A, 0x4D, 0x44, 0x55, 0x78, 0x4F, 0x54, 0x45, 0x79, 0x4E, 0x44, 0x63, 0x31, 0x0D,
+ 0x0A, 0x4E, 0x31, 0x6F, 0x58, 0x44, 0x54, 0x51, 0x35, 0x4D, 0x54, 0x49, 0x7A, 0x4D, 0x54, 0x41, 0x77, 0x4D, 0x44, 0x41,
+ 0x77, 0x4D, 0x46, 0x6F, 0x77, 0x4F, 0x6A, 0x45, 0x57, 0x4D, 0x42, 0x51, 0x47, 0x41, 0x31, 0x55, 0x45, 0x41, 0x78, 0x4D,
+ 0x4E, 0x55, 0x6D, 0x56, 0x69, 0x5A, 0x58, 0x67, 0x67, 0x55, 0x33, 0x56, 0x77, 0x63, 0x47, 0x39, 0x79, 0x64, 0x44, 0x45,
+ 0x67, 0x4D, 0x42, 0x34, 0x47, 0x0D, 0x0A, 0x43, 0x53, 0x71, 0x47, 0x53, 0x49, 0x62, 0x33, 0x44, 0x51, 0x45, 0x4A, 0x41,
+ 0x52, 0x59, 0x52, 0x63, 0x33, 0x56, 0x77, 0x63, 0x47, 0x39, 0x79, 0x64, 0x45, 0x42, 0x79, 0x5A, 0x57, 0x4A, 0x6C, 0x65,
+ 0x43, 0x35, 0x75, 0x5A, 0x58, 0x51, 0x77, 0x67, 0x5A, 0x38, 0x77, 0x44, 0x51, 0x59, 0x4A, 0x4B, 0x6F, 0x5A, 0x49, 0x68,
+ 0x76, 0x63, 0x4E, 0x41, 0x51, 0x45, 0x42, 0x42, 0x51, 0x41, 0x44, 0x0D, 0x0A, 0x67, 0x59, 0x30, 0x41, 0x4D, 0x49, 0x47,
+ 0x4A, 0x41, 0x6F, 0x47, 0x42, 0x41, 0x4B, 0x7A, 0x36, 0x49, 0x37, 0x49, 0x59, 0x4E, 0x4A, 0x4C, 0x44, 0x43, 0x36, 0x42,
+ 0x79, 0x44, 0x32, 0x75, 0x59, 0x36, 0x69, 0x55, 0x61, 0x34, 0x30, 0x54, 0x34, 0x37, 0x34, 0x44, 0x41, 0x65, 0x59, 0x55,
+ 0x49, 0x31, 0x37, 0x43, 0x79, 0x39, 0x55, 0x6B, 0x77, 0x62, 0x4E, 0x4D, 0x2B, 0x6B, 0x39, 0x62, 0x57, 0x0D, 0x0A, 0x68,
+ 0x75, 0x46, 0x62, 0x65, 0x63, 0x56, 0x42, 0x6D, 0x43, 0x37, 0x42, 0x79, 0x31, 0x6C, 0x48, 0x65, 0x2B, 0x79, 0x41, 0x59,
+ 0x59, 0x78, 0x78, 0x74, 0x47, 0x50, 0x7A, 0x41, 0x48, 0x58, 0x50, 0x76, 0x68, 0x4A, 0x4D, 0x56, 0x50, 0x41, 0x2F, 0x37,
+ 0x4C, 0x36, 0x41, 0x4B, 0x58, 0x6D, 0x6A, 0x71, 0x69, 0x77, 0x78, 0x7A, 0x47, 0x51, 0x79, 0x30, 0x73, 0x59, 0x67, 0x2F,
+ 0x6A, 0x36, 0x79, 0x0D, 0x0A, 0x6F, 0x58, 0x39, 0x36, 0x39, 0x52, 0x53, 0x30, 0x49, 0x58, 0x33, 0x75, 0x33, 0x64, 0x31,
+ 0x72, 0x35, 0x61, 0x6F, 0x44, 0x76, 0x36, 0x4A, 0x58, 0x53, 0x69, 0x53, 0x73, 0x75, 0x67, 0x78, 0x56, 0x47, 0x69, 0x65,
+ 0x54, 0x53, 0x2F, 0x50, 0x71, 0x55, 0x6E, 0x6E, 0x76, 0x72, 0x49, 0x74, 0x59, 0x78, 0x6F, 0x64, 0x4F, 0x31, 0x58, 0x79,
+ 0x76, 0x41, 0x67, 0x4D, 0x42, 0x41, 0x41, 0x47, 0x6A, 0x0D, 0x0A, 0x59, 0x7A, 0x42, 0x68, 0x4D, 0x41, 0x34, 0x47, 0x41,
+ 0x31, 0x55, 0x64, 0x44, 0x77, 0x45, 0x42, 0x2F, 0x77, 0x51, 0x45, 0x41, 0x77, 0x49, 0x45, 0x38, 0x44, 0x41, 0x64, 0x42,
+ 0x67, 0x4E, 0x56, 0x48, 0x51, 0x34, 0x45, 0x46, 0x67, 0x51, 0x55, 0x66, 0x75, 0x52, 0x51, 0x78, 0x4E, 0x75, 0x59, 0x71,
+ 0x77, 0x73, 0x38, 0x56, 0x48, 0x7A, 0x4A, 0x6D, 0x4A, 0x50, 0x6F, 0x39, 0x41, 0x45, 0x6F, 0x0D, 0x0A, 0x6F, 0x50, 0x77,
+ 0x77, 0x44, 0x77, 0x59, 0x44, 0x56, 0x52, 0x30, 0x6C, 0x42, 0x41, 0x67, 0x77, 0x42, 0x67, 0x59, 0x45, 0x56, 0x52, 0x30,
+ 0x6C, 0x41, 0x44, 0x41, 0x66, 0x42, 0x67, 0x4E, 0x56, 0x48, 0x53, 0x4D, 0x45, 0x47, 0x44, 0x41, 0x57, 0x67, 0x42, 0x51,
+ 0x39, 0x62, 0x39, 0x74, 0x4C, 0x54, 0x34, 0x4C, 0x78, 0x30, 0x78, 0x43, 0x76, 0x39, 0x48, 0x69, 0x7A, 0x74, 0x50, 0x59,
+ 0x39, 0x0D, 0x0A, 0x4B, 0x79, 0x39, 0x71, 0x6C, 0x7A, 0x41, 0x4E, 0x42, 0x67, 0x6B, 0x71, 0x68, 0x6B, 0x69, 0x47, 0x39,
+ 0x77, 0x30, 0x42, 0x41, 0x51, 0x73, 0x46, 0x41, 0x41, 0x4F, 0x43, 0x41, 0x51, 0x45, 0x41, 0x41, 0x59, 0x62, 0x69, 0x46,
+ 0x41, 0x6D, 0x33, 0x6E, 0x71, 0x61, 0x6F, 0x4A, 0x51, 0x45, 0x41, 0x6D, 0x37, 0x7A, 0x34, 0x33, 0x71, 0x6E, 0x71, 0x41,
+ 0x6B, 0x41, 0x6E, 0x35, 0x30, 0x76, 0x6F, 0x0D, 0x0A, 0x75, 0x4F, 0x39, 0x4E, 0x57, 0x61, 0x33, 0x53, 0x43, 0x45, 0x38,
+ 0x78, 0x6B, 0x4C, 0x55, 0x2B, 0x31, 0x50, 0x62, 0x67, 0x76, 0x6F, 0x48, 0x4E, 0x50, 0x54, 0x6A, 0x36, 0x4D, 0x51, 0x30,
+ 0x59, 0x37, 0x6F, 0x63, 0x2B, 0x6D, 0x42, 0x75, 0x55, 0x6B, 0x5A, 0x52, 0x63, 0x4B, 0x33, 0x51, 0x4C, 0x69, 0x58, 0x6C,
+ 0x62, 0x34, 0x66, 0x6E, 0x7A, 0x39, 0x59, 0x55, 0x36, 0x66, 0x69, 0x7A, 0x4A, 0x0D, 0x0A, 0x79, 0x6A, 0x33, 0x76, 0x33,
+ 0x42, 0x34, 0x6B, 0x4A, 0x33, 0x5A, 0x62, 0x42, 0x6D, 0x38, 0x48, 0x4E, 0x34, 0x78, 0x79, 0x44, 0x62, 0x66, 0x6E, 0x77,
+ 0x6C, 0x67, 0x42, 0x55, 0x65, 0x6F, 0x68, 0x78, 0x61, 0x36, 0x2B, 0x50, 0x78, 0x67, 0x2F, 0x37, 0x72, 0x39, 0x34, 0x78,
+ 0x54, 0x4A, 0x72, 0x35, 0x46, 0x30, 0x43, 0x68, 0x2F, 0x41, 0x68, 0x2F, 0x6D, 0x59, 0x37, 0x66, 0x4B, 0x6C, 0x50, 0x0D,
+ 0x0A, 0x46, 0x46, 0x35, 0x47, 0x68, 0x4A, 0x2B, 0x62, 0x34, 0x76, 0x55, 0x6F, 0x36, 0x47, 0x74, 0x6E, 0x79, 0x6F, 0x4F,
+ 0x33, 0x58, 0x57, 0x4C, 0x45, 0x34, 0x4D, 0x38, 0x4B, 0x67, 0x68, 0x6C, 0x39, 0x78, 0x48, 0x4E, 0x32, 0x52, 0x76, 0x57,
+ 0x47, 0x45, 0x39, 0x4B, 0x6F, 0x31, 0x4B, 0x31, 0x55, 0x62, 0x42, 0x62, 0x53, 0x4A, 0x51, 0x4D, 0x76, 0x66, 0x65, 0x49,
+ 0x65, 0x52, 0x38, 0x32, 0x71, 0x0D, 0x0A, 0x69, 0x66, 0x37, 0x49, 0x30, 0x56, 0x2B, 0x77, 0x59, 0x70, 0x57, 0x61, 0x4B,
+ 0x79, 0x5A, 0x68, 0x33, 0x6C, 0x50, 0x4C, 0x34, 0x33, 0x67, 0x35, 0x4C, 0x4F, 0x42, 0x34, 0x75, 0x51, 0x6C, 0x68, 0x76,
+ 0x76, 0x50, 0x4D, 0x5A, 0x63, 0x43, 0x48, 0x36, 0x4F, 0x37, 0x37, 0x37, 0x6E, 0x2F, 0x33, 0x4C, 0x2B, 0x54, 0x6C, 0x32,
+ 0x2F, 0x41, 0x56, 0x31, 0x73, 0x7A, 0x73, 0x67, 0x53, 0x6B, 0x54, 0x0D, 0x0A, 0x47, 0x79, 0x74, 0x54, 0x75, 0x4B, 0x6A,
+ 0x51, 0x35, 0x6E, 0x50, 0x53, 0x58, 0x76, 0x65, 0x44, 0x39, 0x76, 0x4B, 0x42, 0x50, 0x2F, 0x58, 0x4C, 0x73, 0x54, 0x4D,
+ 0x75, 0x69, 0x6A, 0x48, 0x4C, 0x43, 0x68, 0x57, 0x55, 0x69, 0x33, 0x74, 0x4B, 0x7A, 0x49, 0x48, 0x6F, 0x66, 0x4B, 0x6F,
+ 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, };
+
+ [Test]
+ public void Sha256 ()
+ {
+ X509Certificate2 c = new X509Certificate2 (sha256_data);
+ // can't build is fine - as long as we do not throw
+ Assert.False (new X509Chain (false).Build (c), "Build");
+ }
+ }
+}
diff --git a/tests/linker-ios/link sdk/DataContractTest.cs b/tests/linker-ios/link sdk/DataContractTest.cs
new file mode 100644
index 000000000000..e76945d78fd7
--- /dev/null
+++ b/tests/linker-ios/link sdk/DataContractTest.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+#if XAMCORE_2_0
+using Foundation;
+#else
+using MonoTouch.Foundation;
+#endif
+using NUnit.Framework;
+
+namespace LinkSdk {
+
+ [DataContract(Namespace="XamarinBugExample")]
+ public enum MyEnum : short
+ {
+ [EnumMember]
+ Foo = 0,
+ [EnumMember]
+ Bar = 1,
+ [EnumMember]
+ Baz = 2
+ }
+
+ [DataContract(Namespace="XamarinBugExample")]
+ public class MyClass
+ {
+ public MyClass() { }
+
+ [DataMember]
+ List MyList { get; set; }
+ }
+
+ [TestFixture]
+ // we want the test to be availble if we use the linker
+ [Preserve (AllMembers = true)]
+ public class CrashExample {
+
+ [Test]
+ // http://forums.xamarin.com/discussion/7380/type-cast-error-in-xamarin-6-4-3-on-device-only#latest
+ // could not be reproduced with 6.4.4
+ public void DoCrash()
+ {
+ System.Collections.IList lst = new List();
+ object value = Enum.Parse (typeof(MyEnum), "1");
+ lst.Add (value); // Exception here. List.cs throws ArgumentException.
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/linker-ios/link sdk/DllImportTest.cs b/tests/linker-ios/link sdk/DllImportTest.cs
new file mode 100644
index 000000000000..7569f209b9d7
--- /dev/null
+++ b/tests/linker-ios/link sdk/DllImportTest.cs
@@ -0,0 +1,77 @@
+//
+// Unit tests for [DllImport]
+//
+// Authors:
+// Sebastien Pouliot
+//
+// Copyright 2014-2015 Xamarin Inc. All rights reserved.
+//
+
+using System;
+using System.Net.NetworkInformation;
+using System.Runtime.InteropServices;
+#if XAMCORE_2_0
+using Foundation;
+using ObjCRuntime;
+#else
+using MonoTouch;
+using MonoTouch.Foundation;
+using MonoTouch.ObjCRuntime;
+#endif
+using NUnit.Framework;
+
+namespace LinkSdk {
+
+ [TestFixture]
+ [Preserve (AllMembers = true)]
+ public class DllImportTest {
+
+ class NestedFirstLevel {
+
+ public class NestedSecondLevel {
+
+ [DllImport ("__Internal")]
+ public extern static string xamarin_get_locale_country_code ();
+ }
+ }
+
+ [Test]
+ public void ScanForStrip_17327 ()
+ {
+ // note: must be tested on a release (strip'ed) build
+ Assert.NotNull (NestedFirstLevel.NestedSecondLevel.xamarin_get_locale_country_code ());
+ }
+
+ [Test]
+ public void Sqlite3 ()
+ {
+ var lib = Dlfcn.dlopen ("/usr/lib/libsqlite3.dylib", 0);
+ Assert.That (lib, Is.Not.EqualTo (IntPtr.Zero), "/usr/lib/libsqlite3.dylib");
+ try {
+ Assert.That (Dlfcn.dlsym (lib, "sqlite3_bind_int"), Is.Not.EqualTo (IntPtr.Zero), "sqlite3_bind_int");
+ // iOS does not have some symbols defined - if that change/fail in the future we'll need to update Mono.Data.Sqlite
+ Assert.That (Dlfcn.dlsym (lib, "sqlite3_key"), Is.EqualTo (IntPtr.Zero), "sqlite3_key");
+ Assert.That (Dlfcn.dlsym (lib, "sqlite3_rekey"), Is.EqualTo (IntPtr.Zero), "sqlite3_rekey");
+ Assert.That (Dlfcn.dlsym (lib, "sqlite3_column_database_name"), Is.EqualTo (IntPtr.Zero), "sqlite3_column_database_name");
+ Assert.That (Dlfcn.dlsym (lib, "sqlite3_column_database_name16"), Is.EqualTo (IntPtr.Zero), "sqlite3_column_database_name16");
+ Assert.That (Dlfcn.dlsym (lib, "sqlite3_column_origin_name"), Is.EqualTo (IntPtr.Zero), "sqlite3_column_origin_name");
+ Assert.That (Dlfcn.dlsym (lib, "sqlite3_column_origin_name16"), Is.EqualTo (IntPtr.Zero), "sqlite3_column_origin_name16");
+ Assert.That (Dlfcn.dlsym (lib, "sqlite3_column_table_name"), Is.EqualTo (IntPtr.Zero), "sqlite3_column_table_name");
+ Assert.That (Dlfcn.dlsym (lib, "sqlite3_column_table_name16"), Is.EqualTo (IntPtr.Zero), "sqlite3_column_table_name16");
+ }
+ finally {
+ Dlfcn.dlclose (lib);
+ }
+ }
+
+ [Test]
+ public void LackOfCapget ()
+ {
+ // OSX/iOS libc (libSystem.dylib) does not have a capget - which breaks dlsym=false (required for tvOS)
+ // iOS (tvOS/watchOS) does not support Process to run ping either so it ends up with a InvalidOperationException
+ // which is now "optimized" to reduce code size (and remove DllImport) until we implement ping (see: #964)
+ var p = new Ping ();
+ Assert.Throws (delegate { p.Send ("localhost"); });
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/linker-ios/link sdk/Info.plist b/tests/linker-ios/link sdk/Info.plist
new file mode 100644
index 000000000000..63e5f235fd48
--- /dev/null
+++ b/tests/linker-ios/link sdk/Info.plist
@@ -0,0 +1,30 @@
+
+
+
+
+ CFBundleDisplayName
+ LinkSdkTest
+ CFBundleIdentifier
+ com.xamarin.linksdk
+ UIDeviceFamily
+
+ 1
+ 2
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ MinimumOSVersion
+ 5.1.1
+
+
diff --git a/tests/linker-ios/link sdk/LinkExtraDefsTest.cs b/tests/linker-ios/link sdk/LinkExtraDefsTest.cs
new file mode 100644
index 000000000000..fb00eb7d05da
--- /dev/null
+++ b/tests/linker-ios/link sdk/LinkExtraDefsTest.cs
@@ -0,0 +1,65 @@
+//
+// Unit tests for the mtouch's --xml linker option
+//
+// Authors:
+// Sebastien Pouliot
+//
+// Copyright 2012 Xamarin Inc. All rights reserved.
+//
+
+using System;
+using System.Reflection;
+#if XAMCORE_2_0
+using Foundation;
+#else
+using MonoTouch.Foundation;
+#endif
+using NUnit.Framework;
+
+namespace LinkSdk {
+
+ [TestFixture]
+ [Preserve (AllMembers = true)]
+ public class LinkExtraDefsTest {
+
+ // ensure the types in extra-linker-defs.xml are included
+ // even if they are:
+ // * part of SDK / product assemblies, where adding [Preserve] is not possible;
+ // * not used anywhere in this application
+
+ // note: reflection is used so we're testing the XML-based preservation
+ // not the normal linking process
+
+ [Test]
+ public void Corlib ()
+ {
+ Type t = Type.GetType ("System.Security.HostSecurityManager, mscorlib");
+ Assert.NotNull (t, "System.Security.HostSecurityManager");
+ }
+
+ [Test]
+ public void System ()
+ {
+ Type t = Type.GetType ("System.Net.Mime.ContentType, System");
+ Assert.NotNull (t, "System.Net.Mime.ContentType");
+ // we asked for ParseValue to be preserved
+ Assert.NotNull (t.GetMethod ("ParseValue", BindingFlags.Instance | BindingFlags.NonPublic), "Parse");
+ }
+
+#if !__WATCHOS__
+ [Test]
+ public void MonoTouch ()
+ {
+#if XAMCORE_2_0
+ Type t = Type.GetType ("CoreBluetooth.CBUUID, " + typeof(NSObject).Assembly.ToString ());
+#else
+ Type t = Type.GetType ("MonoTouch.CoreBluetooth.CBUUID, monotouch, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
+#endif
+ Assert.NotNull (t, "[MonoTouch.]CoreBluetooth.CBUUID");
+ // check (generated) fields since we instructed the linker to keep them
+ var f = t.GetFields (BindingFlags.NonPublic | BindingFlags.Static);
+ Assert.That (f.Length, Is.Not.EqualTo (0), "fields were preserved");
+ }
+#endif
+ }
+}
\ No newline at end of file
diff --git a/tests/linker-ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker-ios/link sdk/LinkSdkRegressionTest.cs
new file mode 100644
index 000000000000..a8a13763efdd
--- /dev/null
+++ b/tests/linker-ios/link sdk/LinkSdkRegressionTest.cs
@@ -0,0 +1,1047 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Json;
+using System.Linq;
+using System.Net;
+using System.Net.NetworkInformation;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+using System.Security.Permissions;
+using System.Threading;
+using System.Xml;
+using Mono.Data.Sqlite;
+using MonoTouch;
+#if XAMCORE_2_0
+#if !__TVOS__ && !__WATCHOS__
+using AddressBook;
+using AddressBookUI;
+#endif
+#if !__WATCHOS__
+using CoreAnimation;
+#endif
+using CoreData;
+using CoreFoundation;
+using Foundation;
+using ObjCRuntime;
+#if !__TVOS__
+using MapKit;
+#endif
+using UIKit;
+#if !__WATCHOS__
+using OpenGLES;
+#endif
+#else
+using MonoTouch;
+using MonoTouch.AddressBook;
+using MonoTouch.AddressBookUI;
+using MonoTouch.CoreAnimation;
+using MonoTouch.CoreData;
+using MonoTouch.CoreFoundation;
+using MonoTouch.Foundation;
+using MonoTouch.ObjCRuntime;
+using MonoTouch.MapKit;
+using MonoTouch.UIKit;
+using MonoTouch.OpenGLES;
+#endif
+using NUnit.Framework;
+
+namespace LinkSdk {
+
+ [FileIOPermission (SecurityAction.LinkDemand, AllLocalFiles = FileIOPermissionAccess.AllAccess)]
+ public class SecurityDeclarationDecoratedUserCode {
+
+ [FileIOPermission (SecurityAction.Assert, AllLocalFiles = FileIOPermissionAccess.NoAccess)]
+ static public bool Check ()
+ {
+ return true;
+ }
+ }
+
+ [TestFixture]
+ // we want the test to be availble if we use the linker
+ [Preserve (AllMembers = true)]
+ public class LinkSdkRegressionTest {
+
+ [Test]
+ // https://github.com/xamarin/monotouch/commit/cbefbeaea2eda820dfc7214e976edc83a55df38e
+ public void MonoAssembly_LinkedOut ()
+ {
+ Assembly a = Assembly.GetExecutingAssembly ();
+ Assert.That (a.GetType ().Name, Is.EqualTo ("MonoAssembly"), "MonoAssembly");
+ }
+
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=205
+ // https://bugzilla.novell.com/show_bug.cgi?id=688414
+ public void Bug205_ExposingIEnumerable ()
+ {
+ var ds = new DataContractSerializer (typeof (IEnumerable));
+ using (var xw = XmlWriter.Create (System.IO.Stream.Null))
+ ds.WriteObject (xw, new int [] { 1, 2, 3 });
+ // the above should not throw System.Runtime.Serialization.SerializationException
+ }
+
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=233
+ public void Bug233_MonoPInvokeCallback ()
+ {
+ var c = new SqliteConnection ("Data Source=:memory:");
+ c.Open ();
+ c.Update += (sender, e) => {};
+ // the above should not crash
+ c.Close ();
+ }
+
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=234
+ public void Bug234_Interlocked ()
+ {
+ string str = null;
+ Assert.Null (Interlocked.Exchange (ref str, "one"), "Exchange");
+ // the above should not crash with System.ExecutionEngineException
+ Assert.That (str, Is.EqualTo ("one"), "one");
+ }
+
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=300
+ // http://stackoverflow.com/questions/6517736/monotouch-crash-dictionary-firstordefault-type-initializer-predicateof
+ public void Bug300_Linker_PredicateOf ()
+ {
+ Dictionary queued = new Dictionary ();
+ KeyValuePair valuePair = queued.FirstOrDefault ();
+ // above should not crash with System.ExecutionEngineException
+ Assert.NotNull (valuePair);
+ }
+
+#if !__WATCHOS__
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=328
+ public void Bug328_CompletionBlock ()
+ {
+ CATransaction.Begin ();
+ CATransaction.CompletionBlock = delegate {};
+ // the above should not crash with a MonoTouchException
+ CATransaction.Commit ();
+ }
+#endif // !__WATCHOS__
+
+#if !__TVOS__ && !__WATCHOS__
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=769
+ public void Bug769_UnregistredDelegate ()
+ {
+ var tmp = Class.ThrowOnInitFailure;
+ Class.ThrowOnInitFailure = false;
+ try {
+ Assert.NotNull (new MKMapViewDelegate ());
+ // the above should not throw an Exception
+ } finally {
+ Class.ThrowOnInitFailure = tmp;
+ }
+ }
+#endif // !__TVOS__ && !__WATCHOS__
+
+#if !__WATCHOS__
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=865
+ public void Bug865_CanOpenUrl ()
+ {
+ Assert.False (UIApplication.SharedApplication.CanOpenUrl (null), "null");
+ // the above should not throw an ArgumentNullException
+ // and that's important because NSUrl.FromString and NSUrl.ctor(string) differs
+ const string bad_tel = "tel://1800 023 009";
+ Assert.Null (NSUrl.FromString (bad_tel), "bad url");
+ // we now throw if `init*` fails
+ Assert.Throws (() => new NSUrl (bad_tel), "ctor, bad url");
+ }
+#endif // !__WATCHOS__
+
+ [Test]
+ // issue indirectly found when trying: http://bugzilla.xamarin.com/show_bug.cgi?id=928
+ // similar to MonoAssembly_LinkedOut
+ // https://github.com/xamarin/monotouch/commit/409316f87f23723a384cb072163abd03ae7e6045
+ public void Bug928_MonoModule_LinkedOut ()
+ {
+ Module m = Assembly.GetExecutingAssembly ().ManifestModule;
+ Assert.That (m.GetType ().Name, Is.EqualTo ("MonoModule"), "MonoModule");
+ }
+
+#if !__TVOS__ && !__WATCHOS__
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=980
+ public void Bug980_AddressBook_NRE ()
+ {
+ using (ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController ()) {
+ // no NRE should occur
+ if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0))
+ Assert.Null (picker.AddressBook);
+ else
+ Assert.NotNull (picker.AddressBook);
+ }
+ }
+
+ [Test]
+ public void AddressBook_Constants ()
+ {
+ // we want to ensure we can get the constants without authorization (on iOS 6.0+) so this application
+ // needs to be unauthorized (in settings.app). Note: authorization checks only occurs on devices
+ if ((Runtime.Arch == Arch.DEVICE) && UIDevice.CurrentDevice.CheckSystemVersion (6,0)) {
+ Assert.That (ABAddressBook.GetAuthorizationStatus (), Is.Not.EqualTo (ABAuthorizationStatus.Authorized),
+ "Please deny access to contacts for this this application (it's important for this test)");
+ }
+ Assert.IsNotNull (ABPersonAddressKey.City, "ABPersonAddressKey");
+ }
+#endif // !__TVOS__ && !__WATCHOS__
+
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=1387
+ public void Bug1387_UIEdgeInsets_ToString ()
+ {
+ var insets = new UIEdgeInsets (1, 2, 3, 4);
+ Assert.False (insets.ToString ().Contains ("UIEdgeInsets"));
+ }
+
+ void CheckExceptionDetailProperty (PropertyInfo pi)
+ {
+ bool data_member = true;
+ foreach (var ca in pi.GetCustomAttributes (false)) {
+ if (ca is DataMemberAttribute) {
+ data_member = true;
+ break;
+ }
+ }
+ // to be valid both getter and setter must be present if [DataMember]
+ if (data_member) {
+ Assert.NotNull (pi.GetGetMethod (true), "get_" + pi.Name);
+ Assert.NotNull (pi.GetSetMethod (true), "set_" + pi.Name);
+ } else {
+ // check well-known [DataMember]
+ switch (pi.Name) {
+ case "HelpLink":
+ case "InnerException":
+ case "Message":
+ case "StackTrace":
+ case "Type":
+ Assert.Fail ("{0} is missing it's [DataMember] attribute", pi.Name);
+ break;
+ }
+ }
+ }
+
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=1415
+ public void Bug1415_Linker_DataMember ()
+ {
+ // the typeof ensure we're can't (totally) link away System.ServiceModel.dll
+ Type ed = typeof (System.ServiceModel.AuditLevel).Assembly.GetType ("System.ServiceModel.ExceptionDetail", false);
+ // which means it's [DataContract] / [DataMember] should not be linked out
+ // even if we're not specifically using them (and without [Preserve] being added)
+ // which is important since System.ServiceModel.dll is an SDK assembly
+ Assert.NotNull (ed, "ExceptionDetail");
+ bool help_link = false;
+ bool inner_exception = false;
+ bool message = false;
+ bool stack_trace = false;
+ bool type = false;
+ foreach (var pi in ed.GetProperties ()) {
+ CheckExceptionDetailProperty (pi);
+ switch (pi.Name) {
+ case "HelpLink":
+ help_link = true;
+ break;
+ case "InnerException":
+ inner_exception = true;
+ break;
+ case "Message":
+ message = true;
+ break;
+ case "StackTrace":
+ stack_trace = true;
+ break;
+ case "Type":
+ type = true;
+ break;
+ }
+ }
+ // ensure all properties are still present
+ Assert.True (help_link, "HelpLink");
+ Assert.True (inner_exception, "InnerException");
+ Assert.True (message, "Message");
+ Assert.True (stack_trace, "StackTrace");
+ Assert.True (type, "Type");
+ }
+
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=1415
+ // not really part of the bug - but part of the same fix
+ public void Bug1415_Linker_XmlAttribute ()
+ {
+ // the typeof ensure we're can't (totally) link away System.ServiceModel.dll
+ Type ed = typeof (System.ServiceModel.AuditLevel).Assembly.GetType ("System.ServiceModel.EndpointAddress10", false);
+ // type is decorated with both [XmlSchemaProvider] and [XmlRoot]
+ Assert.NotNull (ed, "EndpointAddress10");
+
+#if !__WATCHOS__ // FIXME: this needs to use a different type than OpenTK.Quaternion, so that the test can run on WatchOS as wells
+ var q = new OpenTK.Quaternion ();
+ Assert.Null (q.GetType ().GetProperty ("XYZ"), "XmlIgnore");
+ // should be null if application is linked (won't be if "Don't link" is used)
+#endif // !__WATCHOS__
+ }
+
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=1443
+ public void Bug1443_Linq_Aot ()
+ {
+ List list = new List ();
+ Dictionary dict = new Dictionary ();
+ list.AddRange (from kv in dict orderby kv.Key select kv.Value.ToString ());
+ // should not throw an ExecutionEngineException on devices
+ }
+
+#if !__TVOS__ && !__WATCHOS__
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=1516
+ public void Bug1516_Appearance_Linker ()
+ {
+ // iOS7, since DP3, validates ?some? appearance properties, e.g.
+ // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -setTintColor: is not allowed for use with the appearance proxy. Perhaps you want to use the barTintColor property.
+ // UINavigationBar.Appearance.TintColor = UIColor.FromRGB (238,234,222);
+ UINavigationBar.Appearance.SetTitleTextAttributes (new UITextAttributes () {
+ TextColor = UIColor.FromRGB (85, 108, 17),
+ TextShadowColor = UIColor.Clear
+ });
+ // should not throw if the application is linked
+ }
+#endif
+
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=1790
+ public void Bug1790_TimeZoneInfo_Local ()
+ {
+ // the simulator has complete file access but the device won't have - i.e. we can't depend on it
+ Assert.That (File.Exists ("/etc/localtime"), Is.EqualTo (Runtime.Arch == Arch.SIMULATOR), "/etc/localtime");
+ Assert.NotNull (TimeZoneInfo.Local, "Local");
+ // should not throw a TimeZoneNotFoundException on devices
+ }
+
+ [Test]
+ // http://bugzilla.xamarin.com/show_bug.cgi?id=1922
+ public void Bug1922_PLinq_Aot ()
+ {
+ const int size = 100;
+ Random random = new Random ();
+ int[] values = new int [size];
+ int currentNumber = 0;
+ List numbers = new List ();
+ while (currentNumber < 100) {
+ values [currentNumber] = random.Next (1, 10);
+ numbers.Add (currentNumber);
+ currentNumber ++;
+ }
+ numbers.AsParallel ().ForAll (number => {
+ Thread.Sleep (values [number]);
+ //Console.WriteLine (number);
+ });
+ if (Runtime.Arch == Arch.SIMULATOR)
+ Assert.Inconclusive ("only fails on devices");
+ }
+
+ [Test]
+ public void Bug2000_NSPersistentStoreCoordinator ()
+ {
+ // from http://www.sgmunn.com/?p=1#comments
+ NSAttributeDescription description = new NSAttributeDescription ();
+ Assert.That (description.Handle, Is.Not.EqualTo (IntPtr.Zero), "NSAttributeDescription");
+ description.AttributeType = NSAttributeType.Integer32;
+ description.Name = "SomeId";
+ description.Optional = false;
+
+ NSEntityDescription entity = new NSEntityDescription ();
+ Assert.That (entity.Handle, Is.Not.EqualTo (IntPtr.Zero), "NSEntityDescription");
+ entity.Name = "TestEntity";
+ entity.Properties = new NSPropertyDescription[1] { description };
+
+ NSManagedObjectModel model = new NSManagedObjectModel ();
+ Assert.That (model.Handle, Is.Not.EqualTo (IntPtr.Zero), "NSManagedObjectModel");
+ model.Entities = new NSEntityDescription[1] { entity };
+ model.SetEntities (model.Entities, String.Empty);
+
+ NSUrl url = new NSUrl ("test.sqlite", false);
+
+ // from http://bugzilla.xamarin.com/show_bug.cgi?id=2000
+ NSError error;
+ var c = new NSPersistentStoreCoordinator (model);
+ c.AddPersistentStoreWithType (NSPersistentStoreCoordinator.SQLiteStoreType, null, url, null, out error);
+ Assert.True (Runtime.Arch == Arch.SIMULATOR ? error == null : error.Code == 512, "error");
+ }
+
+ [Test]
+ // http://lists.ximian.com/pipermail/monotouch/2011-December/006976.html
+ public void Linker_RuntimeWrappedException ()
+ {
+ try {
+ // can't throw anything else but Exception-derived types from C#
+ support.throw_object ();
+ }
+ catch (Exception e) {
+ Assert.That (e.GetType ().Name, Is.EqualTo ("RuntimeWrappedException"), "RuntimeWrappedException");
+ }
+ }
+
+ [Test]
+ // http://stackoverflow.com/questions/8602726/cant-open-sqlite-database-in-read-only-mode
+ public void Sqlite_ReadOnly ()
+ {
+ var c = new SqliteConnection ("Data Source=:memory:;Read Only=true");
+ c.Open ();
+ // the above should not throw a 'misuse' exception
+ c.Close ();
+ }
+
+ [Test]
+ public void AsQueryable_3028 ()
+ {
+ string [] foos = new string [] { "hi", "bye" };
+ string f = foos.AsQueryable ().First ();
+ Assert.That (f, Is.EqualTo ("hi"), "f");
+ }
+
+#if !__WATCHOS__
+ [Test]
+ public void OpenTk_3049 ()
+ {
+ using (var gc1 = OpenTK.Platform.Utilities.CreateGraphicsContext (EAGLRenderingAPI.OpenGLES1)) {
+ Assert.NotNull (gc1);
+ }
+ using (var gc2 = OpenTK.Platform.Utilities.CreateGraphicsContext (EAGLRenderingAPI.OpenGLES2)) {
+ Assert.NotNull (gc2);
+ }
+ }
+
+ [Test]
+ public void OpenTk_Preserved ()
+ {
+#if XAMCORE_2_0
+ const string OpenTKAssembly = "OpenTK-1.0";
+#else
+ const string OpenTKAssembly = "OpenTK";
+#endif
+ var gl = Type.GetType ("OpenTK.Graphics.ES11.GL, " + OpenTKAssembly, false);
+ Assert.NotNull (gl, "ES11/GL");
+ var core = Type.GetType ("OpenTK.Graphics.ES11.GL/Core, " + OpenTKAssembly, false);
+ Assert.NotNull (core, "ES11/Core");
+
+ gl = Type.GetType ("OpenTK.Graphics.ES20.GL, " + OpenTKAssembly, false);
+ Assert.NotNull (gl, "ES20/GL");
+ core = Type.GetType ("OpenTK.Graphics.ES20.GL/Core, " + OpenTKAssembly, false);
+ Assert.NotNull (core, "ES20/Core");
+ }
+#endif // !__WATCHOS__
+
+ [Test]
+ public void XElement_3137 ()
+ {
+ CultureInfo current = Thread.CurrentThread.CurrentCulture;
+ try {
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
+ var element1 = new System.Xml.Linq.XElement ("Property1", new System.Xml.Linq.XAttribute ("type", "number"), 1.2343445);
+ Assert.That (element1.ToString (), Is.EqualTo ("1.2343445"), "en-US");
+
+ Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo ("de-DE");
+ // this was already working because the element was created with en-US
+ Assert.That (element1.ToString (), Is.EqualTo ("1.2343445"), "de-DE/1");
+ // however creating a new, identical, element under de-DE return*ed* a different string
+ var element2 = new System.Xml.Linq.XElement ("Property1", new System.Xml.Linq.XAttribute ("type", "number"), 1.2343445);
+ Assert.That (element2.ToString (), Is.EqualTo ("1.2343445"), "de-DE/2");
+ }
+ finally {
+ Thread.CurrentThread.CurrentCulture = current;
+ }
+ }
+
+#if !__TVOS__ && !__WATCHOS__
+ [Test]
+ public void Modal_3489 ()
+ {
+ using (UIViewController a = new UIViewController ())
+ using (UIViewController b = new UIViewController ())
+ using (UIViewController c = new UIViewController ()) {
+ a.PresentModalViewController (b, true);
+ b.PresentModalViewController (c, true);
+
+#if XAMCORE_2_0
+ b.DismissModalViewController (true);
+ a.DismissModalViewController (true); //error
+#else
+ b.DismissModalViewControllerAnimated (true);
+ a.DismissModalViewControllerAnimated (true); //error
+#endif
+ }
+ }
+#endif // !__TVOS__ && !__WATCHOS__
+
+ [Test]
+ public void TypeDescriptor_A7793 ()
+ {
+ Assert.NotNull (TypeDescriptor.GetConverter (typeof (bool)));
+ }
+
+ [Test]
+ public void Parse_3677 ()
+ {
+ Assert.That (sbyte.Parse ("E3", NumberStyles.HexNumber), Is.EqualTo (-29), "SByte");
+ Assert.That (short.Parse ("E3E3", NumberStyles.HexNumber), Is.EqualTo (-7197), "Int16");
+ }
+
+ public class DeviceHardware {
+ public const string HardwareProperty = "hw.machine";
+
+ public enum HardwareVersion {
+ iPhone,
+ iPhone3G,
+ iPhone3GS,
+ iPhone4,
+ iPod1G,
+ iPod2G,
+ iPod3G,
+ iPod4G,
+ iPad,
+ iPhoneSimulator,
+ iPhone4Simulator,
+ iPadSimulator,
+ Unknown
+ }
+
+ // Changing the constant to "/usr/bin/libSystem.dylib" allows this P/Invoke to work on Mac OS X
+ // Using "hw.model" as property gives Macintosh model, "hw.machine" kernel arch (ppc, ppc64, i386, x86_64)
+ [DllImport (Constants.libSystemLibrary)]
+ internal static extern int sysctlbyname ([MarshalAs(UnmanagedType.LPStr)] string property, // name of the property
+ IntPtr output, // output
+ IntPtr oldLen, // IntPtr.Zero
+ IntPtr newp, // IntPtr.Zero
+ uint newlen // 0
+ );
+
+ public static HardwareVersion Version {
+ get {
+ // get the length of the string that will be returned
+ var pLen = Marshal.AllocHGlobal(sizeof(int));
+ sysctlbyname(DeviceHardware.HardwareProperty, IntPtr.Zero, pLen, IntPtr.Zero, 0);
+
+ var length = Marshal.ReadInt32(pLen);
+
+ // check to see if we got a length
+ if (length == 0)
+ {
+ Marshal.FreeHGlobal(pLen);
+ return HardwareVersion.Unknown;
+ }
+
+ // get the hardware string
+ var pStr = Marshal.AllocHGlobal(length);
+ sysctlbyname(DeviceHardware.HardwareProperty, pStr, pLen, IntPtr.Zero, 0);
+
+ // convert the native string into a C# string
+ var hardwareStr = Marshal.PtrToStringAnsi(pStr);
+ var ret = HardwareVersion.Unknown;
+
+ // determine which hardware we are running
+ if (hardwareStr == "iPhone1,1")
+ ret = HardwareVersion.iPhone;
+ else if (hardwareStr == "iPhone1,2")
+ ret = HardwareVersion.iPhone3G;
+ else if (hardwareStr == "iPhone2,1")
+ ret = HardwareVersion.iPhone3GS;
+ else if (hardwareStr == "iPhone3,1")
+ ret = HardwareVersion.iPhone4;
+ else if (hardwareStr == "iPad1,1")
+ ret = HardwareVersion.iPad;
+ else if (hardwareStr == "iPod1,1")
+ ret = HardwareVersion.iPod1G;
+ else if (hardwareStr == "iPod2,1")
+ ret = HardwareVersion.iPod2G;
+ else if (hardwareStr == "iPod3,1")
+ ret = HardwareVersion.iPod3G;
+ else if (hardwareStr == "iPod4,1")
+ ret = HardwareVersion.iPod3G;
+ else if (hardwareStr == "i386" || hardwareStr == "x86_64") {
+#if __WATCHOS__
+ ret = HardwareVersion.Unknown;
+#else
+ if (UIDevice.CurrentDevice.Model.Contains("iPhone"))
+ ret = UIScreen.MainScreen.Bounds.Height * UIScreen.MainScreen.Scale == 960 || UIScreen.MainScreen.Bounds.Width * UIScreen.MainScreen.Scale == 960 ? HardwareVersion.iPhone4Simulator : HardwareVersion.iPhoneSimulator;
+ else
+ ret = HardwareVersion.iPadSimulator;
+#endif
+ }
+ else ret = HardwareVersion.Unknown;
+
+ // cleanup
+ Marshal.FreeHGlobal(pLen);
+ Marshal.FreeHGlobal(pStr);
+
+ return ret;
+ }
+ }
+ }
+
+ [Test]
+ // http://stackoverflow.com/questions/9685134/monotouch-fatal-crash-once-deployed
+ // could not be duplicated on iPad2 (rolf), iPad1 (spouliot), iPodTouch4 (spouliot)
+ public void Hardware_SO ()
+ {
+ Assert.NotNull (DeviceHardware.Version, "Hardware");
+ }
+
+ public class Location {}
+
+ private static Location mInstance = null;
+
+ [MethodImpl (MethodImplOptions.Synchronized)]
+ public static Location getInstance ()
+ {
+ if (mInstance == null)
+ mInstance = new Location ();
+ return mInstance;
+ }
+
+ [Test]
+ public void Synchronized_3904 ()
+ {
+ // crash with LLVM
+ Assert.NotNull (getInstance (), "Location");
+ }
+
+ [Test]
+ [Culture ("en")]
+ public void Json_Parse_4415 ()
+ {
+ var f = 4.25987E-06f;
+ // note: always use '.' see http://www.json.org/fatfree.html
+ var s = f.ToString ();
+ var v = JsonValue.Parse (s);
+ Assert.AreEqual (f, (float) v, "Parse Negative Exponent");
+ f *= 10;
+ Assert.AreNotEqual (f, (float) v, "non-equal");
+ }
+
+ [Test]
+ [Culture ("en")]
+ public void ConvertToDouble_4620 ()
+ {
+ // can't duplicate bug when using invarient culture
+ Assert.That (Convert.ToDouble ("0.0"), Is.EqualTo (0.0d));
+ }
+
+ [Test]
+ public void NetworkInterface_4631 ()
+ {
+ Assert.NotNull (NetworkInterface.GetAllNetworkInterfaces ());
+ }
+
+ [Test]
+ public void WebClient_SSL_Leak ()
+ {
+ WebClient wc = new WebClient ();
+ // note: needs to be executed under Instrument to verify it does not leak
+ string s = wc.DownloadString ("https://developers.google.com");
+ Assert.NotNull (s);
+ }
+
+#if !__TVOS__ && !__WATCHOS__
+ [Test]
+ public void WebProxy_Leak ()
+ {
+ // note: needs to be executed under Instrument to verify it does not leak
+ Assert.NotNull (CFNetwork.GetSystemProxySettings (), "should not leak");
+ }
+#endif // !__TVOS__ && !__WATCHOS__
+
+ [Test]
+ // https://bugzilla.novell.com/show_bug.cgi?id=650402
+ public void ForeignKey_650402 ()
+ {
+ DataSet data = new DataSet ();
+ DataTable parent = new DataTable ("parent");
+ DataColumn pk = parent.Columns.Add ("PK");
+ DataTable child = new DataTable ("child");
+ DataColumn fk = child.Columns.Add ("FK");
+
+ data.Tables.Add (parent);
+ data.Tables.Add (child);
+ data.Relations.Add (pk, fk);
+
+ parent.Rows.Add ("value");
+ child.Rows.Add ("value");
+ data.AcceptChanges ();
+ child.Rows[0].Delete ();
+ parent.Rows[0][0] = "value2";
+
+ data.EnforceConstraints = false;
+ data.EnforceConstraints = true;
+ }
+
+ [Test]
+ public void Pointer_5200 ()
+ {
+ // ensure the linker did not remove the type, which is used by the runtime
+ Assert.NotNull (Type.GetType ("System.Reflection.Pointer, mscorlib"));
+ }
+
+ [Test]
+ public void LockRecursionException_5311 ()
+ {
+ Assert.Throws (delegate { throw new LockRecursionException (); });
+ }
+
+ class AddedInSilverlight5 : INotifyPropertyChanging {
+ public event PropertyChangingEventHandler PropertyChanging;
+ }
+
+ [Test]
+ public void INotifyPropertyChanging_5337 ()
+ {
+ new AddedInSilverlight5 ().PropertyChanging += delegate { };
+ }
+
+ [Test]
+ public void MonoIOStat_6118 ()
+ {
+ string file = NSBundle.MainBundle.ExecutablePath;
+ DateTime c1 = File.GetCreationTime (file).ToUniversalTime ();
+ DateTime c2 = (DateTime) NSFileManager.DefaultManager.GetAttributes (file).CreationDate;
+ Assert.That ((c1 - c2).Seconds, Is.LessThan (30), "MonoIOStat");
+ }
+
+ [Test]
+ public void ObjectHandleCtor ()
+ {
+ Type o = typeof (Object);
+ // this returns a new System.Runtime.Remoting.ObjectHandle which (was) linked away previously
+ Assert.NotNull (Activator.CreateInstance (o.Assembly.GetName ().Name, o.FullName), "ObjectHandle");
+ }
+
+ [Test]
+ public void AttributeUsageAttribute_Persistance ()
+ {
+ Assert.IsFalse (Attribute.IsDefined (GetType (), typeof(SerializableAttribute)));
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void LinkedAway ()
+ {
+ new System.Runtime.Remoting.RemotingException ();
+ }
+
+ [Test]
+ public void ArrayClear_11184 ()
+ {
+ byte[] key = new byte [16];
+ for (int i = 0; i < key.Length; i++)
+ key [i] = (byte) (255 - i);
+ Array.Clear (key, 5, 11);
+ for (int i = 5; i < key.Length; i++)
+ Assert.That (key [i], Is.EqualTo (0), i.ToString ());
+ }
+
+ public class Demo_14493 {
+ public void Update (object o)
+ {
+ }
+ }
+
+ [Test]
+ public void Action_14493 ()
+ {
+ var Demo = new Demo_14493 ();
+ Action