Ejemplo n.º 1
0
        public void BI1066()
        {
            var bgen = new BGenTool {
                Profile      = Profile.iOS,
                ProcessEnums = true
            };

            bgen.CreateTemporaryBinding(@"
using System;
using ObjCRuntime;
using Foundation;

namespace BI1066Errors
{
	[BaseType (typeof (NSObject))]
	interface C
	{
		// Can't put SEL into NSArray (SEL isn't an NSObject), so a Selector[] parameter/return value doesn't make sense
		[Export (""testSelectorArrayReturnValue"")]
		Selector[] TestSelectorArrayReturnValue ();
	}
}");
            bgen.AssertExecuteError("build");
            bgen.AssertError(1066, "Unsupported return type 'ObjCRuntime.Selector[]' in BI1066Errors.C.TestSelectorArrayReturnValue.");
            bgen.AssertErrorCount(2);              // We show the same error twice.
        }
Ejemplo n.º 2
0
        public void BI1065()
        {
            var bgen = new BGenTool {
                Profile      = Profile.iOS,
                ProcessEnums = true
            };

            bgen.CreateTemporaryBinding(@"
using System;
using ObjCRuntime;
using Foundation;

namespace BI1065Errors
{
	[BaseType (typeof (NSObject))]
	interface C
	{
		// Can't put SEL into NSArray (SEL isn't an NSObject), so a Selector[] parameter/return value doesn't make sense
		[Export (""testSelectorArray:"")]
		void TestSelectorArray (Selector[] values);
	}
}");
            bgen.AssertExecuteError("build");
            bgen.AssertError(1065, "Unsupported parameter type 'ObjCRuntime.Selector[]' for the parameter 'values' in BI1065Errors.C.TestSelectorArray.");
            bgen.AssertErrorCount(1);
        }
Ejemplo n.º 3
0
        public void BindAsNullableNSNumberArrayError()
        {
            // https://bugzilla.xamarin.com/show_bug.cgi?id=57797

            var bgen = new BGenTool {
                Profile      = Profile.iOS,
                ProcessEnums = true
            };

            bgen.CreateTemporaryBinding(@"
using System;
using Foundation;
using ObjCRuntime;
using AVFoundation;
using CoreAnimation;

namespace Bug57797Tests {

	[Native]
	enum Foo : long {
		One,
		Two
	}

	[BaseType (typeof (NSObject))]
	interface FooObject {

		[BindAs (typeof (Foo? []))]
		[Export (""strongNullableAVMediaTypesProperties"")]
		NSNumber[] StrongNullableFoo { get; set; }
	}
}");
            bgen.AssertExecuteError("build");
            bgen.AssertError(1048, "Unsupported type Foo?[] decorated with [BindAs]");
        }
Ejemplo n.º 4
0
        public void BindAsNullableNSValueArrayError()
        {
            // https://bugzilla.xamarin.com/show_bug.cgi?id=57797

            var bgen = new BGenTool {
                Profile = Profile.iOS
            };

            bgen.CreateTemporaryBinding(@"
using System;
using Foundation;
using ObjCRuntime;
using AVFoundation;
using CoreAnimation;

namespace Bug57797Tests {

	[BaseType (typeof (NSObject))]
	interface FooObject {

		[BindAs (typeof (CATransform3D? []))]
		[Export (""PCATransform3DNullableArray"")]
		NSValue [] PCATransform3DNullableArrayValue { get; set; }
	}
}");
            bgen.AssertExecuteError("build");
            bgen.AssertError(1048, "Unsupported type CATransform3D?[] decorated with [BindAs]");
        }
Ejemplo n.º 5
0
        public void BI1117()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.CreateTemporaryBinding(@"using System;
using Foundation;

namespace Bug52570Tests {

	[Category]
	[BaseType (typeof (FooObject))]
	interface FooObject_Extensions {

		[Static]
		[Export (""someMethod:"")]
		bool SomeMethod (NSRange range);
	}

	[BaseType (typeof (NSObject))]
	interface FooObject {
	
	}
}");
            bgen.AssertExecute("build");
            bgen.AssertWarning(1117, "The member 'SomeMethod' is decorated with [Static] and its container class Bug52570Tests.FooObject_Extensions is decorated with [Category] this leads to hard to use code. Please inline SomeMethod into Bug52570Tests.FooObject class.");
        }
Ejemplo n.º 6
0
        public void BI0086()
        {
            var bgen = new BGenTool();

            bgen.CreateTemporaryBinding("");
            bgen.AssertExecuteError("build");
            bgen.AssertError(86, "A target framework (--target-framework) must be specified.");
        }
Ejemplo n.º 7
0
        public void GH6863_method()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "ghissue6863_method.cs")));
            bgen.AssertExecuteError("build");
            bgen.AssertError(1072, "The BindAs type for the parameter \"id_test\" in the method \"GH6863_method.MyFooClass.StringMethod\" must be an array when the parameter's type is an array.");
        }
Ejemplo n.º 8
0
        public void BI0002()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.CreateTemporaryBinding("InvalidCodeHere");
            bgen.AssertExecuteError("build");
            bgen.AssertError(2, "Could not compile the API bindings.");
        }
Ejemplo n.º 9
0
        public void BI1061()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "bug57070.cs")));
            bgen.AssertExecuteError("build");
            bgen.AssertWarning(1061, "The attribute 'ObjCRuntime.iOSAttribute' found on 'SomeClass.DoSomething' is not a valid binding attribute. Please remove this attribute.");
        }
