[generator] Fix slightly incorrect error message when trying to use ref/out parameters with BindAs attributes, fixes 57804. (#2997)
https://bugzilla.xamarin.com/show_bug.cgi?id=57804
This commit is contained in:
Родитель
ee19c79feb
Коммит
b197eab50e
|
@ -1274,6 +1274,9 @@ public partial class Generator : IMemberGatherer {
|
|||
originalType = pi.ParameterType;
|
||||
}
|
||||
|
||||
if (originalType.IsByRef)
|
||||
throw new BindingException (1048, true, $"Unsupported type 'ref/out {originalType.Name.Replace ("&", string.Empty)}' decorated with [BindAs]");
|
||||
|
||||
var retType = TypeManager.GetUnderlyingNullableType (attrib.Type) ?? attrib.Type;
|
||||
var isNullable = attrib.IsNullable;
|
||||
var isValueType = retType.IsValueType;
|
||||
|
|
|
@ -165,5 +165,53 @@ namespace Bug57797Tests {
|
|||
bgen.AssertExecuteError ("build");
|
||||
bgen.AssertError (1048, "Unsupported type Foo?[] decorated with [BindAs]");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindAsNoRefParam ()
|
||||
{
|
||||
var bgen = new BGenTool ();
|
||||
bgen.Profile = Profile.iOS;
|
||||
bgen.CreateTemporaryBinding (@"
|
||||
using System;
|
||||
using Foundation;
|
||||
using CoreGraphics;
|
||||
using ObjCRuntime;
|
||||
|
||||
namespace Bug57804TestsRef {
|
||||
|
||||
[BaseType (typeof (NSObject))]
|
||||
interface FooObject {
|
||||
|
||||
[Export (""setCGAffineTransformValueRefNonNullable:"")]
|
||||
void SetCGAffineTransformValueRefNonNullable ([BindAs (typeof (CGAffineTransform))] ref NSValue value);
|
||||
}
|
||||
}");
|
||||
bgen.AssertExecuteError ("build");
|
||||
bgen.AssertError (1048, "Unsupported type 'ref/out NSValue' decorated with [BindAs]");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindAsNoOutParam ()
|
||||
{
|
||||
var bgen = new BGenTool ();
|
||||
bgen.Profile = Profile.iOS;
|
||||
bgen.CreateTemporaryBinding (@"
|
||||
using System;
|
||||
using Foundation;
|
||||
using CoreGraphics;
|
||||
using ObjCRuntime;
|
||||
|
||||
namespace Bug57804TestsRef {
|
||||
|
||||
[BaseType (typeof (NSObject))]
|
||||
interface FooObject {
|
||||
|
||||
[Export (""setCGAffineTransformValueOutNonNullable:"")]
|
||||
void SetCGAffineTransformValueOutNonNullable ([BindAs (typeof (CGAffineTransform))] out NSValue value);
|
||||
}
|
||||
}");
|
||||
bgen.AssertExecuteError ("build");
|
||||
bgen.AssertError (1048, "Unsupported type 'ref/out NSValue' decorated with [BindAs]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче