[generator] Fix reporting BI1042. (#13587)

Fix reporting BI1042 to include the type + property that triggered the error +
add a test.
This commit is contained in:
Rolf Bjarne Kvinge 2021-12-17 21:47:24 +01:00 коммит произвёл GitHub
Родитель bcbb6c8438
Коммит 09f349b8ce
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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 ()
{

10
tests/generator/bi1042.cs Normal file
Просмотреть файл

@ -0,0 +1,10 @@
using System;
using Foundation;
namespace BindingTests
{
public enum Tools {
[Field ("DoorOpener")]
DoorOpener,
}
}