Ejemplo n.º 10
0
        public void BI1059()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "bi1059.cs")));
            bgen.AssertExecuteError("build");
            bgen.AssertError(1059, "Found 2 Foundation.PreserveAttribute attributes on the member the type BI1059. At most one was expected.");
        }
Ejemplo n.º 11
0
        public void BI0087()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.macOSClassic;
            bgen.CreateTemporaryBinding("");
            bgen.AssertExecuteError("build");
            bgen.AssertError(87, "Xamarin.Mac Classic binding projects are not supported anymore. Please upgrade the binding project to a Xamarin.Mac Unified binding project.");
        }
Ejemplo n.º 12
0
        public void BI1048()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "bindas1048error.cs")));
            bgen.AssertExecuteError("build");
            bgen.AssertError(1048, "Unsupported type String decorated with [BindAs]");
        }
Ejemplo n.º 13
0
        public void BI1060()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "bug42855.cs")));
            bgen.AssertExecute("build");
            bgen.AssertWarning(1060, "The Bug42855Tests.MyFooClass protocol is decorated with [Model], but not [BaseType]. Please verify that [Model] is relevant for this protocol; if so, add [BaseType] as well, otherwise remove [Model].");
        }
Ejemplo n.º 14
0
        public void BI1049()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "bindas1049error.cs")));
            bgen.AssertExecuteError("build");
            bgen.AssertError(1049, "Could not unbox type String from NSNumber container used on member BindAs1049ErrorTests.MyFooClass.StringMethod decorated with [BindAs].");
        }
Ejemplo n.º 15
0
        public void BI1050_protocol()
        {
            var bgen = new BGenTool();

            bgen.Profile = Profile.iOS;
            bgen.CreateTemporaryBinding(File.ReadAllText(Path.Combine(Configuration.SourceRoot, "tests", "generator", "bindas1050protocolerror.cs")));
            bgen.AssertExecuteError("build");
            bgen.AssertError(1050, "[BindAs] cannot be used inside Protocol or Model types. Type: MyFooClass");
        }
Ejemplo n.º 16
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();
        }
Ejemplo n.º 17
0
        public void BI1064()
        {
            var bgen = new BGenTool {
                Profile      = Profile.iOS,
                ProcessEnums = true
            };

            bgen.CreateTemporaryBinding(@"
using System;
using ObjCRuntime;
using Foundation;

namespace BI1064Errors
{
	[BaseType (typeof (NSObject))]
	interface C
	{
		[Export (""testINativeObjectArray:a:b:"")]
		void TestINativeObjectArray (int action, ref INativeObject[] refValues, out INativeObject[] outValues);

		[Export (""invalid1:a:"")]
		void TestInvalid1 (ref DateTime[] refInvalid, out DateTime[] outInvalid);

		[Export (""invalid2:a:"")]
		void TestInvalid2 (ref object[] refInvalid, out object[] outInvalid);

		[Export (""invalid3:a:"")]
		void TestInvalid3 (ref int[] refInvalid, out int[] outInvalid);

		[Export (""invalid4:a:"")]
		void TestInvalid4 (ref object refInvalid, out object outInvalid);

		[Export (""testINativeObject:a:b:"")]
		void TestINativeObject (int action, ref INativeObject refValue, out INativeObject outValue);

		[Export (""testSelectorArray:a:b:"")] // Can't put SEL into NSArray (SEL isn't an NSObject)
		void TestSelectorArray (int action, ref Selector[] refValues, out Selector[] outValues);
	}
}");
            bgen.AssertExecuteError("build");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'ObjCRuntime.INativeObject' for the parameter 'refValue' in BI1064Errors.C.TestINativeObject.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'ObjCRuntime.INativeObject' for the parameter 'outValue' in BI1064Errors.C.TestINativeObject.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'ObjCRuntime.INativeObject[]' for the parameter 'refValues' in BI1064Errors.C.TestINativeObjectArray.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'ObjCRuntime.INativeObject[]' for the parameter 'outValues' in BI1064Errors.C.TestINativeObjectArray.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'System.DateTime[]' for the parameter 'refInvalid' in BI1064Errors.C.TestInvalid1.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'System.DateTime[]' for the parameter 'outInvalid' in BI1064Errors.C.TestInvalid1.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'System.Object[]' for the parameter 'refInvalid' in BI1064Errors.C.TestInvalid2.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'System.Object[]' for the parameter 'refInvalid' in BI1064Errors.C.TestInvalid2.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'System.Int32[]' for the parameter 'outInvalid' in BI1064Errors.C.TestInvalid3.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'System.Int32[]' for the parameter 'outInvalid' in BI1064Errors.C.TestInvalid3.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'System.Object' for the parameter 'refInvalid' in BI1064Errors.C.TestInvalid4.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'System.Object' for the parameter 'refInvalid' in BI1064Errors.C.TestInvalid4.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'ObjCRuntime.Selector[]' for the parameter 'refValues' in BI1064Errors.C.TestSelectorArray.");
            bgen.AssertError(1064, "Unsupported ref/out parameter type 'ObjCRuntime.Selector[]' for the parameter 'outValues' in BI1064Errors.C.TestSelectorArray.");
            bgen.AssertErrorCount(14);
        }
Ejemplo n.º 18
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.º 19
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.º 20
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.");
        }
Ejemplo n.º 21
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");
        }
Ejemplo n.º 22
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.º 23
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();
        }
Ejemplo n.º 24
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.º 25
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.º 26
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.");
        }
Ejemplo n.º 27
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.");
        }
Ejemplo n.º 28
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.º 29
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.º 30
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').");
        }