Skip to content

Commit d4c70eb

Browse files
authored
[bgen] Add iOSAttribute and MacAttribute to the binding attributes. (#23806)
This way third-party libraries can use the [iOS] and [Mac] attributes ([TV] and [MacCatalyst] are already available). This also means we can remove some of our legacy/special COREBUILD-only code.
1 parent 35f820d commit d4c70eb

File tree

11 files changed

+79
-968
lines changed

11 files changed

+79
-968
lines changed

src/ObjCRuntime/PlatformAvailability.cs

Lines changed: 0 additions & 510 deletions
This file was deleted.

src/ObjCRuntime/PlatformAvailability2.cs

Lines changed: 0 additions & 309 deletions
This file was deleted.

src/bgen/Attributes.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,32 @@ public MacCatalystAttribute (byte major, byte minor, byte subminor)
12171217
}
12181218
}
12191219

1220+
[AttributeUsage (AttributeTargets.All, AllowMultiple = false)]
1221+
public sealed class MacAttribute : IntroducedAttribute {
1222+
public MacAttribute (byte major, byte minor)
1223+
: base (PlatformName.MacOSX, (int) major, (int) minor)
1224+
{
1225+
}
1226+
1227+
public MacAttribute (byte major, byte minor, byte subminor)
1228+
: base (PlatformName.MacOSX, (int) major, (int) minor, subminor)
1229+
{
1230+
}
1231+
}
1232+
1233+
[AttributeUsage (AttributeTargets.All, AllowMultiple = false)]
1234+
public sealed class iOSAttribute : IntroducedAttribute {
1235+
public iOSAttribute (byte major, byte minor)
1236+
: base (PlatformName.iOS, (int) major, (int) minor)
1237+
{
1238+
}
1239+
1240+
public iOSAttribute (byte major, byte minor, byte subminor)
1241+
: base (PlatformName.iOS, (int) major, (int) minor, subminor)
1242+
{
1243+
}
1244+
}
1245+
12201246
[AttributeUsage (AttributeTargets.All, AllowMultiple = false)]
12211247
public sealed class NoMacAttribute : UnavailableAttribute {
12221248
public NoMacAttribute ()

src/bgen/bgen.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\LinkWithAttribute.cs" />
6060
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\NativeAttribute.cs" />
6161
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\NativeNameAttribute.cs" />
62-
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\PlatformAvailability2.cs" />
6362
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\Registrar.core.cs" />
6463
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\RequiresSuperAttribute.cs" />
6564
<Compile Include="$(RepositoryPath)\tools\common\Execution.cs">

src/frameworks.sources

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,8 +1845,6 @@ SHARED_CORE_SOURCES = \
18451845
ObjCRuntime/TransientString.cs \
18461846
ObjCRuntime/NFloat.cs \
18471847
ObjCRuntime/ObsoleteConstants.cs \
1848-
ObjCRuntime/PlatformAvailability.cs \
1849-
ObjCRuntime/PlatformAvailability2.cs \
18501848
ObjCRuntime/Protocol.cs \
18511849
ObjCRuntime/Registrar.core.cs \
18521850
ObjCRuntime/RequiresSuperAttribute.cs \

tests/generator/BGenTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,18 @@ public void UnderlyingFieldType (Profile profile)
15421542
BuildFile (profile, true, true, "tests/underlyingfieldtype.cs");
15431543
}
15441544

1545+
[Test]
1546+
[TestCase (Profile.iOS)]
1547+
[TestCase (Profile.tvOS)]
1548+
[TestCase (Profile.MacCatalyst)]
1549+
[TestCase (Profile.macOSMobile)]
1550+
public void AvailabilityAttributes (Profile profile)
1551+
{
1552+
Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ());
1553+
var bgen = BuildFile (profile, "tests/availability-attributes.cs");
1554+
bgen.AssertNoWarnings ();
1555+
}
1556+
15451557
[Test]
15461558
[TestCase (Profile.iOS)]
15471559
public void DelegatesWithNullableReturnType (Profile profile)

0 commit comments

Comments
 (0)