[webkit] Add nullability to (generated and manual) bindings (#15028)
* Adding nullable enable * throw better exceptions * use is null * fix messages on throw exceptions * throw ObjectDisposedException * throw another ObjectDisposedException Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
This commit is contained in:
Родитель
a1e53d6d0d
Коммит
893cd77503
|
@ -1,3 +1,5 @@
|
|||
#nullable enable
|
||||
|
||||
namespace WebKit {
|
||||
|
||||
public partial class DomCssRuleList {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#nullable enable
|
||||
|
||||
using System;
|
||||
using ObjCRuntime;
|
||||
using Foundation;
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
|
@ -77,8 +79,8 @@ namespace WebKit {
|
|||
public DomEventListener AddEventListener (string type, DomEventListenerHandler handler, bool useCapture)
|
||||
#endif
|
||||
{
|
||||
if (handler == null)
|
||||
throw new ArgumentNullException ("handler");
|
||||
if (handler is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (handler));
|
||||
var obj = new DomNodeEventProxy (this, handler);
|
||||
AddEventListener (type, obj, useCapture);
|
||||
return obj;
|
||||
|
@ -90,8 +92,8 @@ namespace WebKit {
|
|||
public DomEventListener AddEventListener (string type, Action<DomEvent> callback, bool useCapture)
|
||||
#endif
|
||||
{
|
||||
if (callback == null)
|
||||
throw new ArgumentNullException ("callback");
|
||||
if (callback is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (callback));
|
||||
var obj = new DomNodeEventProxy2 (callback);
|
||||
AddEventListener (type, obj, useCapture);
|
||||
return obj;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
@ -24,15 +26,19 @@ namespace WebKit {
|
|||
|
||||
public T Current {
|
||||
get {
|
||||
if (_container is null)
|
||||
throw new ObjectDisposedException (nameof (_container));
|
||||
return _container [_index];
|
||||
}
|
||||
}
|
||||
|
||||
object IEnumerator.Current {
|
||||
object? IEnumerator.Current {
|
||||
get { return ((IEnumerator<T>) this).Current; }
|
||||
}
|
||||
|
||||
public bool MoveNext () {
|
||||
if (_container is null)
|
||||
throw new ObjectDisposedException (nameof (_container));
|
||||
return ++_index < _container.Count;
|
||||
}
|
||||
|
||||
|
@ -40,7 +46,7 @@ namespace WebKit {
|
|||
_index = -1;
|
||||
}
|
||||
|
||||
IIndexedContainer<T> _container;
|
||||
IIndexedContainer<T>? _container;
|
||||
int _index;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#nullable enable
|
||||
|
||||
namespace WebKit {
|
||||
|
||||
public partial class DomCssRuleList {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#nullable enable
|
||||
|
||||
using Foundation;
|
||||
|
||||
namespace WebKit {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
//
|
||||
// Copyright 2013 Xamarin Inc
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
using Foundation;
|
||||
|
@ -27,14 +29,14 @@ namespace WebKit {
|
|||
get { return (WebNavigationType)((NSNumber)ActionInformation[WebPolicyDelegate.WebActionNavigationTypeKey]).Int32Value; }
|
||||
}
|
||||
|
||||
public NSDictionary ElementInfo {
|
||||
public NSDictionary? ElementInfo {
|
||||
get { return ActionInformation[WebPolicyDelegate.WebActionElementKey] as NSDictionary; }
|
||||
}
|
||||
|
||||
public WebActionMouseButton MouseButton {
|
||||
get {
|
||||
var number = ActionInformation[WebPolicyDelegate.WebActionButtonKey] as NSNumber;
|
||||
if (number == null) {
|
||||
if (number is null) {
|
||||
return WebActionMouseButton.None;
|
||||
}
|
||||
|
||||
|
@ -46,7 +48,7 @@ namespace WebKit {
|
|||
get { return ((NSNumber)ActionInformation[WebPolicyDelegate.WebActionModifierFlagsKey]).UInt32Value; }
|
||||
}
|
||||
|
||||
public NSUrl OriginalUrl {
|
||||
public NSUrl? OriginalUrl {
|
||||
get { return ActionInformation[WebPolicyDelegate.WebActionOriginalUrlKey] as NSUrl; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using Foundation;
|
||||
using ObjCRuntime;
|
||||
|
@ -33,24 +36,24 @@ namespace WebKit {
|
|||
|
||||
public static void DecideUse (NSObject decisionToken)
|
||||
{
|
||||
if (decisionToken == null)
|
||||
throw new ArgumentNullException ("token");
|
||||
if (decisionToken is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (decisionToken));
|
||||
|
||||
ObjCRuntime.Messaging.void_objc_msgSend (decisionToken.Handle, selUse);
|
||||
}
|
||||
|
||||
public static void DecideDownload (NSObject decisionToken)
|
||||
{
|
||||
if (decisionToken == null)
|
||||
throw new ArgumentNullException ("decisionToken");
|
||||
if (decisionToken is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (decisionToken));
|
||||
|
||||
ObjCRuntime.Messaging.void_objc_msgSend (decisionToken.Handle, selDownload);
|
||||
}
|
||||
|
||||
public static void DecideIgnore (NSObject decisionToken)
|
||||
{
|
||||
if (decisionToken == null)
|
||||
throw new ArgumentNullException ("decisionToken");
|
||||
if (decisionToken is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (decisionToken));
|
||||
|
||||
ObjCRuntime.Messaging.void_objc_msgSend (decisionToken.Handle, selIgnore);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using Foundation;
|
||||
using ObjCRuntime;
|
||||
|
@ -33,24 +36,24 @@ namespace WebKit {
|
|||
|
||||
public static void DecideUse (NSObject decisionToken)
|
||||
{
|
||||
if (decisionToken == null)
|
||||
throw new ArgumentNullException ("token");
|
||||
if (decisionToken is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (decisionToken));
|
||||
|
||||
ObjCRuntime.Messaging.void_objc_msgSend (decisionToken.Handle, selUse);
|
||||
}
|
||||
|
||||
public static void DecideDownload (NSObject decisionToken)
|
||||
{
|
||||
if (decisionToken == null)
|
||||
throw new ArgumentNullException ("decisionToken");
|
||||
if (decisionToken is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (decisionToken));
|
||||
|
||||
ObjCRuntime.Messaging.void_objc_msgSend (decisionToken.Handle, selDownload);
|
||||
}
|
||||
|
||||
public static void DecideIgnore (NSObject decisionToken)
|
||||
{
|
||||
if (decisionToken == null)
|
||||
throw new ArgumentNullException ("decisionToken");
|
||||
if (decisionToken is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (decisionToken));
|
||||
|
||||
ObjCRuntime.Messaging.void_objc_msgSend (decisionToken.Handle, selIgnore);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче