diff --git a/src/csharp/Microsoft.Spark/Interop/Ipc/PayloadHelper.cs b/src/csharp/Microsoft.Spark/Interop/Ipc/PayloadHelper.cs index 3373bca62..bfe77caad 100644 --- a/src/csharp/Microsoft.Spark/Interop/Ipc/PayloadHelper.cs +++ b/src/csharp/Microsoft.Spark/Interop/Ipc/PayloadHelper.cs @@ -323,15 +323,6 @@ internal static byte[] GetTypeId(Type type) case TypeCode.Double: return s_doubleTypeId; case TypeCode.Object: - if (typeof(IJvmObjectReferenceProvider).IsAssignableFrom(type)) - { - return s_jvmObjectTypeId; - } - - if (type == typeof(byte[])) - { - return s_byteArrayTypeId; - } if (type == typeof(int[]) || type == typeof(long[]) || @@ -343,36 +334,17 @@ internal static byte[] GetTypeId(Type type) return s_arrayTypeId; } - if (IsDictionary(type)) - { - return s_dictionaryTypeId; - } - - if (typeof(IEnumerable).IsAssignableFrom(type)) - { - return s_arrayTypeId; - } - - if (typeof(IEnumerable).IsAssignableFrom(type)) - { - return s_rowArrTypeId; - } - - if (typeof(IEnumerable).IsAssignableFrom(type)) + return type switch { - return s_objectArrTypeId; - } - - if (typeof(Date).IsAssignableFrom(type)) - { - return s_dateTypeId; - } - - if (typeof(Timestamp).IsAssignableFrom(type)) - { - return s_timestampTypeId; - } - break; + _ when typeof(IJvmObjectReferenceProvider).IsAssignableFrom(type) => s_jvmObjectTypeId, + _ when type == typeof(byte[]) => s_byteArrayTypeId, + _ when IsDictionary(type) => s_dictionaryTypeId, + _ when typeof(IEnumerable).IsAssignableFrom(type) => s_arrayTypeId, + _ when typeof(IEnumerable).IsAssignableFrom(type) => s_rowArrTypeId, + _ when typeof(IEnumerable).IsAssignableFrom(type) => s_objectArrTypeId, + _ when typeof(Date).IsAssignableFrom(type) => s_dateTypeId, + _ when typeof(Timestamp).IsAssignableFrom(type) => s_timestampTypeId, + }; } // TODO: Support other types.