From 09f349b8ce806dfbb20a09ebe2252c5c98396d0d Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 17 Dec 2021 21:47:24 +0100 Subject: [PATCH] [generator] Fix reporting BI1042. (#13587) Fix reporting BI1042 to include the type + property that triggered the error + add a test. --- src/generator.cs | 2 +- tests/generator/ErrorTests.cs | 12 ++++++++++++ tests/generator/bi1042.cs | 10 ++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/generator/bi1042.cs diff --git a/src/generator.cs b/src/generator.cs index 17ba2a4282..278baa8e2c 100644 --- a/src/generator.cs +++ b/src/generator.cs @@ -6385,7 +6385,7 @@ public partial class Generator : IMemberGatherer { } } else if (BindThirdPartyLibrary) { // User should provide a LibraryName - throw new BindingException (1042, true); + throw ErrorHelper.CreateError (1042, /* Missing '[Field (LibraryName=value)]' for {0} (e.g."__Internal") */ type.FullName + "." + propertyName); } else { library_name = type.Namespace; } diff --git a/tests/generator/ErrorTests.cs b/tests/generator/ErrorTests.cs index e0fb67b272..df9ce21530 100644 --- a/tests/generator/ErrorTests.cs +++ b/tests/generator/ErrorTests.cs @@ -129,6 +129,18 @@ namespace GeneratorTests 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."); } + [Test] + 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\")"); + } + [Test] public void BI1046 () { diff --git a/tests/generator/bi1042.cs b/tests/generator/bi1042.cs new file mode 100644 index 0000000000..7560de780f --- /dev/null +++ b/tests/generator/bi1042.cs @@ -0,0 +1,10 @@ +using System; +using Foundation; + +namespace BindingTests +{ + public enum Tools { + [Field ("DoorOpener")] + DoorOpener, + } +}