Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[generator][dotnet] Add support for [Uns|S]upportedOSPlatformAttribute #10580

Merged
merged 37 commits into from
Apr 10, 2021

Conversation

spouliot
Copy link
Contributor

@spouliot spouliot commented Feb 4, 2021

This moves our current/legacy attributes to the ones added in dotnet 5 [1].

Short Forms (only in bindings)

Old New
[iOS (7,0)] [SupportedOSPlatform ("ios7.0")]
[NoIOS] [UnsupportedOSPlatform ("ios")]

Long Forms

Old New
[Introduced (PlatformName.iOS, 7,0)] [SupportedOSPlatform ("ios7.0")]
[Obsoleted (PlatformName.iOS, 12,1)] [Obsolete (...)]
[Deprecated (PlatformName.iOS, 14,3)] [UnsupportedOSPlatform ("ios14.3")]
[Unavailable (PlatformName.iOS)] [UnsupportedOSPlatform ("ios")]

Other changes

  • [SupportedOSPlatform] and [UnsupportedOSPlatform] are not allowed on interface [2] which means they cannot be used for protocols. This is currently handled by inlining the existing attributes on all members.
  • [ObsoletedInOSPlatform] was removed in net5 RC. This PR is now mapping the existing attributes to [Obsolete], however multiple ones cannot be added so they need to be platform specific.

Tasks

References

This moves our current/legacy attributes to the ones added in dotnet 5 [1].

Short Forms (only in bindings)

| Old                                   | New                                 |
|---------------------------------------|-------------------------------------|
| [iOS (7,0)]                           | [SupportedOSPlatform ("ios7.0")]    |
| [NoIOS]                               | [UnsupportedOSPlatform ("ios")]     |

Long Forms

| Old                                   | New                                 |
|---------------------------------------|-------------------------------------|
| [Introduced (PlatformName.iOS, 7,0)]  | [SupportedOSPlatform ("ios7.0")]    |
| [Obsoleted (PlatformName.iOS, 12,1)]  | [Obsolete (...)]                    |
| [Deprecated (PlatformName.iOS, 14,3)] | [UnsupportedOSPlatform ("ios14.3")] |
| [Unavailable (PlatformName.iOS)]      | [UnsupportedOSPlatform ("ios")]     |

Other changes

* `[SupportedOSPlatform]` and `[UnsupportedOSPlatform]` are not allowed on `interface` [2] which means they cannot be used for protocols. This is currently handled by inlining the existing attributes on all members.
* `[ObsoletedInOSPlatform]` was removed in net5 RC. This PR is now mapping the existing attributes to `[Obsolote]`, however multiple ones cannot be added so they need to be platform specific.

Still Missing

* [ ] Generator deduplication of type/members attributes for interfaces (due to [2])
* [ ] Manual bindings
* [ ] Introspection tests updates

References

* [1] xamarin#10170
* [2] dotnet/runtime#47599
* [3] dotnet/runtime#47601
@spouliot spouliot added the enhancement The issue or pull request is an enhancement label Feb 4, 2021
@spouliot spouliot added this to the .NET 6 milestone Feb 4, 2021
@spouliot spouliot self-assigned this Feb 4, 2021
@spouliot
Copy link
Contributor Author

spouliot commented Feb 4, 2021

Note: right now the CI does not produce the generator diff that makes it hard to review the actual changes. That should be coming soon...

@mandel-macaque
Copy link
Member

@spouliot bumping the generator diff up in my todo then

@spouliot
Copy link
Contributor Author

spouliot commented Feb 4, 2021

@mandel-macaque no rush, there's quite a few more commits before it can land

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

Test results

6 tests failed, 172 tests passed.

Failed tests

  • introspection/iOS Unified 64-bits - simulator/Debug [dotnet]: TimedOut
  • introspection/tvOS - simulator/Debug [dotnet]: TimedOut
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2) [dotnet]: Failed
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 3.2): Failed
  • Generator tests/.NET: Failed (Execution failed with exit code 1)

Pipeline on Agent XAMBOT-1095'

It's a kind of break'ish change as the current behavior is needed to
run the test (even if much less likely to affect production code)
It's defined two times - but only one had the [Deprecated] attribute
Fix existing tests.

Add new `LegacyAttributes` test to spot where and how many of the old
attributes are still in use (manual bindings)
@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

Test results

7 tests failed, 174 tests passed.

Failed tests

  • introspection/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • introspection/tvOS - simulator/Debug [dotnet]: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2) [dotnet]: Failed
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 3.2): Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • Generator tests/.NET: Failed (Execution failed with exit code 1)

Pipeline on Agent XAMBOT-1104'

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

Test results

5 tests failed, 176 tests passed.

Failed tests

  • introspection/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • introspection/tvOS - simulator/Debug [dotnet]: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2) [dotnet]: Failed
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 3.2): Failed

Pipeline on Agent XAMBOT-1094'

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

Test results

5 tests failed, 176 tests passed.

Failed tests

  • introspection/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • introspection/tvOS - simulator/Debug [dotnet]: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2) [dotnet]: Failed
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 3.2): Failed

Pipeline on Agent XAMBOT-1106'

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

Test results

5 tests failed, 176 tests passed.

Failed tests

  • introspection/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • introspection/tvOS - simulator/Debug [dotnet]: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2) [dotnet]: Failed
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 3.2): Failed

Pipeline on Agent XAMBOT-1095'

* Add test to detect duplicates between members and type-level attributes
  to reduce the number of manual entries required to be updated

* Add test to check the string argument of [SupportedOSPlatform] and
  [UnsupportedOSPlatform] in preparation for manual bindings updates

* Fix Legacy test - check the members, not twice the type, custom attributes
@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

