diff --git a/docs/website/binding_types_reference_guide.md b/docs/website/binding_types_reference_guide.md index 9fa6493297..9e06b0052b 100644 --- a/docs/website/binding_types_reference_guide.md +++ b/docs/website/binding_types_reference_guide.md @@ -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: diff --git a/docs/website/generator-errors.md b/docs/website/generator-errors.md index 0611c075f2..c6835ccf5e 100644 --- a/docs/website/generator-errors.md +++ b/docs/website/generator-errors.md @@ -70,7 +70,9 @@ This usually indicates a bug in Xamarin.iOS/Xamarin.Mac; please [file a bug repo ### BI1013: Unsupported type for Fields (string), you probably meant NSString -### BI1014: Unsupported type for Fields: * +### 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. ### BI1015: In class * You specified the Events property, but did not bind those to names with Delegates diff --git a/src/generator.cs b/src/generator.cs index 102b850a1e..53596a656a 100644 --- a/src/generator.cs +++ b/src/generator.cs @@ -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--; diff --git a/tests/generator/ErrorTests.cs b/tests/generator/ErrorTests.cs index 6123c462a2..84ec7aac5b 100644 --- a/tests/generator/ErrorTests.cs +++ b/tests/generator/ErrorTests.cs @@ -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'."); + } } }