Skip to content

Commit

Permalink
[release/7.0.3xx] [bgen] Add support for converting ObsoletedOSPlatfo…
Browse files Browse the repository at this point in the history
…rm attributes. Fixes #18966. (#18990)

Fixes #18966.


Backport of #18972

---------

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
Co-authored-by: GitHub Actions Autoformatter <[email protected]>
  • Loading branch information
3 people authored Sep 13, 2023
1 parent 9dca5fd commit a08b9f3
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/bgen/AttributeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ Type LookupReflectionType (string fullname, ICustomAttributeProvider provider)
return typeof (System.Runtime.Versioning.SupportedOSPlatformAttribute);
case "System.Runtime.Versioning.UnsupportedOSPlatformAttribute":
return typeof (System.Runtime.Versioning.UnsupportedOSPlatformAttribute);
case "System.Runtime.Versioning.ObsoletedOSPlatformAttribute":
return typeof (System.Runtime.Versioning.ObsoletedOSPlatformAttribute);
#endif
}

Expand Down Expand Up @@ -338,6 +340,14 @@ Type ConvertTypeToMeta (System.Type type, ICustomAttributeProvider provider)
return AttributeFactory.CreateNewAttribute<UnavailableAttribute> (up).Yield ();
else
return Enumerable.Empty<System.Attribute> ();
case "ObsoletedOSPlatformAttribute":
var oarg = attribute.ConstructorArguments [0].Value as string;
(var op, var ov) = ParseOSPlatformAttribute (oarg);
// might have been available for a while...
if (ov is null)
return AttributeFactory.CreateNewAttribute<ObsoletedAttribute> (op).Yield ();
else
return AttributeFactory.CreateNewAttribute<ObsoletedAttribute> (op, ov.Major, ov.Minor).Yield ();
#endif
default:
return Enumerable.Empty<System.Attribute> ();
Expand Down
2 changes: 1 addition & 1 deletion tests/bgen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ TOP=../..
include $(TOP)/Make.config

run-tests:
$(DOTNET) test
$(DOTNET) test $(TEST_FILTER)
7 changes: 6 additions & 1 deletion tests/common/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -837,13 +837,18 @@ public static IEnumerable<string> GetBaseLibraryImplementations (ApplePlatform p
}
}


public static IEnumerable<string> GetRefLibraries ()
{
foreach (var platform in GetIncludedPlatforms (true))
yield return Path.Combine (GetRefDirectory (platform), GetBaseLibraryName (platform, true));
}


public static string GetRefLibrary (ApplePlatform platform)
{
return GetBaseLibrary (platform, true);
}

public static string GetTargetFramework (Profile profile)
{
switch (profile) {
Expand Down
15 changes: 15 additions & 0 deletions tests/generator/BGenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,21 @@ public void NewerAvailabilityInInlinedProtocol (Profile profile)
Assert.That (failures, Is.Empty, "Failures");
}

#if !NET
[Ignore ("This only applies to .NET")]
#endif
[Test]
[TestCase (Profile.iOS)]
public void ObsoletedOSPlatform (Profile profile)
{
Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ());
var bgen = new BGenTool ();
bgen.Profile = profile;
bgen.AddTestApiDefinition ("tests/obsoletedosplatform.cs");
bgen.CreateTemporaryBinding ();
bgen.AssertExecute ("build");
}

BGenTool BuildFile (Profile profile, params string [] filenames)
{
return BuildFile (profile, true, false, filenames);
Expand Down
10 changes: 10 additions & 0 deletions tests/generator/tests/obsoletedosplatform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Runtime.Versioning;
using Foundation;
using UIKit;

namespace iosbindinglib {
[Protocol, Model]
[BaseType (typeof (UIApplicationDelegate))]
public interface TestDelegate {
}
}

8 comments on commit a08b9f3

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ API diff for current PR / commit

NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

✅ API diff vs stable

.NET (No breaking changes)

✅ Generator diff

Generator diff is empty

Pipeline on Agent
Hash: a08b9f39d55fc489a6df15381b605608f6b70980 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Ventura (13.0) passed 💻

All tests on macOS M1 - Mac Ventura (13.0) passed.

Pipeline on Agent
Hash: a08b9f39d55fc489a6df15381b605608f6b70980 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻

All tests on macOS M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Hash: a08b9f39d55fc489a6df15381b605608f6b70980 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: a08b9f39d55fc489a6df15381b605608f6b70980 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMMINI-070.Ventura
Hash: a08b9f39d55fc489a6df15381b605608f6b70980 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: simulator tests

0 tests crashed, 1 tests failed, 76 tests passed.

Failures

❌ dotnettests tests

1 tests failed, 0 tests passed.
  • DotNet tests: Failed (Execution failed with exit code 1)

Html Report (VSDrops) Download

Successes

⚠️ bcl: No tests selected. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 2 tests passed. Html Report (VSDrops) Download
✅ framework: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 4 tests passed. Html Report (VSDrops) Download
⚠️ install_source: No tests selected. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 40 tests passed. Html Report (VSDrops) Download
⚠️ mac_binding_project: No tests selected. Html Report (VSDrops) Download
⚠️ mmp: No tests selected. Html Report (VSDrops) Download
⚠️ mononative: No tests selected. Html Report (VSDrops) Download
✅ monotouch: All 13 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
⚠️ mtouch: No tests selected. Html Report (VSDrops) Download
⚠️ xammac: No tests selected. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: a08b9f39d55fc489a6df15381b605608f6b70980 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: simulator tests

0 tests crashed, 1 tests failed, 76 tests passed.

Failures

❌ dotnettests tests [attempt 2]

1 tests failed, 0 tests passed.
  • DotNet tests: Failed (Execution failed with exit code 1)

Html Report (VSDrops) Download

Successes

⚠️ bcl: No tests selected. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 2 tests passed. Html Report (VSDrops) Download
✅ framework: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 4 tests passed. Html Report (VSDrops) Download
⚠️ install_source: No tests selected. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 40 tests passed. Html Report (VSDrops) Download
⚠️ mac_binding_project: No tests selected. Html Report (VSDrops) Download
⚠️ mmp: No tests selected. Html Report (VSDrops) Download
⚠️ mononative: No tests selected. Html Report (VSDrops) Download
✅ monotouch: All 13 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
⚠️ mtouch: No tests selected. Html Report (VSDrops) Download
⚠️ xammac: No tests selected. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: a08b9f39d55fc489a6df15381b605608f6b70980 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: simulator tests

0 tests crashed, 1 tests failed, 76 tests passed.

Failures

❌ dotnettests tests [attempt 3]

1 tests failed, 0 tests passed.
  • DotNet tests: Failed (Execution failed with exit code 1)

Html Report (VSDrops) Download

Successes

⚠️ bcl: No tests selected. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 2 tests passed. Html Report (VSDrops) Download
✅ framework: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 4 tests passed. Html Report (VSDrops) Download
⚠️ install_source: No tests selected. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 40 tests passed. Html Report (VSDrops) Download
⚠️ mac_binding_project: No tests selected. Html Report (VSDrops) Download
⚠️ mmp: No tests selected. Html Report (VSDrops) Download
⚠️ mononative: No tests selected. Html Report (VSDrops) Download
✅ monotouch: All 13 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
⚠️ mtouch: No tests selected. Html Report (VSDrops) Download
⚠️ xammac: No tests selected. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: a08b9f39d55fc489a6df15381b605608f6b70980 [CI build]

Please sign in to comment.