Example #1
0
        public void BI1117_allowstaticmembers()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "bug52570allowstaticmembers.cs")));
            bgen.AssertExecute("build");
            bgen.AssertNoWarnings();
        }
Example #2
0
        public void NoAsyncWarningCS0219()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.AddTestApiDefinition("noasyncwarningcs0219.cs");
            bgen.CreateTemporaryBinding();
            bgen.AssertExecute("build");
            bgen.AssertNoWarnings();
        }
Example #3
0
        public void ResponseFile()
        {
            var bgen = new BGenTool();

            bgen.CreateTemporaryBinding("");
            bgen.ResponseFile = Path.Combine(Cache.CreateTemporaryDirectory(), "rspfile");
            File.WriteAllLines(bgen.ResponseFile, new string [] { "--target-framework:Xamarin.iOS,v1.0" });
            bgen.AssertExecute("response file");
            bgen.AssertNoWarnings();
        }
Example #4
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();
        }
Example #5
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();
        }
Example #6
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");
        }
Example #7
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);
        }
Example #8
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();
            }
        }
Example #9
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);
        }
Example #10
0
        public void ResponseFile()
        {
            var bgen = new BGenTool();

            bgen.CreateTemporaryBinding("");
            bgen.ResponseFile = Path.Combine(Cache.CreateTemporaryDirectory(), "rspfile");

            var arguments = new List <string> ();

#if NET
            var targetFramework = TargetFramework.DotNet_6_0_iOS_String;
            var tf = TargetFramework.Parse(targetFramework);
            arguments.Add($"--baselib={Configuration.GetBaseLibrary (tf)}");
            arguments.Add($"--attributelib={Configuration.GetBindingAttributePath (tf)}");
            arguments.AddRange(Directory.GetFiles(Configuration.DotNet6BclDir, "*.dll").Select(v => $"-r:{v}"));
#else
            var targetFramework = "Xamarin.iOS,v1.0";
#endif
            arguments.Add($"--target-framework={targetFramework}");

            File.WriteAllLines(bgen.ResponseFile, arguments.ToArray());
            bgen.AssertExecute("response file");
            bgen.AssertNoWarnings();
        }