[webkit] Add nullability to (generated and manual) bindings - #15028
Conversation
| get { | ||
| return _container [_index]; | ||
| return _container! [_index]; | ||
| } |
There was a problem hiding this comment.
Highlighting this !. The return type cannot be made nullable since it is implementing an interface with that method signature but it is also a getter that is not an indexer so I thought this may be the best option
There was a problem hiding this comment.
what about using:
if (_container is null) {
return default (T);
} else {
return _container [_index]
}There was a problem hiding this comment.
Might make more sense to throw an ObjectDisposedException.
There was a problem hiding this comment.
@rolfbjarne good one, that exception should also be a good idea for my other comment.
| } | ||
|
|
||
| IIndexedContainer<T> _container; | ||
| IIndexedContainer<T>? _container; |
There was a problem hiding this comment.
Why is this needed, if the only constructor takes a non-nullable container value and assigns it to this field?
There was a problem hiding this comment.
@rolfbjarne I added this, because the Dispose method assigns null to _container
There was a problem hiding this comment.
@rolfbjarne we need a way to init that. The compiler is complaining because the default value of a IIndexedContainer is null. We could probably make the _container a private Init property with the type and remove the need of ? and remove all the Dipose code. Should make things nicer.
There was a problem hiding this comment.
@rolfbjarne @mandel-macaque Should I do this?
There was a problem hiding this comment.
@tj-devel709 yes, keep this since nulling it the field in the Dispose method might be important
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.
| get { | ||
| return _container [_index]; | ||
| return _container! [_index]; | ||
| } |
There was a problem hiding this comment.
what about using:
if (_container is null) {
return default (T);
} else {
return _container [_index]
}| if (_container is null) | ||
| return false; |
There was a problem hiding this comment.
This is not correct. MoveNext can throw and throws and exception, please read https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerator.movenext?view=net-6.0
Returning false has a meaning:
true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
That means that you are telling the user of the API that everything was ok and that you reached the end, that is not the case. We should throw an InvalidOperationException.
There was a problem hiding this comment.
_container can only be null if the object has been disposed, so an ObjectDisposedException sounds natural
| } | ||
|
|
||
| IIndexedContainer<T> _container; | ||
| IIndexedContainer<T>? _container; |
There was a problem hiding this comment.
@rolfbjarne we need a way to init that. The compiler is complaining because the default value of a IIndexedContainer is null. We could probably make the _container a private Init property with the type and remove the need of ? and remove all the Dipose code. Should make things nicer.
| get { | ||
| return _container [_index]; | ||
| return _container! [_index]; | ||
| } |
There was a problem hiding this comment.
Might make more sense to throw an ObjectDisposedException.
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.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
â API diff for current PR / commitLegacy Xamarin (No breaking changes).NET (No breaking changes)â API diff vs stable (Breaking changes)Legacy Xamarin (No breaking changes).NET (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
âđïļ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
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.
|
ðĨ Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire Pipeline on Agent |
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.
â API diff for current PR / commitLegacy Xamarin (No breaking changes)
NET (empty diffs)
â API diff vs stableLegacy Xamarin (No breaking changes).NET (No breaking changes)â Generator diffGenerator diff is empty Pipeline on Agent |
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.
ðŧ [PR Build] Tests on macOS Mac Catalina (10.15) passed ðŧâ All tests on macOS Mac Catalina (10.15) passed. Pipeline on Agent |
â API diff for current PR / commitLegacy Xamarin (No breaking changes)
NET (empty diffs)
â API diff vs stableLegacy Xamarin (No breaking changes).NET (No breaking changes)â Generator diffGenerator diff is empty Pipeline on Agent |
ðŧ [PR 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 |
â [CI Build] Tests failed on VSTS: simulator tests iOS âTests failed on VSTS: simulator tests iOS. Test results1 tests failed, 147 tests passed.Failed tests
Pipeline on Agent XAMBOT-1044.Monterey' |
|
Unrelated Test Failure: https://github.com/xamarin/maccore/issues/2558 |
This PR aims to bring nullability changes to WebKit.
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