diff --git a/src/WebKit/DomCssRuleList.cs b/src/WebKit/DomCssRuleList.cs index 1019bf8ab5ef..adc06211e36c 100644 --- a/src/WebKit/DomCssRuleList.cs +++ b/src/WebKit/DomCssRuleList.cs @@ -1,3 +1,5 @@ +#nullable enable + namespace WebKit { public partial class DomCssRuleList { diff --git a/src/WebKit/DomHelpers.cs b/src/WebKit/DomHelpers.cs index ead1b62e27b2..cbfea7c810d2 100644 --- a/src/WebKit/DomHelpers.cs +++ b/src/WebKit/DomHelpers.cs @@ -1,3 +1,5 @@ +#nullable enable + using System; using ObjCRuntime; using Foundation; diff --git a/src/WebKit/DomNode.cs b/src/WebKit/DomNode.cs index 3ea8d94f86e8..fd4122757598 100644 --- a/src/WebKit/DomNode.cs +++ b/src/WebKit/DomNode.cs @@ -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 @@ public IDomEventListener AddEventListener (string type, DomEventListenerHandler 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 @@ public IDomEventListener AddEventListener (string type, Action callbac public DomEventListener AddEventListener (string type, Action 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; diff --git a/src/WebKit/Enumerators.cs b/src/WebKit/Enumerators.cs index 144586be2875..88b99218c091 100644 --- a/src/WebKit/Enumerators.cs +++ b/src/WebKit/Enumerators.cs @@ -1,3 +1,5 @@ +#nullable enable + using System; using System.Collections; using System.Collections.Generic; @@ -24,15 +26,19 @@ public void Dispose () { 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) this).Current; } } public bool MoveNext () { + if (_container is null) + throw new ObjectDisposedException (nameof (_container)); return ++_index < _container.Count; } @@ -40,7 +46,7 @@ public void Reset () { _index = -1; } - IIndexedContainer _container; + IIndexedContainer? _container; int _index; } diff --git a/src/WebKit/Indexers.cs b/src/WebKit/Indexers.cs index a6d935ecc2f9..2e9f038015e4 100644 --- a/src/WebKit/Indexers.cs +++ b/src/WebKit/Indexers.cs @@ -1,3 +1,5 @@ +#nullable enable + namespace WebKit { public partial class DomCssRuleList { diff --git a/src/WebKit/WebKit.cs b/src/WebKit/WebKit.cs index bdba3eed9467..3ddcce6e4854 100644 --- a/src/WebKit/WebKit.cs +++ b/src/WebKit/WebKit.cs @@ -1,3 +1,5 @@ +#nullable enable + using Foundation; namespace WebKit { diff --git a/src/WebKit/WebNavigationPolicyEventArgs.cs b/src/WebKit/WebNavigationPolicyEventArgs.cs index f413d5044c58..21a4bd4b9bcf 100644 --- a/src/WebKit/WebNavigationPolicyEventArgs.cs +++ b/src/WebKit/WebNavigationPolicyEventArgs.cs @@ -6,6 +6,8 @@ // // Copyright 2013 Xamarin Inc +#nullable enable + using System; using Foundation; @@ -27,14 +29,14 @@ public WebNavigationType NavigationType { 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 @@ public uint Flags { get { return ((NSNumber)ActionInformation[WebPolicyDelegate.WebActionModifierFlagsKey]).UInt32Value; } } - public NSUrl OriginalUrl { + public NSUrl? OriginalUrl { get { return ActionInformation[WebPolicyDelegate.WebActionOriginalUrlKey] as NSUrl; } } } diff --git a/src/WebKit/WebPolicyDelegate.cs b/src/WebKit/WebPolicyDelegate.cs index d97e8e7c8b21..4058862bf534 100644 --- a/src/WebKit/WebPolicyDelegate.cs +++ b/src/WebKit/WebPolicyDelegate.cs @@ -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 @@ public partial class WebPolicyDelegate { 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); } diff --git a/src/WebKit/WebView.cs b/src/WebKit/WebView.cs index c388ba8d9e97..303c8147d156 100644 --- a/src/WebKit/WebView.cs +++ b/src/WebKit/WebView.cs @@ -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 @@ public partial class WebView { 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); }