Skip to content

Commit 5ccc03f

Browse files
committed
Improve type checking for FragmentInfo methods when the type is string.
If the generic type is string, we check ourselves that the `DataType` is a string one. This ensures the exception thrown is `ArgumentException` instead of `TileDBException`. The exception message also is more descriptive.
1 parent 8e3af2c commit 5ccc03f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

sources/TileDB.CSharp/FragmentInfo.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,13 @@ public ulong GetMinimumBoundedRectangleCount(uint fragmentIndex)
411411
DataType dataType = GetDimensionType(fragmentIndex, dimensionIndex);
412412
if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
413413
{
414-
if (typeof(T) == typeof(string))
414+
if (typeof(T) == typeof(string) && EnumUtil.IsStringType(dataType))
415415
{
416416
(string startStr, string endStr) =
417417
GetStringMinimumBoundedRectangle(fragmentIndex, minimumBoundedRectangleIndex, dimensionIndex, dataType);
418418
return ((T)(object)startStr, (T)(object)endStr);
419419
}
420-
ThrowHelpers.ThrowTypeNotSupported();
420+
ThrowHelpers.ThrowTypeMismatch(dataType);
421421
return default;
422422
}
423423
ValidateDomainType<T>(dataType);
@@ -450,13 +450,13 @@ public ulong GetMinimumBoundedRectangleCount(uint fragmentIndex)
450450
DataType dataType = GetDimensionType(fragmentIndex, dimensionName);
451451
if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
452452
{
453-
if (typeof(T) == typeof(string))
453+
if (typeof(T) == typeof(string) && EnumUtil.IsStringType(dataType))
454454
{
455455
(string startStr, string endStr) =
456456
GetStringMinimumBoundedRectangle(fragmentIndex, minimumBoundedRectangleIndex, dimensionName, dataType);
457457
return ((T)(object)startStr, (T)(object)endStr);
458458
}
459-
ThrowHelpers.ThrowTypeNotSupported();
459+
ThrowHelpers.ThrowTypeMismatch(dataType);
460460
return default;
461461
}
462462
ValidateDomainType<T>(dataType);
@@ -536,12 +536,12 @@ public ulong GetMinimumBoundedRectangleCount(uint fragmentIndex)
536536
DataType dataType = GetDimensionType(fragmentIndex, dimensionIndex);
537537
if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
538538
{
539-
if (typeof(T) == typeof(string))
539+
if (typeof(T) == typeof(string) && EnumUtil.IsStringType(dataType))
540540
{
541541
(string startStr, string endStr) = GetStringNonEmptyDomain(fragmentIndex, dimensionIndex, dataType);
542542
return ((T)(object)startStr, (T)(object)endStr);
543543
}
544-
ThrowHelpers.ThrowTypeNotSupported();
544+
ThrowHelpers.ThrowTypeMismatch(dataType);
545545
return default;
546546
}
547547
ValidateDomainType<T>(dataType);
@@ -574,12 +574,12 @@ public ulong GetMinimumBoundedRectangleCount(uint fragmentIndex)
574574
DataType dataType = GetDimensionType(fragmentIndex, dimensionName);
575575
if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
576576
{
577-
if (typeof(T) == typeof(string))
577+
if (typeof(T) == typeof(string) && EnumUtil.IsStringType(dataType))
578578
{
579579
(string startStr, string endStr) = GetStringNonEmptyDomain(fragmentIndex, dimensionName, dataType);
580580
return ((T)(object)startStr, (T)(object)endStr);
581581
}
582-
ThrowHelpers.ThrowTypeNotSupported();
582+
ThrowHelpers.ThrowTypeMismatch(dataType);
583583
return default;
584584
}
585585
ValidateDomainType<T>(dataType);

0 commit comments

Comments
 (0)