From daf7776c96624e1da14425a721d697c3284d5f8f Mon Sep 17 00:00:00 2001 From: Anshul David <43073266+anshuldavid13@users.noreply.github.com> Date: Wed, 22 Jun 2022 15:48:04 +0000 Subject: [PATCH] Null check for adding operators (#8791) * WIP * Updating test cases * Adding null check for collection * Review comments * Review comments implemented * Removing redundant ref --- .../Google.Cloud.Datastore.V1/FilterPartial.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1/FilterPartial.cs b/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1/FilterPartial.cs index 006b79b54c6b..89f1d0495b84 100644 --- a/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1/FilterPartial.cs +++ b/apis/Google.Cloud.Datastore.V1/Google.Cloud.Datastore.V1/FilterPartial.cs @@ -76,19 +76,25 @@ public static Filter And(IEnumerable filters) /// Creates a filter to check that the specified property is in a given array of values. /// /// The name of the property. Must not be null. - /// The array of values to compare against. + /// The array of values to compare against. Must not be null. /// The newly created filter. - public static Filter In(string value, ArrayValue collection) => - Property(value, collection, Operator.In); + public static Filter In(string value, ArrayValue collection) + { + GaxPreconditions.CheckNotNull(collection, nameof(collection)); + return Property(value, collection, Operator.In); + } /// /// Creates a filter to check that the specified property is not in a given array of values. /// /// The name of the property. Must not be null. - /// The array of values to compare against. + /// The array of values to compare against. Must not be null. /// The newly created filter. - public static Filter NotIn(string value, ArrayValue collection) => - Property(value, collection, Operator.NotIn); + public static Filter NotIn(string value, ArrayValue collection) + { + GaxPreconditions.CheckNotNull(collection, nameof(collection)); + return Property(value, collection, Operator.NotIn); + } /// /// Creates a filter to check that the specified property is less than a given value.