diff --git a/src/client/spark_core/Collections/Extensions/EnumerableExtensions.cs b/src/client/spark_core/Collections/Extensions/EnumerableExtensions.cs index 3baac4382..be462dd99 100644 --- a/src/client/spark_core/Collections/Extensions/EnumerableExtensions.cs +++ b/src/client/spark_core/Collections/Extensions/EnumerableExtensions.cs @@ -237,10 +237,11 @@ namespace System.Collections.Generic { yield return ConvertUtils.try_convert(v); } - public static IEnumerable ExceptNull(this IEnumerable source) where T : class { + public static IEnumerable ExceptNull(this IEnumerable source) where T : class { foreach (var v in source) { - if (v != null) + if (v is not null) { yield return v; + } } } @@ -908,9 +909,10 @@ namespace System.Collections.Generic { public static IEnumerable empty_if_null(this IEnumerable? source) => source ?? Enumerable.Empty(); - public static void DisposeAll(this IEnumerable source) { - foreach (IDisposable d in source) - d.Dispose(); + public static void DisposeAll(this IEnumerable source) { + foreach (var d in source) { + d?.Dispose(); + } } public static IEnumerable return_if(bool condition, Func get_value) {