[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:
Alex Soto 2017-11-13 14:21:18 -06:00 коммит произвёл GitHub
Родитель ee19c79feb
Коммит b197eab50e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 51 добавлений и 0 удалений

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

@ -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]");
}
}
}