[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:
Родитель
2b1e34caa4
Коммит
21a56a5f27
|
@ -1380,7 +1380,19 @@ static library, use "__Internal" as the `libraryName` parameter.
|
||||||
|
|
||||||
The generated properties are always static.
|
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:
|
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='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
|
### <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)
|
else if (btype == TypeManager.System_nuint || btype == TypeManager.System_UInt64)
|
||||||
print ($"return ({fieldTypeName}) (ulong) Dlfcn.GetNUInt (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\");");
|
print ($"return ({fieldTypeName}) (ulong) Dlfcn.GetNUInt (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\");");
|
||||||
else
|
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 {
|
} else {
|
||||||
if (btype == TypeManager.System_Int32)
|
if (btype == TypeManager.System_Int32)
|
||||||
print ($"return ({fieldTypeName}) Dlfcn.GetInt32 (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\");");
|
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)
|
else if (btype == TypeManager.System_UInt64)
|
||||||
print ($"return ({fieldTypeName}) Dlfcn.GetUInt64 (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\");");
|
print ($"return ({fieldTypeName}) Dlfcn.GetUInt64 (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\");");
|
||||||
else
|
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 {
|
} else {
|
||||||
if (field_pi.PropertyType == TypeManager.System_String)
|
if (field_pi.PropertyType == TypeManager.System_String)
|
||||||
throw new BindingException (1013, true, "Unsupported type for Fields (string), you probably meant NSString");
|
throw new BindingException (1013, true, "Unsupported type for Fields (string), you probably meant NSString");
|
||||||
else
|
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--;
|
indent--;
|
||||||
|
|
|
@ -213,5 +213,29 @@ namespace Bug57804TestsRef {
|
||||||
bgen.AssertExecuteError ("build");
|
bgen.AssertExecuteError ("build");
|
||||||
bgen.AssertError (1048, "Unsupported type 'ref/out NSValue' decorated with [BindAs]");
|
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'.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче