public static Type GetNullableType(this Type type) { Debug.Assert(type != null, "type cannot be null"); if (type.GetTypeInfo().IsValueType && !IsNullableType(type)) { return typeof(Nullable<>).MakeGenericType(type); } return type; }