Ejemplo n.º 1
0
 static void Test()
 {
     if (MonoLinkerSupport.IsTypeAvailable("Mono.Globalization.Unicode.SimpleCollator"))
     {
         throw new AssertionException("Mono.Globalization.Unicode.SimpleCollator");
     }
 }
Ejemplo n.º 2
0
        public static void RunWeakInstance4()
        {
            var supported = MonoLinkerSupport.IsWeakInstanceOf <Foo> (null);

            Console.Error.WriteLine($"SUPPORTED: {supported}");
            TestHelpers.Assert(!supported);
        }
Ejemplo n.º 3
0
 public static void RunFeature1()
 {
     if (!MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Martin))
     {
         TestHelpers.AssertFail("Feature `MonoLinkerFeature.Martin` should not be available.");
     }
 }
Ejemplo n.º 4
0
 public static void RunFeature2()
 {
     if (MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Unknown))
     {
         TestHelpers.AssertFail("Feature `MonoLinkerFeature.Unknown` should be disabled.");
     }
 }
Ejemplo n.º 5
0
        public static void RunFeature(MonoLinkerFeature feature)
        {
            bool supported;

            switch (feature)
            {
            case MonoLinkerFeature.Martin:
                supported = MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Martin);
                break;

            case MonoLinkerFeature.Unknown:
                supported = MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Unknown);
                break;

            case MonoLinkerFeature.ReflectionEmit:
                Console.Error.WriteLine("REFLECTION EMIT");
                supported = false;
                break;

            default:
                throw new AssertionException();
            }

            Console.WriteLine($"DONE: {supported}");
        }
Ejemplo n.º 6
0
 static void Test()
 {
     if (MonoLinkerSupport.IsTypeAvailable("System.Globalization.EncodingTable"))
     {
         throw new AssertionException("System.Globalization.EncodingTable");
     }
 }
Ejemplo n.º 7
0
        public static void RunWeakInstance12()
        {
            var instance = new InstanceTest();

            Console.WriteLine(MonoLinkerSupport.IsWeakInstanceOf <Foo> (instance.Instance));
            Console.WriteLine();
        }
Ejemplo n.º 8
0
        ISimpleCollator GetCollator()
        {
            if (!MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Martin))
            {
                return(null);
            }

            if (collator != null)
            {
                return(collator);
            }

            if (collators == null)
            {
                Interlocked.CompareExchange(ref collators, new Dictionary <string, ISimpleCollator> (StringComparer.Ordinal), null);
            }

            TestHelpers.AssertRemoved();

            lock (collators) {
                if (!collators.TryGetValue(_sortName, out collator))
                {
                    collator = new SimpleCollator(CultureInfo.GetCultureInfo(m_name));
                    collators [_sortName] = collator;
                }
            }

            return(collator);
        }
Ejemplo n.º 9
0
 static void Test()
 {
     if (MonoLinkerSupport.IsTypeAvailable("System.Security.Cryptography.X509Certificate"))
     {
         throw new AssertionException("System.Security.Cryptography.X509Certificate");
     }
 }
Ejemplo n.º 10
0
        public static void RunWeakInstance2()
        {
            if (MonoLinkerSupport.IsWeakInstanceOf <Foo> (null))
            {
                throw new AssertionException("Conditional should return false.");
            }

            Console.Error.WriteLine("DONE");
        }
Ejemplo n.º 11
0
        public static void Main()
        {
            var supported = MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Martin) && ReturnTrue();

            if (supported)
            {
                Foo.Hello();
            }
        }
        public static void TestAvailable1()
        {
            var supported = MonoLinkerSupport.IsTypeAvailable <Foo> ();

            Console.Error.WriteLine($"SUPPORTED: {supported}");
            if (supported)
            {
                throw new AssertionException("Conditional should have returned false.");
            }
        }
        public static void RunWeakInstance3()
        {
            Console.Error.WriteLine("HELLO");
            if (MonoLinkerSupport.IsWeakInstanceOf <Foo> (null))
            {
                throw TestHelpers.AssertRemoved();
            }

            Console.Error.WriteLine("DONE");
        }
        public static void RunWeakInstance2()
        {
            if (MonoLinkerSupport.IsWeakInstanceOf <Foo> (null))
            {
                TestHelpers.Debug("Conditional should have been removed.");
                throw TestHelpers.AssertRemoved();
            }

            Console.Error.WriteLine("DONE");
        }
Ejemplo n.º 15
0
        static Object CreateInstanceImpl(Type type,
                                         BindingFlags bindingAttr, Binder binder,
                                         Object[] args,
                                         Object[] activationAttributes)
        {
            if ((object)type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (MonoLinkerSupport.IsWeakInstanceOf <TypeBuilder> (type))
            {
                throw new NotSupportedException(MyEnvironment.GetResourceString("X"));
            }

            // If they didn't specify a lookup, then we will provide the default lookup.
            if ((bindingAttr & (BindingFlags)LookupMask) == 0)
            {
                bindingAttr |= TestConditionals.ConstructorDefault;
            }

            bool status = false;

            if (MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Martin))
            {
                status = true;
                if (activationAttributes != null && activationAttributes.Length > 0)
                {
                    if (type.IsMarshalByRef)
                    {
                        if (!(type.IsContextful))
                        {
                            if (activationAttributes.Length > 1 || !(activationAttributes[0] is UrlAttribute))
                            {
                                throw new NotSupportedException(MyEnvironment.GetResourceString("Y"));
                            }
                        }
                    }
                    else
                    {
                        throw new NotSupportedException(MyEnvironment.GetResourceString("Z"));
                    }
                }
            }

            TestHelpers.Assert(status);

            TypeInfo rt = type.UnderlyingSystemType as TypeInfo;

            if (rt == null)
            {
                throw new ArgumentException(MyEnvironment.GetResourceString("X"), "type");
            }

            return(Test(rt, bindingAttr, binder, args, activationAttributes));
        }
        public static void RunWeakInstance13()
        {
            var instance = new InstanceTest();

            if (MonoLinkerSupport.IsWeakInstanceOf <Foo> (instance.Instance))
            {
                throw TestHelpers.AssertRemoved();
            }

            Console.Error.WriteLine("DONE");
        }
