Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/Vision/VNBarcodeSymbologyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,28 @@
// Copyright 2017 Xamarin Inc. All rights reserved.
//

#nullable enable

using System;
using Foundation;

namespace Vision {
public static partial class VNBarcodeSymbologyExtensions {
public static NSString [] GetConstants (this VNBarcodeSymbology [] self)
{
if (self == null)
throw new ArgumentNullException (nameof (self));
if (self is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (self));

var array = new NSString [self.Length];
for (int n = 0; n < self.Length; n++)
array [n] = self [n].GetConstant ();
array [n] = self [n].GetConstant ()!;
return array;
}

public static VNBarcodeSymbology [] GetValues (NSString [] constants)
public static VNBarcodeSymbology [] GetValues (NSString []? constants)
{
if (constants == null)
throw new ArgumentNullException (nameof (constants));
if (constants is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (constants));

var array = new VNBarcodeSymbology [constants.Length];
for (int n = 0; n < constants.Length; n++)
Expand Down
6 changes: 4 additions & 2 deletions src/Vision/VNCircle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
// Copyright (c) Microsoft Corporation.
//

#nullable enable

using System;
using Foundation;
using ObjCRuntime;

namespace Vision {
public partial class VNCircle {

public static VNCircle CreateUsingRadius (VNPoint center, double radius)
public static VNCircle? CreateUsingRadius (VNPoint center, double radius)
{
var handle = Messaging.IntPtr_objc_msgSend (class_ptr, Selector.GetHandle ("alloc"));
#if NET
Expand All @@ -25,7 +27,7 @@ public static VNCircle CreateUsingRadius (VNPoint center, double radius)
return Runtime.GetNSObject<VNCircle> (handle, true);
}

public static VNCircle CreateUsingDiameter (VNPoint center, double diameter)
public static VNCircle? CreateUsingDiameter (VNPoint center, double diameter)
{
var handle = Messaging.IntPtr_objc_msgSend (class_ptr, Selector.GetHandle ("alloc"));
#if NET
Expand Down
4 changes: 3 additions & 1 deletion src/Vision/VNCompat.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

#if !NET

using System;
Expand All @@ -7,7 +9,7 @@ namespace Vision {
public partial class VNRequest {

[Obsolete ("Empty stub (not a public API).")]
public virtual IMTLDevice PreferredMetalContext { get; set; }
public virtual IMTLDevice? PreferredMetalContext { get; set; }
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Vision/VNDetectBarcodesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// Copyright 2017 Xamarin Inc. All rights reserved.
//

#nullable enable

using System;

namespace Vision {
Expand Down
6 changes: 4 additions & 2 deletions src/Vision/VNFaceLandmarkRegion2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
// Copyright 2017 Xamarin Inc. All rights reserved.
//

#nullable enable

using System;
using CoreGraphics;

namespace Vision {
public partial class VNFaceLandmarkRegion2D {

public virtual CGPoint [] NormalizedPoints {
public virtual CGPoint []? NormalizedPoints {
get {
var ret = _GetNormalizedPoints ();
if (ret == IntPtr.Zero)
Expand All @@ -30,7 +32,7 @@ public virtual CGPoint [] NormalizedPoints {
}
}

public virtual CGPoint [] GetPointsInImage (CGSize imageSize)
public virtual CGPoint []? GetPointsInImage (CGSize imageSize)
{
// return the address of the array of pointCount points
// or NULL if the conversion could not take place.
Expand Down
4 changes: 3 additions & 1 deletion src/Vision/VNFeaturePrintObservation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
// Copyright 2019 Microsoft Corporation. All rights reserved.
//

#nullable enable

using System;
using Foundation;
using ObjCRuntime;

namespace Vision {
public partial class VNFeaturePrintObservation {

public bool ComputeDistance (out float [] distance, VNFeaturePrintObservation featurePrint, out NSError error)
public bool ComputeDistance (out float [] distance, VNFeaturePrintObservation featurePrint, out NSError? error)
{
distance = new float [ElementCount];
unsafe {
Expand Down
10 changes: 6 additions & 4 deletions src/Vision/VNRecognizedPointsObservation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@
// Copyright (c) Microsoft Corporation.
//

#nullable enable

using System;
using Foundation;
using ObjCRuntime;

namespace Vision {
public partial class VNRecognizedPointsObservation {

public T [] GetAvailableKeys<T> () where T : Enum
public T []? GetAvailableKeys<T> () where T : Enum
{
var type = typeof (T);
if (!(type == typeof (VNHumanBodyPoseObservationJointName) || type == typeof (VNHumanHandPoseObservationJointName)))
throw new InvalidOperationException ($"Only '{nameof (VNHumanBodyPoseObservationJointName)}' and '{nameof (VNHumanHandPoseObservationJointName)}' are supported.");

NSString[] keys = AvailableKeys;
if (keys == null)
if (keys is null)
return null;

if (keys.Length == 0)
Expand All @@ -34,14 +36,14 @@ public T [] GetAvailableKeys<T> () where T : Enum
return null;
}

public T [] GetAvailableGroupKeys<T> () where T : Enum
public T []? GetAvailableGroupKeys<T> () where T : Enum
{
var type = typeof (T);
if (!(type == typeof (VNHumanBodyPoseObservationJointsGroupName) || type == typeof (VNHumanHandPoseObservationJointsGroupName)))
throw new InvalidOperationException ($"Only '{nameof (VNHumanBodyPoseObservationJointsGroupName)}' and '{nameof (VNHumanHandPoseObservationJointsGroupName)}' are supported.");

NSString[] keys = AvailableGroupKeys;
if (keys == null)
if (keys is null)
return null;

if (keys.Length == 0)
Expand Down
2 changes: 2 additions & 0 deletions src/Vision/VNRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// Copyright 2017 Xamarin Inc. All rights reserved.
//

#nullable enable

using System;
using Foundation;
using ObjCRuntime;
Expand Down
6 changes: 4 additions & 2 deletions src/Vision/VNRequestRevision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
// Copyright 2018 Microsoft Corporation.
//

#nullable enable

using System;
using Foundation;
using ObjCRuntime;

namespace Vision {
public partial class VNRequest {

internal static T [] GetSupportedVersions<T> (NSIndexSet indexSet) where T : Enum
internal static T []? GetSupportedVersions<T> (NSIndexSet indexSet) where T : Enum
{
if (indexSet == null)
if (indexSet is null)
return null;

var count = indexSet.Count;
Expand Down
8 changes: 5 additions & 3 deletions src/Vision/VNUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// Copyright 2017 Xamarin Inc. All rights reserved.
//

#nullable enable

using System;
using System.Runtime.InteropServices;
using CoreGraphics;
Expand Down Expand Up @@ -175,10 +177,10 @@ public static CGPoint GetImagePoint (Vector2 faceLandmarkPoint, CGRect faceBound

public partial class VNGeometryUtils {

public static VNCircle CreateBoundingCircle (Vector2 [] points, out NSError error)
public static VNCircle? CreateBoundingCircle (Vector2 [] points, out NSError error)
{
if (points == null)
throw new ArgumentNullException (nameof (points));
if (points is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (points));
if (points.Length == 0)
throw new ArgumentException ($"'{nameof (points)}' array must have more than zero elements.");

Expand Down
4 changes: 3 additions & 1 deletion src/Vision/VNVector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
// Copyright (c) Microsoft Corporation.
//

#nullable enable

using System;
using Foundation;
using ObjCRuntime;

namespace Vision {
public partial class VNVector {

public static VNVector Create (double r, double theta)
public static VNVector? Create (double r, double theta)
{
var handle = Messaging.IntPtr_objc_msgSend (class_ptr, Selector.GetHandle ("alloc"));
handle = Messaging.IntPtr_objc_msgSend_Double_Double (handle, Selector.GetHandle ("initWithR:theta:"), r, theta);
Expand Down