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

[Foundation] Add bindings for NSBackgroundActivityScheduler #7496

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/foundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16594,4 +16594,50 @@ enum NSUrlErrorNetworkUnavailableReason : long {
Expensive = 1,
Constrained = 2,
}

[NoWatch, NoTV, NoiOS, Mac (10,10)]
[Native]
public enum NSBackgroundActivityResult : long
{
Finished = 1,
Deferred = 2,
}

delegate void NSBackgroundActivityCompletionHandler (NSBackgroundActivityResult result);

delegate void NSBackgroundActivityCompletionAction ([BlockCallback] NSBackgroundActivityCompletionHandler handler);

[NoWatch, NoTV, NoiOS, Mac (10,10)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface NSBackgroundActivityScheduler
{
[Export ("initWithIdentifier:")]
[DesignatedInitializer]
IntPtr Constructor (string identifier);

[Export ("identifier")]
string Identifier { get; }

[Export ("qualityOfService", ArgumentSemantic.Assign)]
NSQualityOfService QualityOfService { get; set; }

[Export ("repeats")]
bool Repeats { get; set; }

[Export ("interval")]
double Interval { get; set; }

[Export ("tolerance")]
double Tolerance { get; set; }

[Export ("scheduleWithBlock:")]
void Schedule (NSBackgroundActivityCompletionAction action);
Comment on lines +16634 to +16635
Copy link

@ghost ghost Nov 26, 2019

Choose a reason for hiding this comment

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

question (not feedback): During team week @dalexsoto mentioned the Async attribute should be used when the last argument of a method is a callback. Why isn't async used here, isn't this method asynchronous in objc?

Copy link
Member

Choose a reason for hiding this comment

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

@wachaudh because in this case, it is not a function to be called when the method is completed with the result of the operation, but a function to be schedule to be called.

That is, if the callback taken by the function is going to be called with the results of the function, you should use Async. In this case you are just giving a function to be schedule.


[Export ("invalidate")]
void Invalidate ();

[Export ("shouldDefer")]
bool ShouldDefer { get; }
}
}
15 changes: 0 additions & 15 deletions tests/xtro-sharpie/macOS-Foundation.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

!extra-designated-initializer! NSScriptCommand::initWithCoder: is incorrectly decorated with an [DesignatedInitializer] attribute
!extra-protocol-member! unexpected selector NSURLSessionDelegate::URLSessionDidFinishEventsForBackgroundURLSession: found
!missing-enum! NSBackgroundActivityResult not bound
!missing-enum! NSDistributedNotificationOptions not bound
!missing-enum! NSInsertionPosition not bound
!missing-enum! NSRelativePosition not bound
Expand Down Expand Up @@ -212,18 +211,6 @@
!missing-selector! NSArchiver::encodeRootObject: not bound
!missing-selector! NSArchiver::initForWritingWithMutableData: not bound
!missing-selector! NSArchiver::replaceObject:withObject: not bound
!missing-selector! NSBackgroundActivityScheduler::identifier not bound
!missing-selector! NSBackgroundActivityScheduler::initWithIdentifier: not bound
!missing-selector! NSBackgroundActivityScheduler::interval not bound
!missing-selector! NSBackgroundActivityScheduler::qualityOfService not bound
!missing-selector! NSBackgroundActivityScheduler::repeats not bound
!missing-selector! NSBackgroundActivityScheduler::scheduleWithBlock: not bound
!missing-selector! NSBackgroundActivityScheduler::setInterval: not bound
!missing-selector! NSBackgroundActivityScheduler::setQualityOfService: not bound
!missing-selector! NSBackgroundActivityScheduler::setRepeats: not bound
!missing-selector! NSBackgroundActivityScheduler::setTolerance: not bound
!missing-selector! NSBackgroundActivityScheduler::shouldDefer not bound
!missing-selector! NSBackgroundActivityScheduler::tolerance not bound
!missing-selector! NSCalendarDate::years:months:days:hours:minutes:seconds:sinceDate: not bound
!missing-selector! NSClassDescription::attributeKeys not bound
!missing-selector! NSClassDescription::inverseForRelationshipKey: not bound
Expand Down Expand Up @@ -660,7 +647,6 @@
!missing-selector! NSXMLNode::XMLStringWithOptions: not bound
!missing-selector! NSXMLNode::XPath not bound
!missing-type! NSArchiver not bound
!missing-type! NSBackgroundActivityScheduler not bound
!missing-type! NSClassDescription not bound
!missing-type! NSCloneCommand not bound
!missing-type! NSCloseCommand not bound
Expand Down Expand Up @@ -755,7 +741,6 @@
!missing-selector! +NSScriptSuiteRegistry::sharedScriptSuiteRegistry not bound
!missing-selector! +NSSocketPortNameServer::sharedInstance not bound
!missing-selector! +NSXMLNode::document not bound
!missing-selector! NSBackgroundActivityScheduler::invalidate not bound
!missing-selector! NSCoder::decodePoint not bound
!missing-selector! NSCoder::decodePropertyList not bound
!missing-selector! NSCoder::decodeRect not bound
Expand Down