Ejemplo n.º 17
0
        public static void RunWeakInstance(object instance)
        {
            if (MonoLinkerSupport.AsWeakInstanceOf <Foo> (instance, out var foo))
            {
                TestHelpers.Debug("Conditional should have been removed.");
                foo.Hello();
                TestHelpers.AssertRemoved();
            }

            Console.Error.WriteLine("DONE");
        }
Ejemplo n.º 18
0
        public static void RunWeakInstance()
        {
            if (MonoLinkerSupport.IsWeakInstanceOf <Foo> (null))
            {
                Foo.Hello();
                TestHelpers.Debug("Conditional should be linked out.");
                throw TestHelpers.AssertRemoved();
            }

            Console.Error.WriteLine("DONE");
        }
Ejemplo n.º 19
0
 public static void RunFeature(bool test)
 {
     if (test)
     {
         return;
     }
     if (MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Martin))
     {
         throw new AssertionException("Feature `MonoLinkerFeature.Martin` should be disabled.");
     }
 }
        public static void Main()
        {
            if (!MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Martin))
            {
                return;
            }

            lock (locker) {
                Hello();
            }
        }
Ejemplo n.º 21
0
        public static void RunWeakInstance13()
        {
            var instance = new InstanceTest();

            if (MonoLinkerSupport.IsWeakInstanceOf <Foo> (instance.Instance))
            {
                throw new AssertionException("Conditional should return false.");
            }

            Console.Error.WriteLine("DONE");
        }
Ejemplo n.º 22
0
        public static void RunWeakInstance1()
        {
            TryCatchMethod();
            if (MonoLinkerSupport.IsWeakInstanceOf <Foo> (null))
            {
                TestHelpers.Debug("Conditional should return false.");
                TestHelpers.AssertFail("Conditional should return false.");
            }

            Console.Error.WriteLine("DONE");
        }
Ejemplo n.º 23
0
 public static void RunFeature()
 {
     if (!MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Martin))
     {
         throw new InvalidOperationException("Expected `MonoLinkerFeature.Martin` to be enabled.");
     }
     if (MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Unknown))
     {
         throw new InvalidOperationException("Expected `MonoLinkerFeature.Unknown` to be disabled.");
     }
 }
Ejemplo n.º 24
0
        public static bool RunWeakInstance10()
        {
            var instance = new InstanceTest();

            Console.WriteLine(instance);
            if (TryCatchMethod())
            {
                throw new AssertionException();
            }
            return(MonoLinkerSupport.IsWeakInstanceOf <Foo> (instance.Field));
        }
Ejemplo n.º 25
0
        public static void Main()
        {
            var supported = MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Martin) && ReturnTrue();

            Console.Error.WriteLine($"SUPPORTED: {supported}");

            if (supported)
            {
                Foo.Hello();
            }
        }
        static void Run(Type type)
        {
            if ((object)type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (MonoLinkerSupport.IsWeakInstanceOf <TypeBuilder> (type))
            {
                throw new AssertionException("Conditional should return false.");
            }

            Console.Error.WriteLine("DONE");
        }
Ejemplo n.º 27
0
        public static void Main()
        {
            var test     = new TestUnicode();
            var collator = test.GetCollator();

            if (collator != null)
            {
                throw new AssertionException("GetCollator() should have returned null.");
            }

            if (MonoLinkerSupport.IsTypeAvailable <SimpleCollator> ())
            {
                throw new AssertionException("SimpleCollator should have been removed.");
            }
        }
        public static void TestAvailable2()
        {
            var supported = MonoLinkerSupport.IsTypeAvailable("Martin.LinkerTest.Foo");

            Console.Error.WriteLine($"SUPPORTED: {supported}");
            if (supported)
            {
                throw new AssertionException("Foo should not be available");
            }

            if (MonoLinkerSupport.IsTypeAvailable("Martin.LinkerTest.Undefined"))
            {
                throw new InvalidOperationException("Undefined type!");
            }
        }
Ejemplo n.º 29
0
        public static void RunErrorTest(object instance)
        {
            if (MonoLinkerSupport.AsWeakInstanceOf <Bar> (instance, out var bar))
            {
                TestHelpers.Debug("Conditional should have been removed.");
                bar.Hello();
                TestHelpers.AssertRemoved();
            }

            /*
             * This line will produce an error message:
             *
             * Attempting to mark type `Martin.LinkerTest.Bar` after it's already been used in a conditional!
             */
            Console.Error.WriteLine($"DONE: {bar != null}");
        }
Ejemplo n.º 30
0
        public static void RunFeature()
        {
            bool supported;

            try {
                supported = MonoLinkerSupport.IsFeatureSupported(MonoLinkerFeature.Martin);
                if (supported)
                {
                    throw new AssertionException("Feature `MonoLinkerFeature.Martin` should not be enabled.");
                }
            } catch (Exception ex) {
                Console.Error.WriteLine($"ERROR: {ex.Message}");
                throw;
            }

            Console.WriteLine($"DONE: {supported}");
        }