Exemplo n.º 1
0
        public void BI1040(Profile profile)
        {
            var bgen = new BGenTool();

            bgen.Profile = profile;
            bgen.Defines = BGenTool.GetDefaultDefines(profile);
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "protocol-duplicate-method-diff-out.cs")));
            bgen.AssertExecuteError("build");
            bgen.AssertError(1040, "The selector doit:withmore on type Derived is found multiple times with different argument out states on argument 1.");
        }
Exemplo n.º 2
0
        public void BI1037(Profile profile)
        {
            var bgen = new BGenTool();

            bgen.Profile = profile;
            bgen.Defines = BGenTool.GetDefaultDefines(profile);
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "protocol-duplicate-abstract-error.cs")));
            bgen.AssertExecuteError("build");
            bgen.AssertError(1037, "The selector Identifier on type Derived is found multiple times with both read only and write only versions, with no read/write version.");
        }
Exemplo n.º 3
0
        public void BI1041(Profile profile)
        {
            var bgen = new BGenTool();

            bgen.Profile = profile;
            bgen.Defines = BGenTool.GetDefaultDefines(profile);
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "protocol-duplicate-method-diff-type.cs")));
            bgen.AssertExecuteError("build");
            bgen.AssertErrorPattern(1041, "The selector doit:with:more: on type Derived is found multiple times with different argument types on argument 2 - System.Int32 : .*Foundation.NSObject.");
        }
Exemplo n.º 4
0
        public void MissingExportOnProperty(Profile profile)
        {
            var bgen = new BGenTool();

            bgen.Profile = profile;
            bgen.Defines = BGenTool.GetDefaultDefines(profile);
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "missing-export-property.cs")));
            bgen.AssertExecuteError("build");
            bgen.AssertError(1018, "No [Export] attribute on property Test.NSTextInputClient.SelectedRange");
        }
Exemplo n.º 5
0
        public void BI1036(Profile profile)
        {
            var bgen = new BGenTool();

            bgen.Profile = profile;
            bgen.Defines = BGenTool.GetDefaultDefines(profile);
            bgen.ApiDefinitions.Add(Path.Combine(Configuration.SourceRoot, "tests", "generator", "bi1036.cs"));
            bgen.CreateTemporaryBinding();
            bgen.AssertExecuteError("build");
            bgen.AssertError(1036, "The last parameter in the method 'NS.Foo.Method' must be a delegate (it's 'System.String').");
        }
Exemplo n.º 6
0
        public void ClassNameCollision()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.Defines = BGenTool.GetDefaultDefines(bgen.Profile);
            bgen.Sources.Add(Path.Combine(Configuration.SourceRoot, "tests", "generator", "classNameCollision-enum.cs"));
            bgen.ApiDefinitions.Add(Path.Combine(Configuration.SourceRoot, "tests", "generator", "classNameCollision.cs"));
            bgen.CreateTemporaryBinding();
            bgen.AssertExecute("build");
            bgen.AssertNoWarnings();
        }
Exemplo n.º 7
0
        public void NativeEnum()
        {
            var bgen = new BGenTool();

            bgen.Profile        = Profile.iOS;
            bgen.ProcessEnums   = true;
            bgen.Defines        = BGenTool.GetDefaultDefines(bgen.Profile);
            bgen.Sources        = new string [] { Path.Combine(Configuration.SourceRoot, "tests", "generator", "tests", "nativeenum-extensions.cs") }.ToList();
            bgen.ApiDefinitions = new string [] { Path.Combine(Configuration.SourceRoot, "tests", "generator", "tests", "nativeenum.cs") }.ToList();
            bgen.CreateTemporaryBinding();
            bgen.AssertExecute("build");
        }
Exemplo n.º 8
0
        public void Bug31788(Profile profile)
        {
            var bgen = new BGenTool();

            bgen.Profile = profile;
            bgen.Defines = BGenTool.GetDefaultDefines(bgen.Profile);
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "bug31788.cs")));
            bgen.AssertExecute("build");
            bgen.AssertNoWarnings();

            bgen.AssertApiCallsMethod("Test", "MarshalInProperty", "get_Shared", "xamarin_IntPtr_objc_msgSend_exception", "MarshalInProperty.Shared getter");
            bgen.AssertApiCallsMethod("Test", "MarshalOnProperty", "get_Shared", "xamarin_IntPtr_objc_msgSend_exception", "MarshalOnProperty.Shared getter");
        }
Exemplo n.º 9
0
        BGenTool BuildFile(Profile profile, bool nowarnings, params string [] filenames)
        {
            var bgen = new BGenTool();

            bgen.Profile = profile;
            bgen.Defines = BGenTool.GetDefaultDefines(bgen.Profile);
            bgen.CreateTemporaryBinding(filenames.Select((filename) => File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", filename))).ToArray());
            bgen.AssertExecute("build");
            if (nowarnings)
            {
                bgen.AssertNoWarnings();
            }
            return(bgen);
        }
Exemplo n.º 10
0
        public void NoWarn(Profile profile)
        {
            const string message = "The member 'SomeMethod' is decorated with [Static] and its container class nowarnTests.FooObject_Extensions is decorated with [Category] this leads to hard to use code. Please inline SomeMethod into nowarnTests.FooObject class.";
            {
                // Enabled
                var bgen = new BGenTool();
                bgen.Profile = profile;
                bgen.Defines = BGenTool.GetDefaultDefines(profile);
                bgen.NoWarn  = string.Empty;
                bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "nowarn.cs")));
                bgen.AssertExecute("build");
                bgen.AssertNoWarnings();
            }

            {
                // Disabled
                var bgen = new BGenTool();
                bgen.Profile = profile;
                bgen.Defines = BGenTool.GetDefaultDefines(profile);
                bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "nowarn.cs")));
                bgen.AssertExecute("build");
                bgen.AssertWarning(1117, message);
            }

            {
                // Only 1116
                var bgen = new BGenTool();
                bgen.Profile = profile;
                bgen.Defines = BGenTool.GetDefaultDefines(profile);
                bgen.NoWarn  = "1116";
                bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "nowarn.cs")));
                bgen.AssertExecute("build");
                bgen.AssertWarning(1117, message);
            }

            {
                // Only 1117
                var bgen = new BGenTool();
                bgen.Profile = profile;
                bgen.Defines = BGenTool.GetDefaultDefines(profile);
                bgen.NoWarn  = "1117";
                bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "nowarn.cs")));
                bgen.AssertExecute("build");
                bgen.AssertNoWarnings();
            }
        }
Exemplo n.º 11
0
        BGenTool BuildFile(Profile profile, bool nowarnings, bool processEnums, params string [] filenames)
        {
            var bgen = new BGenTool();

            bgen.Profile      = profile;
            bgen.ProcessEnums = processEnums;
            bgen.Defines      = BGenTool.GetDefaultDefines(bgen.Profile);
            TestContext.Out.WriteLine(TestContext.CurrentContext.Test.FullName);
            foreach (var filename in filenames)
            {
                TestContext.Out.WriteLine($"\t{filename}");
            }
            bgen.CreateTemporaryBinding(filenames.Select((filename) => File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", filename))).ToArray());
            bgen.AssertExecute("build");
            if (nowarnings)
            {
                bgen.AssertNoWarnings();
            }
            return(bgen);
        }