Skip to content

Commit

Permalink
[Foundation] Add Support for DotNet Attributes (#12603)
Browse files Browse the repository at this point in the history

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
  • Loading branch information
tj-devel709 and tj_devel709 authored Sep 2, 2021
1 parent 02b671c commit f9c0589
Show file tree
Hide file tree
Showing 9 changed files with 366 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Foundation/NSAttributedString.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using ObjCRuntime;
using Foundation;
using CoreGraphics;
using System.Runtime.Versioning;

#if !MONOMAC
using UIKit;
Expand Down Expand Up @@ -281,7 +282,12 @@ public NSDictionary WeakDefaultAttributes {
#if !COREBUILD && !TVOS && !WATCH
// documentation is unclear if an NSString or an NSUrl should be used...
// but providing an `NSString` throws a `NSInvalidArgumentException Reason: (null) is not a file URL`
#if !NET
[Mac (10, 15), iOS (13, 0)]
#else
[SupportedOSPlatform ("ios13.0")]
[SupportedOSPlatform ("macos10.15")]
#endif
public NSUrl ReadAccessUrl {
get {
Dictionary.TryGetValue (NSAttributedStringDocumentReadingOptionKeys.ReadAccessUrlKey, out var value);
Expand Down
5 changes: 5 additions & 0 deletions src/Foundation/NSCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using CoreFoundation;
using Foundation;
using CoreGraphics;
using System.Runtime.Versioning;
#if !WATCH
using CoreMedia;
#endif
Expand All @@ -39,11 +40,15 @@ namespace Foundation {
public enum NSCalendarType {
Gregorian, Buddhist, Chinese, Hebrew, Islamic, IslamicCivil, Japanese, [Obsolete] RepublicOfChina, Persian, Indian, ISO8601,
Coptic, EthiopicAmeteAlem, EthiopicAmeteMihret,
#if !NET
[Mac (10, 10)]
[iOS (8, 0)]
#endif
IslamicTabular,
#if !NET
[Mac (10, 10)]
[iOS (8, 0)]
#endif
IslamicUmmAlQura,
#pragma warning disable 612 // RepublicOfChina is obsolete
Taiwan = RepublicOfChina
Expand Down
5 changes: 5 additions & 0 deletions src/Foundation/NSCoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ObjCRuntime;

namespace Foundation {
Expand Down Expand Up @@ -177,15 +178,19 @@ public bool TryDecode (string key, out byte [] result)
return false;
}

#if !NET
[iOS (9,0), Mac (10,11)]
#endif
public NSObject DecodeTopLevelObject (Type type, string key, out NSError error)
{
if (type == null)
throw new ArgumentNullException ("type");
return DecodeTopLevelObject (new Class (type), key, out error);
}

#if !NET
[iOS (9,0), Mac (10,11)]
#endif
public NSObject DecodeTopLevelObject (Type[] types, string key, out NSError error)
{
NSSet<Class> typeSet = null;
Expand Down
5 changes: 5 additions & 0 deletions src/Foundation/NSExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// tests for those was not possible. The properties for these two types have been deduced from the other types yet bugs are possible and an objc exception will be thrown.
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ObjCRuntime;

namespace Foundation {
Expand Down Expand Up @@ -92,7 +93,9 @@ public virtual NSExpression LeftExpression {
}
}

#if !NET
[Mac(10,11),iOS(9,0)]
#endif
[Export ("trueExpression")]
public virtual NSExpression TrueExpression {
get {
Expand All @@ -105,7 +108,9 @@ public virtual NSExpression TrueExpression {
}
}

#if !NET
[Mac(10,11),iOS(9,0)]
#endif
[Export ("falseExpression")]
public virtual NSExpression FalseExpression {
get {
Expand Down
3 changes: 3 additions & 0 deletions src/Foundation/NSIndexPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Reflection;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

using ObjCRuntime;

Expand Down Expand Up @@ -71,7 +72,9 @@ public unsafe nuint [] GetIndexes ()
return ret;
}

#if !NET
[iOS (9,0), Mac(10,11)]
#endif
public unsafe nuint [] GetIndexes (NSRange range)
{
var ret = new nuint [range.Length];
Expand Down
16 changes: 16 additions & 0 deletions src/Foundation/NSItemProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using CloudKit;
using ObjCRuntime;
using System.Runtime.Versioning;

namespace Foundation
{
Expand Down Expand Up @@ -29,7 +30,12 @@ public virtual Task<CloudKitRegistrationPreparationHandler> RegisterCloudKitShar
}
#endif

#if !NET
[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public NSProgress LoadObject<T> (Action<T, NSError> completionHandler) where T: NSObject, INSItemProviderReading
{
return LoadObject (new Class (typeof (T)), (rv, err) =>
Expand All @@ -41,7 +47,12 @@ public NSProgress LoadObject<T> (Action<T, NSError> completionHandler) where T:
});
}

#if !NET
[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public Task<T> LoadObjectAsync<T> () where T: NSObject, INSItemProviderReading
{
var rv = LoadObjectAsync (new Class (typeof (T)));
Expand All @@ -54,7 +65,12 @@ public Task<T> LoadObjectAsync<T> () where T: NSObject, INSItemProviderReading
});
}

#if !NET
[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
#else
[SupportedOSPlatform ("ios11.0")]
[SupportedOSPlatform ("tvos11.0")]
#endif
public Task<T> LoadObjectAsync<T> (out NSProgress result) where T: NSObject, INSItemProviderReading
{
var rv = LoadObjectAsync (new Class (typeof (T)), out result);
Expand Down
Loading

7 comments on commit f9c0589

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ [CI Build] Tests passed on Build. ✅

Tests passed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

API Diff (from PR only) (no change)
Generator Diff (only version changes)

Packages generated

View packages

🎉 All 249 tests passed 🎉

Pipeline on Agent XAMBOT-1030.BigSur'
[Foundation] Add Support for DotNet Attributes (#12603)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests tvOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[Foundation] Add Support for DotNet Attributes (#12603)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests iOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[Foundation] Add Support for DotNet Attributes (#12603)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ Tests failed on macOS M1 - Mac Big Sur (11.5) ❌

Tests failed on M1 - Mac Big Sur (11.5).

Failed tests are:

  • xammac_tests

Pipeline on Agent
[Foundation] Add Support for DotNet Attributes (#12603)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ Tests passed on macOS Mac Mojave (10.14) ✅

Tests passed

All tests on macOS X Mac Mojave (10.14) passed.

Pipeline on Agent
[Foundation] Add Support for DotNet Attributes (#12603)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ Status for 'xamarin-macios - sample testing (build)': failure.

  • ❌ Debug_iPhone_AF: Failed
  • ❌ Debug_iPhone_GR: Failed
  • ❌ Debug_iPhone_SZ: Failed
  • ❌ Debug_iPhoneSimulator: Failed
  • ❌ Release_iPhone_AF: Failed
  • ❌ Release_iPhone_GR: Failed
  • ❌ Release_iPhone_SZ: Failed
  • ❌ Release_iPhoneSimulator: Failed
  • ❌ Debug_Mac: Failed
  • ❌ Release_Mac: Failed
  • ❌ PublishPerformanceData: Failed

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (Build). ⚠️

Results were skipped for this run Azure Devops.

Pipeline on Agent
[Foundation] Add Support for DotNet Attributes (#12603)

Co-authored-by: tj_devel709 antlambe@microsoft.com

Please sign in to comment.