Repository navigation
[corefoundation] Add nullability to (generated and manual) bindings - #15090
Conversation
| public bool Transform (ref CFRange range, string transform, bool reverse) | ||
| { | ||
| var t = NSString.CreateNative (transform); | ||
| var t = CreateNative (transform); |
There was a problem hiding this comment.
Context, NSString.CreateNative (...) is obsolete and the recommendation was to use CFString.CreateNative (...)
| public bool Transform (string transform, bool reverse) | ||
| { | ||
| var t = NSString.CreateNative (transform); | ||
| var t = CreateNative (transform); |
There was a problem hiding this comment.
Context, NSString.CreateNative (...) is obsolete and the recommendation was to use CFString.CreateNative (...)
There was a problem hiding this comment.
I love the fact that you are giving context in your changes, appreciate it.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| public IntPtr Handle { | ||
| get { return data.Handle; } | ||
| get { return data?.Handle ?? IntPtr.Zero; } |
There was a problem hiding this comment.
| get { return data?.Handle ?? IntPtr.Zero; } | |
| get { return data.GetHandle (); } |
There was a problem hiding this comment.
I tried to use GetHandle () here but it was not supported.. I'll double check why!
There was a problem hiding this comment.
Oop was just missing the namespace :)
| if (name is null) | ||
| throw new ArgumentNullException (nameof (name), "When using the Darwin Notification Center, the value passed must not be null"); | ||
| if (darwinnc is not null && darwinnc.Handle == Handle && name is null){ | ||
| ObjCRuntime.ThrowHelper.ThrowArgumentNullException ($"{nameof (name)}: When using the Darwin Notification Center, the value passed must not be null"); |
There was a problem hiding this comment.
I think you have to add another ThrowArgumentNullException overload that takes the message in addition to the parameter name.
There was a problem hiding this comment.
@rolfbjarne There is not one in the ObjCRuntime.ThrowHelper class, but I could easily create one!
There was a problem hiding this comment.
Yep, adding a new method is the way to go :)
| } | ||
|
|
||
| throw new ArgumentException ("unsupported type: " + value.GetType (), "value"); | ||
| if (value is not null) |
There was a problem hiding this comment.
This looks wrong, I think there's a missing return; statement after line 127, where it already handles the value is null case. Looks like the nullability attributes caught a bug here :)
There was a problem hiding this comment.
I believe you are correct.
| if (left as object is null) | ||
| return right as object is null; |
There was a problem hiding this comment.
You don't need the as object part:
| if (left as object is null) | |
| return right as object is null; | |
| if (left is null) | |
| return right is null; |
| if (left as object is null) | ||
| return right as object is not null; |
There was a problem hiding this comment.
| if (left as object is null) | |
| return right as object is not null; | |
| if (left is null) | |
| return right is not null; |
mandel-macaque
left a comment
There was a problem hiding this comment.
After all rolfs comments have been addressed.
| public bool Transform (string transform, bool reverse) | ||
| { | ||
| var t = NSString.CreateNative (transform); | ||
| var t = CreateNative (transform); |
There was a problem hiding this comment.
I love the fact that you are giving context in your changes, appreciate it.
| } | ||
|
|
||
| throw new ArgumentException ("unsupported type: " + value.GetType (), "value"); | ||
| if (value is not null) |
There was a problem hiding this comment.
I believe you are correct.
| string? username = proxy?.Username; | ||
| string? password = proxy?.Password; | ||
| string? hostname = proxy?.HostName; | ||
| int? port = proxy?.Port; |
There was a problem hiding this comment.
var here would have make you type less :)
|
@rolfbjarne Changes addressed! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| public NSString Domain {get; private set;} | ||
| public string FailureReason {get; private set;} | ||
| public string RecoverySuggestion {get; private set;} | ||
| public nint? Code {get; private set;} |
There was a problem hiding this comment.
You can't make this nullable, because it's a struct and that would be a breaking change.
| public class CFException : Exception { | ||
|
|
||
| public CFException (string description, NSString domain, nint code, string failureReason, string recoverySuggestion) | ||
| public CFException (string? description, NSString? domain, nint? code, string? failureReason, string? recoverySuggestion) |
There was a problem hiding this comment.
You can't make the code argument nullable, because it's a struct and it would be a breaking change.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@rolfbjarne Changes applied! |
💻 [PR Build] Tests on macOS Mac Catalina (10.15) passed 💻✅ All tests on macOS Mac Catalina (10.15) passed. Pipeline on Agent |
📋 [PR Build] API Diff 📋API diff (for current PR)ℹ️ API Diff (from PR only) (please review changes) .NETXamarin vs .NETAPI diff (vs stable)✅ API Diff from stable .NETXamarin vs .NETGenerator diff✅ Generator Diff (no change) Pipeline on Agent XAMBOT-1100.Monterey |
❌ [CI Build] Tests failed on VSTS: simulator tests iOS ❌Tests failed on VSTS: simulator tests iOS. Test results4 tests failed, 144 tests passed.Failed tests
Pipeline on Agent XAMBOT-1099.Monterey' |
| var username = proxy?.Username; | ||
| var password = proxy?.Password; | ||
| var hostname = proxy?.HostName; | ||
| var port = proxy?.Port; |
There was a problem hiding this comment.
I don't love the usage of var here where the right hand size doesn't make it obvious if Port is a int or a string for example, but I think it's fine enough.
|
Unrelated Test Failures: https://github.com/xamarin/maccore/issues/2558 |
This PR aims to bring nullability changes to CoreFoundation.
Following the steps here:
nullable enableto all manual files that are not "API_SOURCES" in src/frameworks.sources and making the required nullability changesthrow new ArgumentNullException ("object"));toObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (object));for size saving optimization as well to mark that this framework contains nullability changes== nullor!= nulltois nullandis not null