From b2cc6d9c2ee7dd2f82b6aa7cb6396e3bb904a28f Mon Sep 17 00:00:00 2001 From: TJ Lambert <50846373+tj-devel709@users.noreply.github.com> Date: Wed, 23 Feb 2022 11:29:58 -0600 Subject: [PATCH] [assetslibrary] Add nullability to (generated and manual) bindings (#14222) Co-authored-by: TJ Lambert --- src/AssetsLibrary/ALAsset.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/AssetsLibrary/ALAsset.cs b/src/AssetsLibrary/ALAsset.cs index 5e6794d69216..7a0a8344d347 100644 --- a/src/AssetsLibrary/ALAsset.cs +++ b/src/AssetsLibrary/ALAsset.cs @@ -47,7 +47,7 @@ public double Duration { // note: this can return an NSString like: ALErrorInvalidProperty // which causes an InvalidCastException with a normal cast var n = ValueForProperty (_PropertyDuration) as NSNumber; - return n == null ? double.NaN : n.DoubleValue; + return n?.DoubleValue ?? double.NaN; } } @@ -81,9 +81,7 @@ public NSUrl? AssetUrl { get { // do not show an ArgumentNullException inside the // debugger for releases before 6.0 - if (_PropertyAssetURL == null) - return null; - return (NSUrl) ValueForProperty (_PropertyAssetURL); + return _PropertyAssetURL is not null ? (NSUrl) ValueForProperty (_PropertyAssetURL) : null; } } }