Skip to content

Commit

Permalink
[xtro] Fix nullability checks on parameters (dotnet#10279)
Browse files Browse the repository at this point in the history
and fix most (append for AppKit) additional missing/extra null that this
fix detected in the bindings
  • Loading branch information
spouliot authored Dec 15, 2020
1 parent 896479e commit d768431
Show file tree
Hide file tree
Showing 16 changed files with 138 additions and 58 deletions.
6 changes: 3 additions & 3 deletions src/avfoundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10962,7 +10962,7 @@ interface AVPlayer {

[Export ("prerollAtRate:completionHandler:")]
[Async]
void Preroll (float /* defined as 'float' */ rate, AVCompletion onComplete);
void Preroll (float /* defined as 'float' */ rate, [NullAllowed] AVCompletion onComplete);

[Export ("cancelPendingPrerolls")]
void CancelPendingPrerolls ();
Expand Down Expand Up @@ -11338,14 +11338,14 @@ interface AVPlayerItem : NSCopying {

[Export ("seekToTime:completionHandler:")]
[Async]
void Seek (CMTime time, AVCompletion completion);
void Seek (CMTime time, [NullAllowed] AVCompletion completion);

[Export ("cancelPendingSeeks")]
void CancelPendingSeeks ();

[Export ("seekToTime:toleranceBefore:toleranceAfter:completionHandler:")]
[Async]
void Seek (CMTime time, CMTime toleranceBefore, CMTime toleranceAfter, AVCompletion completion);
void Seek (CMTime time, CMTime toleranceBefore, CMTime toleranceAfter, [NullAllowed] AVCompletion completion);

[Export ("selectMediaOption:inMediaSelectionGroup:")]
void SelectMediaOption ([NullAllowed] AVMediaSelectionOption mediaSelectionOption, AVMediaSelectionGroup mediaSelectionGroup);
Expand Down
2 changes: 1 addition & 1 deletion src/avkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ interface AVPlayerViewControllerDelegate

[NoiOS, TV (11,0), NoWatch, NoMac]
[Export ("playerViewController:willTransitionToVisibilityOfTransportBar:withAnimationCoordinator:")]
void WillTransitionToVisibilityOfTransportBar (AVPlayerViewController playerViewController, bool visible, [NullAllowed] IAVPlayerViewControllerAnimationCoordinator coordinator);
void WillTransitionToVisibilityOfTransportBar (AVPlayerViewController playerViewController, bool visible, IAVPlayerViewControllerAnimationCoordinator coordinator);

[iOS (13,0), NoTV, NoWatch, NoMac]
[Export ("playerViewController:willBeginFullScreenPresentationWithAnimationCoordinator:"), EventArgs ("AVPlayerViewFullScreenPresentationWillBegin")]
Expand Down
2 changes: 1 addition & 1 deletion src/classkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ interface CLSProgressReportingCapability {
string Details { get; }

[Export ("initWithKind:details:")]
IntPtr Constructor (CLSProgressReportingCapabilityKind kind, string details);
IntPtr Constructor (CLSProgressReportingCapabilityKind kind, [NullAllowed] string details);
}

}
4 changes: 2 additions & 2 deletions src/coreimage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ interface CIContext {

[iOS (9,0)][Mac (10,11)]
[Export ("render:toMTLTexture:commandBuffer:bounds:colorSpace:")]
void Render (CIImage image, IMTLTexture texture, [NullAllowed] IMTLCommandBuffer commandBuffer, CGRect bounds, [NullAllowed] CGColorSpace colorSpace);
void Render (CIImage image, IMTLTexture texture, [NullAllowed] IMTLCommandBuffer commandBuffer, CGRect bounds, CGColorSpace colorSpace);

[Deprecated (PlatformName.iOS, 6, 0, message : "Use 'DrawImage (image, CGRect, CGRect)' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 8, message : "Use 'DrawImage (image, CGRect, CGRect)' instead.")]
Expand Down Expand Up @@ -5618,7 +5618,7 @@ interface CIRenderDestination {
IntPtr Constructor (IMTLTexture texture, [NullAllowed] IMTLCommandBuffer commandBuffer);

[Export ("initWithWidth:height:pixelFormat:commandBuffer:mtlTextureProvider:")]
IntPtr Constructor (nuint width, nuint height, MTLPixelFormat pixelFormat, [NullAllowed] IMTLCommandBuffer commandBuffer, Func<IMTLTexture> block);
IntPtr Constructor (nuint width, nuint height, MTLPixelFormat pixelFormat, [NullAllowed] IMTLCommandBuffer commandBuffer, [NullAllowed] Func<IMTLTexture> block);

[Export ("initWithGLTexture:target:width:height:")]
IntPtr Constructor (uint texture, uint target, nuint width, nuint height);
Expand Down
2 changes: 1 addition & 1 deletion src/coreml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ interface MLMultiArray : NSSecureCoding {
IntPtr Constructor (NSNumber [] shape, MLMultiArrayDataType dataType, out NSError error);

[Export ("initWithDataPointer:shape:dataType:strides:deallocator:error:")]
IntPtr Constructor (IntPtr dataPointer, NSNumber [] shape, MLMultiArrayDataType dataType, NSNumber [] strides, Action<IntPtr> deallocator, out NSError error);
IntPtr Constructor (IntPtr dataPointer, NSNumber [] shape, MLMultiArrayDataType dataType, NSNumber [] strides, [NullAllowed] Action<IntPtr> deallocator, out NSError error);

// From MLMultiArray (NSNumberDataAccess) Category

Expand Down
2 changes: 1 addition & 1 deletion src/corewlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ interface CWInterface {

[Deprecated (PlatformName.MacOSX, 11,0)]
[Export ("startIBSSModeWithSSID:security:channel:password:error:")]
bool StartIbssModeWithSsid (NSData ssidData, CWIbssModeSecurity security, nuint channel, string password, out NSError error);
bool StartIbssModeWithSsid (NSData ssidData, CWIbssModeSecurity security, nuint channel, [NullAllowed] string password, out NSError error);

[Export ("disassociate")]
void Disassociate ();
Expand Down
36 changes: 18 additions & 18 deletions src/foundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ interface NSCalendarDate {

[Export ("initWithYear:month:day:hour:minute:second:timeZone:")]
[Availability (Deprecated = Platform.Mac_10_10)]
IntPtr Constructor (nint year, nuint month, nuint day, nuint hour, nuint minute, nuint second, NSTimeZone aTimeZone);
IntPtr Constructor (nint year, nuint month, nuint day, nuint hour, nuint minute, nuint second, [NullAllowed] NSTimeZone aTimeZone);

[Availability (Deprecated = Platform.Mac_10_10)]
[Export ("dateByAddingYears:months:days:hours:minutes:seconds:")]
Expand Down Expand Up @@ -1487,7 +1487,7 @@ interface NSData : NSSecureCoding, NSMutableCopying, CKRecordValue {

[iOS (7,0), Mac (10, 9)]
[Export ("initWithBytesNoCopy:length:deallocator:")]
IntPtr Constructor (IntPtr bytes, nuint length, Action<IntPtr,nuint> deallocator);
IntPtr Constructor (IntPtr bytes, nuint length, [NullAllowed] Action<IntPtr,nuint> deallocator);

// NSDataCompression (NSData)

Expand Down Expand Up @@ -1761,7 +1761,7 @@ interface NSDateFormatter {

[Export ("dateFormatFromTemplate:options:locale:")]
[Static]
string GetDateFormatFromTemplate (string template, nuint options, NSLocale locale);
string GetDateFormatFromTemplate (string template, nuint options, [NullAllowed] NSLocale locale);

[Export ("doesRelativeDateFormatting")]
bool DoesRelativeDateFormatting { get; set; }
Expand Down Expand Up @@ -4993,7 +4993,7 @@ interface NSSortDescriptor : NSSecureCoding, NSCopying {
IntPtr Constructor (string key, bool ascending);

[Export ("initWithKey:ascending:selector:")]
IntPtr Constructor (string key, bool ascending, Selector selector);
IntPtr Constructor (string key, bool ascending, [NullAllowed] Selector selector);

[Export ("initWithKey:ascending:comparator:")]
IntPtr Constructor (string key, bool ascending, NSComparator comparator);
Expand Down Expand Up @@ -5166,7 +5166,7 @@ interface NSTimeZone : NSSecureCoding, NSCopying {
string DataVersion { get; }

[Export ("localizedName:locale:")]
string GetLocalizedName (NSTimeZoneNameStyle style, NSLocale locale);
string GetLocalizedName (NSTimeZoneNameStyle style, [NullAllowed] NSLocale locale);
}

interface NSUbiquitousKeyValueStoreChangeEventArgs {
Expand Down Expand Up @@ -5754,10 +5754,10 @@ partial interface NSUrl : NSSecureCoding, NSCopying
[DesignatedInitializer]
[iOS (7,0), Mac (10, 9)]
[Export ("initFileURLWithFileSystemRepresentation:isDirectory:relativeToURL:")]
IntPtr Constructor (IntPtr ptrUtf8path, bool isDir, NSUrl baseURL);
IntPtr Constructor (IntPtr ptrUtf8path, bool isDir, [NullAllowed] NSUrl baseURL);

[iOS (7,0), Mac (10, 9), Static, Export ("fileURLWithFileSystemRepresentation:isDirectory:relativeToURL:")]
NSUrl FromUTF8Pointer (IntPtr ptrUtf8path, bool isDir, NSUrl baseURL);
NSUrl FromUTF8Pointer (IntPtr ptrUtf8path, bool isDir, [NullAllowed] NSUrl baseURL);

#if MONOMAC

Expand Down Expand Up @@ -6397,7 +6397,7 @@ interface NSUrlCache {
[Deprecated (PlatformName.WatchOS, 6,0, message : "Use the overload that accepts an 'NSUrl' parameter instead.")]
[Deprecated (PlatformName.TvOS, 13,0, message : "Use the overload that accepts an 'NSUrl' parameter instead.")]
[Export ("initWithMemoryCapacity:diskCapacity:diskPath:")]
IntPtr Constructor (nuint memoryCapacity, nuint diskCapacity, string diskPath);
IntPtr Constructor (nuint memoryCapacity, nuint diskCapacity, [NullAllowed] string diskPath);

[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
[Export ("initWithMemoryCapacity:diskCapacity:directoryURL:")]
Expand Down Expand Up @@ -6573,7 +6573,7 @@ partial interface NSUrlComponents : NSCopying {
[DisableDefaultCtor]
interface NSUrlAuthenticationChallenge : NSSecureCoding {
[Export ("initWithProtectionSpace:proposedCredential:previousFailureCount:failureResponse:error:sender:")]
IntPtr Constructor (NSUrlProtectionSpace space, NSUrlCredential credential, nint previousFailureCount, NSUrlResponse response, [NullAllowed] NSError error, NSUrlConnection sender);
IntPtr Constructor (NSUrlProtectionSpace space, NSUrlCredential credential, nint previousFailureCount, [NullAllowed] NSUrlResponse response, [NullAllowed] NSError error, NSUrlConnection sender);

[Export ("initWithAuthenticationChallenge:sender:")]
IntPtr Constructor (NSUrlAuthenticationChallenge challenge, NSUrlConnection sender);
Expand Down Expand Up @@ -8823,7 +8823,7 @@ interface NSObject2 : NSObjectProtocol {
void PerformSelector (Selector selector, NSThread onThread, [NullAllowed] NSObject withObject, bool waitUntilDone);

[Export ("performSelector:onThread:withObject:waitUntilDone:modes:")]
void PerformSelector (Selector selector, NSThread onThread, [NullAllowed] NSObject withObject, bool waitUntilDone, NSString [] nsRunLoopModes);
void PerformSelector (Selector selector, NSThread onThread, [NullAllowed] NSObject withObject, bool waitUntilDone, [NullAllowed] NSString [] nsRunLoopModes);

[Static, Export ("cancelPreviousPerformRequestsWithTarget:")]
void CancelPreviousPerformRequest (NSObject aTarget);
Expand Down Expand Up @@ -9606,7 +9606,7 @@ interface NSHttpUrlResponse {
IntPtr Constructor (NSUrl url, string mimetype, nint expectedContentLength, [NullAllowed] string textEncodingName);

[Export ("initWithURL:statusCode:HTTPVersion:headerFields:")]
IntPtr Constructor (NSUrl url, nint statusCode, string httpVersion, NSDictionary headerFields);
IntPtr Constructor (NSUrl url, nint statusCode, [NullAllowed] string httpVersion, [NullAllowed] NSDictionary headerFields);

[Export ("statusCode")]
nint StatusCode { get; }
Expand Down Expand Up @@ -10709,12 +10709,12 @@ interface NSNotificationQueue {

[Export ("enqueueNotification:postingStyle:coalesceMask:forModes:")]
#if !XAMCORE_4_0
void EnqueueNotification (NSNotification notification, NSPostingStyle postingStyle, NSNotificationCoalescing coalesceMask, string [] modes);
void EnqueueNotification (NSNotification notification, NSPostingStyle postingStyle, NSNotificationCoalescing coalesceMask, [NullAllowed] string [] modes);
#else
void EnqueueNotification (NSNotification notification, NSPostingStyle postingStyle, NSNotificationCoalescing coalesceMask, NSString [] modes);
void EnqueueNotification (NSNotification notification, NSPostingStyle postingStyle, NSNotificationCoalescing coalesceMask, [NullAllowed] NSString [] modes);

[Wrap ("EnqueueNotification (notification, postingStyle, coalesceMask, modes.GetConstants ())")]
void EnqueueNotification (NSNotification notification, NSPostingStyle postingStyle, NSNotificationCoalescing coalesceMask, NSRunLoopMode [] modes);
[Wrap ("EnqueueNotification (notification, postingStyle, coalesceMask, modes?.GetConstants ())")]
void EnqueueNotification (NSNotification notification, NSPostingStyle postingStyle, NSNotificationCoalescing coalesceMask, [NullAllowed] NSRunLoopMode [] modes);
#endif

[Export ("dequeueNotificationsMatching:coalesceMask:")]
Expand Down Expand Up @@ -11496,13 +11496,13 @@ interface NSDecimalNumber : NSSecureCoding {
NSDecimalNumber RaiseTo (nuint power);

[Export ("decimalNumberByRaisingToPower:withBehavior:")]
NSDecimalNumber RaiseTo (nuint power, NSObject Behavior);
NSDecimalNumber RaiseTo (nuint power, [NullAllowed] NSObject Behavior);

[Export ("decimalNumberByMultiplyingByPowerOf10:")]
NSDecimalNumber MultiplyPowerOf10 (short power);

[Export ("decimalNumberByMultiplyingByPowerOf10:withBehavior:")]
NSDecimalNumber MultiplyPowerOf10 (short power, NSObject Behavior);
NSDecimalNumber MultiplyPowerOf10 (short power, [NullAllowed] NSObject Behavior);

[Export ("decimalNumberByRoundingAccordingToBehavior:")]
NSDecimalNumber Rounding (NSObject behavior);
Expand Down Expand Up @@ -12766,7 +12766,7 @@ interface NSFileWrapper : NSSecureCoding {
bool Read (NSUrl url, NSFileWrapperReadingOptions options, out NSError outError);

[Export ("writeToURL:options:originalContentsURL:error:")]
bool Write (NSUrl url, NSFileWrapperWritingOptions options, NSUrl originalContentsURL, out NSError outError);
bool Write (NSUrl url, NSFileWrapperWritingOptions options, [NullAllowed] NSUrl originalContentsURL, out NSError outError);

[Export ("serializedRepresentation")]
NSData GetSerializedRepresentation ();
Expand Down
4 changes: 2 additions & 2 deletions src/gamekit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,12 @@ interface GKLeaderboard {
[Watch (7, 0), TV (14, 0), Mac (11, 0), iOS (14, 0)]
[Async (ResultTypeName = "GKEntriesForPlayerScopeResult")]
[Export ("loadEntriesForPlayerScope:timeScope:range:completionHandler:")]
void LoadEntries (GKLeaderboardPlayerScope playerScope, GKLeaderboardTimeScope timeScope, NSRange range, [NullAllowed] GKEntriesForPlayerScopeHandler completionHandler);
void LoadEntries (GKLeaderboardPlayerScope playerScope, GKLeaderboardTimeScope timeScope, NSRange range, GKEntriesForPlayerScopeHandler completionHandler);

[Watch (7, 0), TV (14, 0), Mac (11, 0), iOS (14, 0)]
[Async (ResultTypeName = "GKEntriesForPlayersResult")]
[Export ("loadEntriesForPlayers:timeScope:completionHandler:")]
void LoadEntries (GKPlayer[] players, GKLeaderboardTimeScope timeScope, [NullAllowed] GKEntriesForPlayersHandler completionHandler);
void LoadEntries (GKPlayer[] players, GKLeaderboardTimeScope timeScope, GKEntriesForPlayersHandler completionHandler);

[Watch (7, 0), TV (14, 0), Mac (11, 0), iOS (14, 0)]
[Export ("loadPreviousOccurrenceWithCompletionHandler:")]
Expand Down
4 changes: 2 additions & 2 deletions src/mapkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ interface MKPolygon : MKOverlay, MKGeoJsonObject {
[Static]
[Internal]
[Export ("polygonWithPoints:count:interiorPolygons:")]
MKPolygon _FromPoints (IntPtr points, nint count, MKPolygon [] interiorPolygons);
MKPolygon _FromPoints (IntPtr points, nint count, [NullAllowed] MKPolygon [] interiorPolygons);

[Static]
[Export ("polygonWithCoordinates:count:"), Internal]
Expand All @@ -1077,7 +1077,7 @@ interface MKPolygon : MKOverlay, MKGeoJsonObject {
[Static]
[Internal]
[Export ("polygonWithCoordinates:count:interiorPolygons:")]
MKPolygon _FromCoordinates (IntPtr coords, nint count, MKPolygon [] interiorPolygons);
MKPolygon _FromCoordinates (IntPtr coords, nint count, [NullAllowed] MKPolygon [] interiorPolygons);

#region MKAnnotation
[Export ("coordinate")]
Expand Down
2 changes: 1 addition & 1 deletion src/messageui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface MFMailComposeViewController : UIAppearance {
[Protocol]
interface MFMailComposeViewControllerDelegate {
[Export ("mailComposeController:didFinishWithResult:error:")]
void Finished (MFMailComposeViewController controller, MFMailComposeResult result, NSError error);
void Finished (MFMailComposeViewController controller, MFMailComposeResult result, [NullAllowed] NSError error);
}

interface MFMessageAvailabilityChangedEventArgs {
Expand Down
2 changes: 1 addition & 1 deletion src/scenekit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4485,7 +4485,7 @@ interface SCNPhysicsHingeJoint {

[Static, Export ("jointWithBodyA:axisA:anchorA:bodyB:axisB:anchorB:")]
SCNPhysicsHingeJoint Create (SCNPhysicsBody bodyA, SCNVector3 axisA, SCNVector3 anchorA,
[NullAllowed] SCNPhysicsBody bodyB, SCNVector3 axisB, SCNVector3 anchorB);
SCNPhysicsBody bodyB, SCNVector3 axisB, SCNVector3 anchorB);

[Static, Export ("jointWithBody:axis:anchor:")]
SCNPhysicsHingeJoint Create (SCNPhysicsBody body, SCNVector3 axis, SCNVector3 anchor);
Expand Down
Loading

0 comments on commit d768431

Please sign in to comment.