Skip to content

Commit e540b51

Browse files
authored
[generator] Honor [Internal] on delegates. Fixes #15299. (#19038)
Fixes #15299.
1 parent 0d3d4ff commit e540b51

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/bgen/Generator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4799,10 +4799,12 @@ group fullname by ns into g
47994799
if (AttributeManager.HasAttribute (mi.DeclaringType, "MonoNativeFunctionWrapper"))
48004800
print ("[MonoNativeFunctionWrapper]\n");
48014801

4802-
print ("public delegate {0} {1} ({2});",
4802+
var accessibility = mi.DeclaringType.IsInternal (this) ? "internal" : "public";
4803+
print ("{3} delegate {0} {1} ({2});",
48034804
RenderType (mi.ReturnType, mi.ReturnTypeCustomAttributes),
48044805
shortName,
4805-
RenderParameterDecl (mi.GetParameters ()));
4806+
RenderParameterDecl (mi.GetParameters ()),
4807+
accessibility);
48064808
}
48074809

48084810
if (group.Namespace is not null) {

tests/generator/BGenTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,12 @@ public void ObsoletedOSPlatform (Profile profile)
14201420
bgen.AssertExecute ("build");
14211421
}
14221422

1423+
[Test]
1424+
public void InternalDelegate ()
1425+
{
1426+
BuildFile (Profile.iOS, "tests/internal-delegate.cs");
1427+
}
1428+
14231429
BGenTool BuildFile (Profile profile, params string [] filenames)
14241430
{
14251431
return BuildFile (profile, true, false, filenames);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using Foundation;
3+
4+
namespace NS {
5+
[Internal]
6+
delegate void Whatever (SomeType value);
7+
8+
[Internal]
9+
[BaseType (typeof (NSObject))]
10+
interface SomeType {
11+
[Export ("whatever")]
12+
Whatever Nope { get; set; }
13+
}
14+
}
15+

0 commit comments

Comments
 (0)