Test results

11 tests failed, 170 tests passed.

Failed tests

  • introspection/Mac Modern/Debug: Failed (Tests run: 37 Passed: 35 Inconclusive: 0 Failed: 1 Ignored: 1)
  • introspection/iOS Unified 64-bits - simulator/Debug: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • introspection/tvOS - simulator/Debug: Failed
  • introspection/tvOS - simulator/Debug [dotnet]: Failed
  • introspection/watchOS 32-bits - simulator/Debug: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3): Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2): Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2) [dotnet]: Failed
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 3.2): Failed

Pipeline on Agent XAMBOT-1100'

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

Test results

11 tests failed, 170 tests passed.

Failed tests

  • introspection/Mac Modern/Debug: Failed (Tests run: 37 Passed: 35 Inconclusive: 0 Failed: 1 Ignored: 1)
  • introspection/iOS Unified 64-bits - simulator/Debug: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • introspection/tvOS - simulator/Debug: Failed
  • introspection/tvOS - simulator/Debug [dotnet]: Failed
  • introspection/watchOS 32-bits - simulator/Debug: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3): Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2): Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2) [dotnet]: Failed
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 3.2): Failed

Pipeline on Agent XAMBOT-1095'

spouliot added a commit to spouliot/xamarin-macios that referenced this pull request Feb 22, 2021
- this requires small (but tricky) generator changes
- duplicate availability attributes detection is tested by introspection
- it also requires removing dupes in manual bindings (which was the
  current, if not the _named_, goal for this PR)

Long story:

It's always been hard to detect and enforce removal of extraneous
availability attributes since the generator inlined them _freely_
when processing ObjC protocols.

That meant introspection could not report dupes and led to many
extra attributes. This was **not** a problem in binding files since we
could ignore them. IOW their presence (in the input) does not mean they
are _all_ dupes in generated code (output).

However dupes in manual bindings were also (forced to be) _ignored_ and
those were part of the assemblies we ship. Again it was not a big deal,
nor a source of much extra metadata/size, so it was ignored.

Forward to today, manual bindings needs to be updated for net6 [1] so any
extra we have requires more (manual) work. Cleaning this problem up in
the generator code reduce the (manual) work we need to do.

It also means introspection can detect dupes (in generated and manual
code) so we don't end up adding more (which would also require more
manual work to support both set of attributes).

[1] xamarin#10580
@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

Test results

2 tests failed, 180 tests passed.

Failed tests

  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2) [dotnet]: Failed

Pipeline on Agent XAMBOT-1095'

Mostly for dotnet, few for watchOS 2.0.

Only API newer than the minimum supported OS needs to be decorated.
@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

Test results

6 tests failed, 176 tests passed.

Failed tests

  • introspection/Mac Modern/Debug: Failed (Test run failed.
    Tests run: 37 Passed: 32 Inconclusive: 0 Failed: 4 Ignored: 1)
  • introspection/iOS Unified 64-bits - simulator/Debug: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3): Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2) [dotnet]: Failed
  • Generator tests/.NET: Failed (Execution failed with exit code 1)

Pipeline on Agent XAMBOT-1094'

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

Test results

3 tests failed, 179 tests passed.

Failed tests

  • introspection/Mac Modern/Debug: Failed (Test run failed.
    Tests run: 37 Passed: 33 Inconclusive: 0 Failed: 3 Ignored: 1)
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2) [dotnet]: Failed

Pipeline on Agent XAMBOT-1099'

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

Test results

3 tests failed, 179 tests passed.

Failed tests

  • introspection/Mac Modern/Debug: Failed (Test run failed.
    Tests run: 37 Passed: 33 Inconclusive: 0 Failed: 3 Ignored: 1)
  • link sdk/iOS Unified 64-bits - simulator/Debug: Failed
  • link sdk/iOS Unified 64-bits - simulator/Release: Failed

Pipeline on Agent XAMBOT-1101'

Sebastien Pouliot added 2 commits March 31, 2021 09:57
and, without it, introspection (on dotnet [1]) will try to run tests on it

Quote from `NSMenuView.h`

```objc
```

[1] the new attribute do not have anythings similar to the legacy
`PlatformArchitecture` enum
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ Tests passed on Build. ✅

Tests passed on Build.

API diff

✅ API Diff from stable

View API diff

🎉 All 80 tests passed 🎉

Pipeline on Agent XAMBOT-1100'

@spouliot spouliot added the run-dotnet-tests Run all the .NET tests label Mar 31, 2021
@spouliot
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ Tests passed on Build. ✅

Tests passed on Build.

API diff

✅ API Diff from stable

View API diff

🎉 All 80 tests passed 🎉

Pipeline on Agent XAMBOT-1094'

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ Tests passed on Build. ✅

Tests passed on Build.

API diff

✅ API Diff from stable

View API diff

🎉 All 94 tests passed 🎉

Pipeline on Agent XAMBOT-1100'

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

Test results

2 tests failed, 96 tests passed.

Failed tests

  • introspection/watchOS 32-bits - simulator/Debug (watchOS 5.0): LaunchFailure
  • MSBuild tests/Integration: TimedOut (Execution timed out after 90 minutes.)

Pipeline on Agent XAMBOT-1106'

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

Test results

1 tests failed, 97 tests passed.

Failed tests

  • introspection/watchOS 32-bits - simulator/Debug (watchOS 5.0): LaunchFailure

Pipeline on Agent XAMBOT-1104.BigSur

@spouliot
Copy link
Contributor Author

Known issue unrelated to PR https://github.com/xamarin/maccore/issues/2411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue or pull request is an enhancement run-dotnet-tests Run all the .NET tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants