[generator] Handle subclasses of NSObject as ref/out parameters in third-party libraries. Fixes #6828. (#6829)
For third-party libraries we need to look up the base type using the BaseType attribute. Fixes https://github.com/xamarin/xamarin-macios/issues/6828.
This commit is contained in:
Родитель
3e3e980565
Коммит
4e70034b96
|
@ -1077,8 +1077,13 @@ public partial class Generator : IMemberGatherer {
|
|||
if (type.IsSubclassOf (TypeManager.NSObject))
|
||||
return true;
|
||||
|
||||
if (BindThirdPartyLibrary)
|
||||
if (BindThirdPartyLibrary) {
|
||||
var bta = ReflectionExtensions.GetBaseTypeAttribute (type, this);
|
||||
if (bta?.BaseType != null)
|
||||
return IsNSObject (bta.BaseType);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return type.IsInterface;
|
||||
}
|
||||
|
|
|
@ -603,6 +603,12 @@ namespace GeneratorTests
|
|||
[Test]
|
||||
public void GHIssue6626 () => BuildFile (Profile.iOS, "ghissue6626.cs");
|
||||
|
||||
[Test]
|
||||
public void VSTS970507 ()
|
||||
{
|
||||
BuildFile (Profile.iOS, "tests/vsts-970507.cs");
|
||||
}
|
||||
|
||||
BGenTool BuildFile (Profile profile, params string [] filenames)
|
||||
{
|
||||
return BuildFile (profile, true, false, filenames);
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
<None Include="packages.config" />
|
||||
<None Include="tests\ref-out-parameters.cs" />
|
||||
<None Include="tests\return-release.cs" />
|
||||
<None Include="tests\vsts-970507.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="tests\" />
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using Foundation;
|
||||
|
||||
namespace NS
|
||||
{
|
||||
[BaseType (typeof (NSObject))]
|
||||
interface OutNSObject
|
||||
{
|
||||
[Export ("func:")]
|
||||
void Func (out ErrorObject error);
|
||||
}
|
||||
|
||||
[BaseType (typeof (NSObject))]
|
||||
interface ErrorObject
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче