Skip to content

Commit

Permalink
[release/6.0.3xx] [NET Attribute Conversion][generator] Generate NET …
Browse files Browse the repository at this point in the history
…style attributes (#14877)

* [NET Attribute Conversion][generator] Generate NET style attributes

- The integration with the existing generator code is not ideal in this
commit, but given time pressures it will hopefully be improved in the future.
- GetPlatformAttributesToPrint is repeating some of the logic that is #if !NET'ed out
in places such as PrintPlatformAttributes because those checks were not robust enough
for the NET6 attribute logic (we generate many more 'duplicate' attributes now)

* Add new FindSupportedOnElementsThatDoNotExistInThatAssembly test and remove now unnecessary ignores on other tests

* API corrections found by new test

* Attribute corrections found due to test

* Xtro todo removals due to better attributes

* Correct defines to include GetCurrentInputDevice on Catalyst

- This is an actual API inclusion, not just attribute change.
- All of the other defines, and attributes imply that GetCurrentInputDevice()
was expected to be on catalyst, but the define on 433 did not include it

* Fix API breaks

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Update src/generator.cs

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Remove hack that was disabling a test and fix test failures that it covered up

* Hack around 'is decorated more than once with' in NET6 introspection tests for now

* Correct invalid attributes caused by incorrect namespace check (we were lower cased in one place but not another)

* Add a hack in for webkit/wkwebkit

* Actually add introspection test hacks

* Change generated attributes and fix known test failures

- Generate Obsolete/Advice and Unsupported pairs for Deprecated/Obsoleted instead of a single attribute
- A number of generator improvements and test/binding fixes

* More test fixes

* Remove now unnecessary hack

* Code review changes

* Fix 3rd party binding having no attributes due to StripIntroducedOnNamespaceNotIncluded always assuming we're core

Co-authored-by: Chris Hamons <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
  • Loading branch information
3 people authored May 4, 2022
1 parent 3f73ae0 commit 2ad0c24
Show file tree
Hide file tree
Showing 102 changed files with 1,499 additions and 755 deletions.
2 changes: 2 additions & 0 deletions src/ARKit/ARSkeleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public partial class ARSkeleton {

#if NET
[SupportedOSPlatform ("ios14.0")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[iOS (14,0)]
#endif
Expand All @@ -20,6 +21,7 @@ public partial class ARSkeleton {

#if NET
[SupportedOSPlatform ("ios14.0")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[iOS (14,0)]
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/AVFoundation/AVCaptureVideoPreviewLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public enum InitMode {
WithConnection,
#if NET
[SupportedOSPlatform ("ios8.0")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("maccatalyst")]
#else
[iOS (8,0)]
#endif
Expand Down
7 changes: 1 addition & 6 deletions src/AVFoundation/AVTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,6 @@ public override int GetHashCode ()
}
}

#if NET
[SupportedOSPlatform ("ios8.0")]
[SupportedOSPlatform ("macos10.10")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
#endif
#if !COREBUILD
public static partial class AVMetadataIdentifiers {
}
Expand Down Expand Up @@ -419,6 +413,7 @@ public struct AVSampleCursorChunkInfo {

#if NET
[SupportedOSPlatform ("macos10.15")]
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[Mac (10,15)]
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/AVFoundation/AVVideoSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public double? MaxKeyFrameIntervalDuration {
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("macos")]
#else
[iOS (7,0)]
#endif
Expand All @@ -257,8 +257,8 @@ public bool? AllowFrameReordering {
#if NET
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos")]
#else
[iOS (7,0)]
#endif
Expand Down Expand Up @@ -300,8 +300,8 @@ public AVVideoH264EntropyMode? EntropyEncoding {
#if NET
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos")]
#else
[iOS (7,0)]
#endif
Expand All @@ -318,8 +318,8 @@ public float? ExpectedSourceFrameRate {
#if NET
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos")]
#else
[iOS (7,0)]
#endif
Expand Down
1 change: 1 addition & 0 deletions src/AVFoundation/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ public enum AVCaptureAutoFocusSystem : long {
[NoWatch]
[iOS (9, 0)]
[Native]
[NoMac]
public enum AVCaptureSessionInterruptionReason : long {
VideoDeviceNotAvailableInBackground = 1,
AudioDeviceInUseByAnotherClient = 2,
Expand Down
2 changes: 2 additions & 0 deletions src/AddressBook/ABPerson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace AddressBook {

#if NET
[UnsupportedOSPlatform ("ios9.0")]
[UnsupportedOSPlatform ("maccatalyst")]
#if IOS
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
Expand Down Expand Up @@ -251,6 +252,7 @@ internal static void Init ()

#if NET
[UnsupportedOSPlatform ("ios9.0")]
[UnsupportedOSPlatform ("maccatalyst")]
#if IOS
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
Expand Down
1 change: 1 addition & 0 deletions src/AddressBook/ABSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public ABSourceType SourceType {

#if NET
[UnsupportedOSPlatform ("ios9.0")]
[UnsupportedOSPlatform ("maccatalyst")]
#if IOS
[Obsolete ("Starting with ios9.0 use the 'Contacts' API instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
Expand Down
1 change: 1 addition & 0 deletions src/AppKit/Defs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
namespace AppKit {
#if NET
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("maccatalyst")]
#endif
[StructLayout (LayoutKind.Sequential)]
public struct NSEdgeInsets {
Expand Down
5 changes: 0 additions & 5 deletions src/AppKit/NSAccessibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@

namespace AppKit
{
#if NET
[SupportedOSPlatform ("macos10.10")]
#else
[Mac (10,10)] // protocol added in 10.10
#endif
public partial interface INSAccessibility {}

#if NET
Expand Down
17 changes: 15 additions & 2 deletions src/AudioUnit/AUEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,20 @@ public enum AudioObjectPropertySelector : uint
TranslateUIDToBox = 1969841250, // 'uidb'
ClockDeviceList = 1668049699, //'clk#'
TranslateUidToClockDevice = 1969841251, // 'uidc',
#if XAMCORE_3_0
[NoiOS][NoTV]
#endif
[Deprecated (PlatformName.iOS, 15,0, message : "Use the 'ProcessIsMain' element instead.")]
[Deprecated (PlatformName.MacCatalyst, 15,0, message : "Use the 'ProcessIsMain' element instead.")]
[Deprecated (PlatformName.MacOSX, 12,0, message : "Use the 'ProcessIsMain' element instead.")]
[Obsolete ("Use the 'ProcessIsMain' element instead.")]
ProcessIsMaster = 1835103092, // 'mast'
[iOS (15,0), MacCatalyst (15,0), Mac (12,0), NoTV, NoWatch]
#if !XAMCORE_3_0
[iOS (15,0)]
#else
[NoiOS]
#endif
[MacCatalyst (15,0), Mac (12,0), NoTV, NoWatch]
ProcessIsMain = 1835100526, // 'main'
IsInitingOrExiting = 1768845172, // 'inot'
UserIDChanged = 1702193508, // 'euid'
Expand All @@ -208,7 +216,12 @@ public enum AudioObjectPropertySelector : uint
ActualSampleRate = 1634955892,// 'asrt',
ClockDevice = 1634755428, // 'apcd',
IOThreadOSWorkgroup = 1869838183, // 'oswg'
[iOS (15,0), MacCatalyst (15,0), Mac (12,0), NoTV, NoWatch]
#if !XAMCORE_3_0
[iOS (15,0)]
#else
[NoiOS]
#endif
[MacCatalyst (15,0), Mac (12,0), NoTV, NoWatch]
ProcessMute = 1634758765, // 'appm'
}

Expand Down
9 changes: 0 additions & 9 deletions src/AudioUnit/AUParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@

namespace AudioUnit
{
#if NET
[SupportedOSPlatform ("ios9.0")]
[SupportedOSPlatform ("macos10.11")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("tvos")]
#else
[iOS (9,0)]
[Mac (10,11)]
#endif
public partial class AUParameter
{
public string GetString (float? value)
Expand Down
12 changes: 6 additions & 6 deletions src/AudioUnit/AudioComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ public Version? Version {
#if !__MACCATALYST__
#if NET
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos14.0")]
[UnsupportedOSPlatform ("ios14.0")]
#if TVOS
Expand All @@ -412,9 +412,9 @@ public Version? Version {

#if NET
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos14.0")]
[UnsupportedOSPlatform ("ios14.0")]
#if TVOS
Expand All @@ -436,11 +436,11 @@ public Version? Version {
#if NET
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst14.0")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("maccatalyst14.0")]
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("macos")]
#if TVOS
[Obsolete ("Starting with tvos13.0.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif __MACCATALYST__
Expand All @@ -461,11 +461,11 @@ public Version? Version {
#if NET
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst14.0")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("maccatalyst14.0")]
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("macos")]
#if TVOS
[Obsolete ("Starting with tvos13.0 use 'AudioUnit' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif __MACCATALYST__
Expand Down
14 changes: 9 additions & 5 deletions src/AudioUnit/AudioComponentDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public enum AudioTypeConverter { // OSType in AudioComponentDescription
#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("ios13.0")]
#if TVOS
Expand Down Expand Up @@ -210,10 +210,10 @@ public enum AudioTypeEffect { // OSType in AudioComponentDescription
#else
#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("macos")]
#if TVOS
[Obsolete ("Starting with tvos13.0 use 'AudioTypeEffect.GraphicEQ' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif IOS
Expand Down Expand Up @@ -248,10 +248,10 @@ public enum AudioTypeMixer { // OSType in AudioComponentDescription
#if MONOMAC
Stereo=0x736d7872, // 'smxr'
#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos10.10")]
#if MONOMAC
[Obsolete ("Starting with macos10.10 use 'Spacial' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
Expand All @@ -262,7 +262,11 @@ public enum AudioTypeMixer { // OSType in AudioComponentDescription
ThreeD=0x33646d78, // '3dmx'
#else
#if NET
[SupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("ios8.0")]
[UnsupportedOSPlatform ("maccatalyst")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos")]
#if IOS
[Obsolete ("Starting with ios8.0 use 'Spacial' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
Expand Down
14 changes: 7 additions & 7 deletions src/AudioUnit/AudioUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,15 @@ public uint GetCurrentDevice (AudioUnitScopeType scope, uint audioUnitElement =
return device;
}

#if !XAMCORE_3_0 || MONOMAC
#if !MONOMAC
#if !XAMCORE_3_0 || MONOMAC || __MACCATALYST__
#if !MONOMAC && !__MACCATALYST__
[Obsolete ("This API is not available on iOS.")]
#endif
#if NET
[SupportedOSPlatform ("maccatalyst15.0")]
[SupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
#else
[MacCatalyst (15,0)]
#endif
Expand Down Expand Up @@ -748,11 +748,11 @@ static AudioUnitStatus InputCallbackImpl (IntPtr clientData, ref AudioUnitRender
#if NET
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst14.0")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("maccatalyst14.0")]
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("macos")]
#if TVOS
[Obsolete ("Starting with tvos13.0 use 'AudioUnit' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif __MACCATALYST__
Expand Down Expand Up @@ -784,11 +784,11 @@ public AudioComponentStatus AudioOutputUnitPublish (AudioComponentDescription de
#if NET
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst14.0")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("maccatalyst14.0")]
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("macos")]
#if TVOS
[Obsolete ("Starting with tvos13.0.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif __MACCATALYST__
Expand All @@ -809,11 +809,11 @@ public AudioComponentStatus AudioOutputUnitPublish (AudioComponentDescription de
#if NET
[SupportedOSPlatform ("ios7.0")]
[SupportedOSPlatform ("maccatalyst14.0")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("tvos13.0")]
[UnsupportedOSPlatform ("maccatalyst14.0")]
[UnsupportedOSPlatform ("ios13.0")]
[UnsupportedOSPlatform ("macos")]
#if TVOS
[Obsolete ("Starting with tvos13.0 use 'AudioUnit' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif __MACCATALYST__
Expand Down
1 change: 1 addition & 0 deletions src/CFNetwork/CFHTTPMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public enum AuthenticationScheme {
[UnsupportedOSPlatform ("tvos12.0")]
[UnsupportedOSPlatform ("macos10.14")]
[UnsupportedOSPlatform ("ios12.0")]
[UnsupportedOSPlatform ("maccatalyst")]
#if TVOS
[Obsolete ("Starting with tvos12.0 not available anymore.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#elif MONOMAC
Expand Down
2 changes: 2 additions & 0 deletions src/Contacts/CNEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ public enum CNContactOptions : long {
NonGregorianBirthday = 1 << 8,
Note = 1 << 9,
#if !MONOMAC
[NoMac]
ImageData = 1 << 10,
#endif
ThumbnailImageData = 1 << 11,
#if !MONOMAC
[NoMac]
ImageDataAvailable = 1 << 12,
#endif
Type = 1 << 13,
Expand Down
Loading

5 comments on commit 2ad0c24

@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] API Diff 📋

API Current PR diff

ℹ️ API Diff (from PR only) (please review changes)

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

API diff

✅ API Diff from stable

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

Generator diff

ℹ️ Generator Diff (please review changes)

Pipeline on Agent XAMMINI-068.Monterey
Hash: 2ad0c24a2cf52287f805ca3c6e15ff54e2266caa

@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-067.Monterey'
Hash: 2ad0c24a2cf52287f805ca3c6e15ff54e2266caa

@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 Mac Catalina (10.15) failed ❌

Failed tests are:

  • introspection

Pipeline on Agent
Hash: 2ad0c24a2cf52287f805ca3c6e15ff54e2266caa

@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: 2ad0c24a2cf52287f805ca3c6e15ff54e2266caa

@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 failed on VSTS: simulator tests iOS ❌

Tests failed on VSTS: simulator tests iOS.

Test results

2 tests failed, 232 tests passed.

Failed tests

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

Pipeline on Agent XAMBOT-1094.Monterey
[release/6.0.3xx] [NET Attribute Conversion][generator] Generate NET style attributes (#14877)

Please sign in to comment.