[generator] Improve BI1014 - include name of unsupported field and update valid types on docs, fixes bug 57094. (#3001)

* [generator] Improve BI1014 - include name of unsupported field and update valid types on docs, fixes bug 57094.

https://bugzilla.xamarin.com/show_bug.cgi?id=57094

* Implement feedback

* fix error message

* More feedback
This commit is contained in:
Alex Soto 2017-11-14 08:46:46 -06:00 коммит произвёл GitHub
Родитель 2b1e34caa4
Коммит 21a56a5f27
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 43 добавлений и 5 удалений

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

@ -1380,7 +1380,19 @@ static library, use "__Internal" as the `libraryName` parameter.
The generated properties are always static.
Properties flagged with the Field attribute can be of type `NSString`, `NSArray`, `nint`, `double`, `nfloat` or `System.IntPtr`.
Properties flagged with the Field attribute can be of the following types:
* `NSString`
* `NSArray`
* `nint` / `int` / `long`
* `nuint` / `uint` / `ulong`
* `nfloat` / `float`
* `double`
* `CGSize`
* `System.IntPtr`
* Enums
Setters are not supported for [enums backed by NSString constants](#enum-attributes), but they can be manually bound if needed.
Example:

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

@ -70,7 +70,9 @@ This usually indicates a bug in Xamarin.iOS/Xamarin.Mac; please [file a bug repo
### <a name='BI1013'/>BI1013: Unsupported type for Fields (string), you probably meant NSString
### <a name='BI1014'/>BI1014: Unsupported type for Fields: *
### <a name='BI1014'/>BI1014: Unsupported type for Fields: * for '*'.
Please go to [[FieldAttribute]](https://developer.xamarin.com/guides/cross-platform/macios/binding/binding-types-reference/#FieldAttribute) documentation to see supported types.
### <a name='BI1015'/>BI1015: In class * You specified the Events property, but did not bind those to names with Delegates

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

@ -6223,7 +6223,7 @@ public partial class Generator : IMemberGatherer {
else if (btype == TypeManager.System_nuint || btype == TypeManager.System_UInt64)
print ($"return ({fieldTypeName}) (ulong) Dlfcn.GetNUInt (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\");");
else
throw new BindingException (1014, true, "Unsupported type for Fields: {0}", fieldTypeName);
throw new BindingException (1014, true, $"Unsupported type for Fields: {fieldTypeName} for '{field_pi}'.");
} else {
if (btype == TypeManager.System_Int32)
print ($"return ({fieldTypeName}) Dlfcn.GetInt32 (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\");");
@ -6234,13 +6234,13 @@ public partial class Generator : IMemberGatherer {
else if (btype == TypeManager.System_UInt64)
print ($"return ({fieldTypeName}) Dlfcn.GetUInt64 (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\");");
else
throw new BindingException (1014, true, "Unsupported type for Fields: {0}", fieldTypeName);
throw new BindingException (1014, true, $"Unsupported type for Fields: {fieldTypeName} for '{field_pi}'.");
}
} else {
if (field_pi.PropertyType == TypeManager.System_String)
throw new BindingException (1013, true, "Unsupported type for Fields (string), you probably meant NSString");
else
throw new BindingException (1014, true, "Unsupported type for Fields: {0}", fieldTypeName);
throw new BindingException (1014, true, $"Unsupported type for Fields: {fieldTypeName} for '{field_pi}'.");
}
indent--;

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

@ -213,5 +213,29 @@ namespace Bug57804TestsRef {
bgen.AssertExecuteError ("build");
bgen.AssertError (1048, "Unsupported type 'ref/out NSValue' decorated with [BindAs]");
}
[Test]
public void Bug57094Test ()
{
// https://bugzilla.xamarin.com/show_bug.cgi?id=57094
var bgen = new BGenTool ();
bgen.Profile = Profile.iOS;
bgen.CreateTemporaryBinding (@"
using System;
using Foundation;
using ObjCRuntime;
namespace Bug57094 {
[BaseType (typeof (NSObject))]
interface FooObject {
[Field (""SomeField"", ""__Internal"")]
byte [] SomeField { get; }
}
}");
bgen.AssertExecuteError ("build");
bgen.AssertError (1014, "Unsupported type for Fields: byte[] for 'Bug57094.FooObject SomeField'.");
}
}
}