Ejemplo n.º 1
0
        public void GH5416_setter()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.AddTestApiDefinition("ghissue5416a.cs");
            bgen.CreateTemporaryBinding();
            bgen.AssertExecute("build");
            bgen.AssertWarning(1118, "[NullAllowed] should not be used on methods, like 'System.Void set_Setter(Foundation.NSString)', but only on properties, parameters and return values.");
        }
Ejemplo n.º 2
0
        public void Bug39614()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.AddTestApiDefinition("bug39614.cs");
            bgen.CreateTemporaryBinding();
            bgen.AssertExecute("build");
            bgen.AssertWarning(1103, "'FooType`1' does not live under a namespace; namespaces are a highly recommended .NET best practice");
        }
Ejemplo n.º 3
0
        public void NoAsyncWarningCS0219()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.AddTestApiDefinition("noasyncwarningcs0219.cs");
            bgen.CreateTemporaryBinding();
            bgen.AssertExecute("build");
            bgen.AssertNoWarnings();
        }
Ejemplo n.º 4
0
        public void BI1113_Bug37527_MissingProperty()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.AddTestApiDefinition("bug37527-missing-property.cs");
            bgen.CreateTemporaryBinding();
            bgen.AssertExecuteError("build");
            bgen.AssertError(1113, "BaseType.Delegates were set but no properties could be found. Do ensure that the WrapAttribute is used on the right properties.");
        }
Ejemplo n.º 5
0
        public void BI1112_Bug37527_WrongProperty()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.AddTestApiDefinition("bug37527-wrong-property.cs");
            bgen.CreateTemporaryBinding();
            bgen.AssertExecuteError("build");
            bgen.AssertError(1112, "Property 'TestProperty' should be renamed to 'Delegate' for BaseType.Events and BaseType.Delegates to work.");
        }
Ejemplo n.º 6
0
        public void FieldEnumTests()
        {
            var bgen = new BGenTool();

            bgen.Profile      = Profile.iOS;
            bgen.ProcessEnums = true;
            bgen.AddTestApiDefinition("fieldenumtests.cs");
            bgen.CreateTemporaryBinding();
            bgen.AssertExecute("build");
            bgen.AssertNoWarnings();
        }
Ejemplo n.º 7
0
        public void BI1046()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.AddTestApiDefinition("bi1046.cs");
            bgen.CreateTemporaryBinding();
            bgen.ProcessEnums = true;
            bgen.AssertExecuteError("build");
            bgen.AssertError(1046, "The [Field] constant HMAccessoryCategoryTypeGarageDoorOpener cannot only be used once inside enum HMAccessoryCategoryType.");
        }
Ejemplo n.º 8
0
        public void BI1042()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.AddTestApiDefinition("bi1042.cs");
            bgen.CreateTemporaryBinding();
            bgen.ProcessEnums = true;
            bgen.AssertExecuteError("build");
            bgen.AssertError(1042, "Missing '[Field (LibraryName=value)]' for BindingTests.Tools.DoorOpener (e.g.\"__Internal\")");
        }
Ejemplo n.º 9
0
        public void SmartEnumWithFramework()
        {
            var bgen = new BGenTool();

            bgen.Profile      = Profile.iOS;
            bgen.ProcessEnums = true;
            bgen.AddTestApiDefinition("smartenumwithframework.cs");
            bgen.CreateTemporaryBinding();
            bgen.AssertExecute("build");

            bgen.AssertApiLoadsField("SmartEnumWithFramework.FooEnumTestExtensions", "get_First", "ObjCRuntime.Libraries/CoreImage", "Handle", "First getter");
            bgen.AssertApiLoadsField("SmartEnumWithFramework.FooEnumTestExtensions", "get_Second", "ObjCRuntime.Libraries/CoreImage", "Handle", "Second getter");
        }
Ejemplo n.º 10
0
        public void Bug46292()
        {
            var bgen = new BGenTool();

            bgen.Profile      = Profile.iOS;
            bgen.ProcessEnums = true;
            bgen.AddTestApiDefinition("bug46292.cs");
            bgen.CreateTemporaryBinding();
            bgen.AssertExecute("build");

            var allTypes   = bgen.ApiAssembly.MainModule.GetTypes().ToArray();
            var allMembers = ((IEnumerable <ICustomAttributeProvider>)allTypes)
                             .Union(allTypes.SelectMany((type) => type.Methods))
                             .Union(allTypes.SelectMany((type) => type.Fields))
                             .Union(allTypes.SelectMany((type) => type.Properties));

            var attribCount = allMembers.Count((v) => v.HasCustomAttributes && v.CustomAttributes.Any((ca) => ca.AttributeType.Name == "ObsoleteAttribute"));

            Assert.AreEqual(2, attribCount, "attribute count");
        }
Ejemplo n.º 11
0
        public void NoAsyncInternalWrapper()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.AddTestApiDefinition("noasyncinternalwrapper.cs");
            bgen.CreateTemporaryBinding();
            bgen.AssertExecute("build");

            var allTypes   = bgen.ApiAssembly.MainModule.GetTypes().ToArray();
            var allMembers = ((IEnumerable <MemberReference>)allTypes)
                             .Union(allTypes.SelectMany((type) => type.Methods))
                             .Union(allTypes.SelectMany((type) => type.Fields))
                             .Union(allTypes.SelectMany((type) => type.Properties));

            Assert.AreEqual(1, allMembers.Count((member) => member.Name == "RequiredMethodAsync"), "Expected 1 RequiredMethodAsync members in generated code. If you modified code that generates RequiredMethodAsync (AsyncAttribute) please update the RequiredMethodAsync count.");

            var attribs = MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig;

            bgen.AssertMethod("NoAsyncInternalWrapperTests.MyFooDelegate_Extensions", "RequiredMethodAsync", attribs, "System.Threading.Tasks.Task", "NoAsyncInternalWrapperTests.IMyFooDelegate", "System.Int32");
        }
Ejemplo n.º 12
0
        public void VirtualWrap()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.AddTestApiDefinition("virtualwrap.cs");
            bgen.CreateTemporaryBinding();
            bgen.ProcessEnums = true;
            bgen.AssertExecute("build");

            // verify virtual methods
            var attribs = MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.NewSlot;

            bgen.AssertMethod("WrapTest.MyFooClass", "FromUrl", attribs, null, "Foundation.NSUrl");
            bgen.AssertMethod("WrapTest.MyFooClass", "FromUrl", attribs, null, "System.String");
            bgen.AssertMethod("WrapTest.MyFooClass", "get_FooNSString", attribs | MethodAttributes.SpecialName, "Foundation.NSString");
            bgen.AssertMethod("WrapTest.MyFooClass", "get_FooString", attribs | MethodAttributes.SpecialName, "System.String");

            // verify non-virtual methods
            attribs = MethodAttributes.Public | MethodAttributes.HideBySig;
            bgen.AssertMethod("WrapTest.MyFooClass", "FromUrlN", attribs, null, "System.String");
            bgen.AssertMethod("WrapTest.MyFooClass", "get_FooNSStringN", attribs | MethodAttributes.SpecialName, "Foundation.NSString");
        }