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."); }
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."); }
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."); }
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"); }
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')."); }
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(); }
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"); }
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"); }
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); }
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(); } }
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); }