diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 26ee98ba..4428621c 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -26,7 +26,7 @@ jobs:
platform: macos-arm64
- os: windows-latest
platform: windows-x86_64
- tag: [release-2.28, main]
+ tag: [release-2.29, main]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout TileDB
@@ -73,7 +73,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- tag: [release-2.28, main]
+ tag: [release-2.29, main]
runs-on: ubuntu-latest
steps:
- name: Checkout TileDB-CSharp
@@ -107,7 +107,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
- tag: [release-2.28, main]
+ tag: [release-2.29, main]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout TileDB-CSharp
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 70ccbb61..580a1b15 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -2,7 +2,7 @@
true
TileDB.Native
- [2.28.1,2.29.0)
+ [2.29.1,2.30.0)
- PKV006
- net5.0
+ CP0001
+ T:TileDB.CSharp.ConfigIterator
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.__sFILE
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.ArrayHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.ArraySchemaEvolutionHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.ArraySchemaHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.AttributeHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.ConfigHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.ConfigIteratorHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.ContextHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.DimensionHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.DomainHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.FilterHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.FilterListHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.GroupHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.LibC
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.MarshaledString
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.MarshaledStringOut
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.QueryConditionHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.QueryHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.SpanExtensions
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_array_schema_evolution_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_array_schema_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_array_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_array_type_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_attribute_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_config_iter_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_config_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_ctx_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_datatype_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_dimension_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_domain_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_filter_list_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_filter_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_filter_type_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_group_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_query_condition_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_query_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_query_type_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.tiledb_vfs_t
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0001
+ T:TileDB.Interop.VFSHandle
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0002
+ M:TileDB.CSharp.Config.Iterate(System.String)
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0002
+ M:TileDB.CSharp.EnumUtil.DataTypeToType(TileDB.CSharp.DataType)
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
+
+
+ CP0002
+ M:TileDB.CSharp.EnumUtil.TypeToDataType(System.Type)
+ lib/net8.0/TileDB.CSharp.dll
+ lib/net8.0/TileDB.CSharp.dll
+ true
\ No newline at end of file
diff --git a/sources/TileDB.CSharp/Interop/Methods.cs b/sources/TileDB.CSharp/Interop/Methods.cs
index 6e79a0f0..f787e412 100644
--- a/sources/TileDB.CSharp/Interop/Methods.cs
+++ b/sources/TileDB.CSharp/Interop/Methods.cs
@@ -1492,6 +1492,10 @@ public static int tiledb_status([NativeTypeName("capi_return_t")] int x)
[return: NativeTypeName("capi_return_t")]
public static extern int tiledb_ndrectangle_get_dim_num(tiledb_ctx_t* ctx, [NativeTypeName("tiledb_ndrectangle_t *")] tiledb_ndrectangle_handle_t* ndr, [NativeTypeName("uint32_t *")] uint* ndim);
+ [DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ [return: NativeTypeName("capi_return_t")]
+ public static extern int tiledb_ndrectangle_dump_str(tiledb_ctx_t* ctx, [NativeTypeName("tiledb_ndrectangle_t *")] tiledb_ndrectangle_handle_t* ndr, tiledb_string_t** @out);
+
[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("capi_return_t")]
public static extern int tiledb_current_domain_create(tiledb_ctx_t* ctx, [NativeTypeName("tiledb_current_domain_t **")] tiledb_current_domain_handle_t** current_domain);
@@ -1516,6 +1520,10 @@ public static int tiledb_status([NativeTypeName("capi_return_t")] int x)
[return: NativeTypeName("capi_return_t")]
public static extern int tiledb_current_domain_get_type(tiledb_ctx_t* ctx, [NativeTypeName("tiledb_current_domain_t *")] tiledb_current_domain_handle_t* current_domain, tiledb_current_domain_type_t* type);
+ [DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ [return: NativeTypeName("capi_return_t")]
+ public static extern int tiledb_current_domain_dump_str(tiledb_ctx_t* ctx, [NativeTypeName("tiledb_current_domain_t *")] tiledb_current_domain_handle_t* current_domain, tiledb_string_t** @out);
+
[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("capi_return_t")]
public static extern int tiledb_array_schema_alloc_at_timestamp(tiledb_ctx_t* ctx, tiledb_array_type_t array_type, [NativeTypeName("uint64_t")] ulong timestamp, tiledb_array_schema_t** array_schema);
@@ -1646,8 +1654,13 @@ public static int tiledb_status([NativeTypeName("capi_return_t")] int x)
[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("capi_return_t")]
+ [Obsolete]
public static extern int tiledb_vfs_ls_recursive(tiledb_ctx_t* ctx, tiledb_vfs_t* vfs, [NativeTypeName("const char *")] sbyte* path, [NativeTypeName("tiledb_ls_callback_t")] delegate* unmanaged[Cdecl] callback, void* data);
+ [DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ [return: NativeTypeName("capi_return_t")]
+ public static extern int tiledb_vfs_ls_recursive_v2(tiledb_ctx_t* ctx, tiledb_vfs_t* vfs, [NativeTypeName("const char *")] sbyte* path, [NativeTypeName("tiledb_ls_callback_v2_t")] delegate* unmanaged[Cdecl] callback, void* data);
+
[DllImport("tiledb", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void tiledb_dimension_label_free(tiledb_dimension_label_t** dim_label);
diff --git a/sources/TileDB.CSharp/Interop/tiledb_array_type_t.cs b/sources/TileDB.CSharp/Interop/tiledb_array_type_t.cs
index d2de8ccf..76531f36 100644
--- a/sources/TileDB.CSharp/Interop/tiledb_array_type_t.cs
+++ b/sources/TileDB.CSharp/Interop/tiledb_array_type_t.cs
@@ -1,9 +1,5 @@
//
-using System;
-using System.ComponentModel;
-using TileDB.CSharp;
-
namespace TileDB.Interop
{
internal enum tiledb_array_type_t
diff --git a/sources/TileDB.CSharp/Interop/tiledb_datatype_t.cs b/sources/TileDB.CSharp/Interop/tiledb_datatype_t.cs
index 458e7068..9c5fb8c9 100644
--- a/sources/TileDB.CSharp/Interop/tiledb_datatype_t.cs
+++ b/sources/TileDB.CSharp/Interop/tiledb_datatype_t.cs
@@ -1,9 +1,5 @@
//
-using System;
-using System.ComponentModel;
-using TileDB.CSharp;
-
namespace TileDB.Interop
{
internal enum tiledb_datatype_t
diff --git a/sources/TileDB.CSharp/Interop/tiledb_filter_type_t.cs b/sources/TileDB.CSharp/Interop/tiledb_filter_type_t.cs
index dd967012..17653eb7 100644
--- a/sources/TileDB.CSharp/Interop/tiledb_filter_type_t.cs
+++ b/sources/TileDB.CSharp/Interop/tiledb_filter_type_t.cs
@@ -1,9 +1,5 @@
//
-using System;
-using System.ComponentModel;
-using TileDB.CSharp;
-
namespace TileDB.Interop
{
internal enum tiledb_filter_type_t
@@ -27,5 +23,6 @@ internal enum tiledb_filter_type_t
TILEDB_FILTER_DEPRECATED = 17,
TILEDB_FILTER_WEBP = 18,
TILEDB_FILTER_DELTA = 19,
+ TILEDB_INTERNAL_FILTER_COUNT = 20,
}
}
diff --git a/sources/TileDB.CSharp/Interop/tiledb_query_type_t.cs b/sources/TileDB.CSharp/Interop/tiledb_query_type_t.cs
index d49f36f1..21fa4db6 100644
--- a/sources/TileDB.CSharp/Interop/tiledb_query_type_t.cs
+++ b/sources/TileDB.CSharp/Interop/tiledb_query_type_t.cs
@@ -1,9 +1,5 @@
//
-using System;
-using System.ComponentModel;
-using TileDB.CSharp;
-
namespace TileDB.Interop
{
internal enum tiledb_query_type_t
diff --git a/sources/TileDB.CSharp/Marshalling/MarshaledStringOut.cs b/sources/TileDB.CSharp/Marshalling/MarshaledStringOut.cs
index 350e8a82..e8b42c51 100644
--- a/sources/TileDB.CSharp/Marshalling/MarshaledStringOut.cs
+++ b/sources/TileDB.CSharp/Marshalling/MarshaledStringOut.cs
@@ -1,4 +1,5 @@
using System;
+using System.Runtime.InteropServices;
using System.Text;
using TileDB.CSharp;
@@ -32,8 +33,6 @@ internal static unsafe string GetStringFromNullTerminated(sbyte* ptr)
return string.Empty;
}
- var span = new ReadOnlySpan(ptr, int.MaxValue);
- span = span[0..span.IndexOf((byte)0)];
- return GetString(span);
+ return GetString(MemoryMarshal.CreateReadOnlySpanFromNullTerminated((byte*)ptr));
}
}
diff --git a/sources/TileDB.CSharp/Obsoletions.cs b/sources/TileDB.CSharp/Obsoletions.cs
index ba697505..de4db0bc 100644
--- a/sources/TileDB.CSharp/Obsoletions.cs
+++ b/sources/TileDB.CSharp/Obsoletions.cs
@@ -53,4 +53,7 @@ internal static class Obsoletions
public const string FilestoreApiMessage = "File is obsolete and will be removed in a future version.";
public const string FilestoreApiDiagId = "TILEDB0016";
+
+ public const string VisitChildrenRecursiveV1Message = "The original VFS.VisitChildrenRecursive overload is obsolete and will be removed in a future version. Use the overload with the callback that accepts a boolean instead.";
+ public const string VisitChildrenRecursiveV1DiagId = "TILEDB0017";
}
diff --git a/sources/TileDB.CSharp/TileDB.CSharp.csproj b/sources/TileDB.CSharp/TileDB.CSharp.csproj
index d845130a..f8619155 100644
--- a/sources/TileDB.CSharp/TileDB.CSharp.csproj
+++ b/sources/TileDB.CSharp/TileDB.CSharp.csproj
@@ -6,12 +6,12 @@
true
enable
TileDB.CSharp
- 5.18.0
+ 5.19.0
C# wrapper of the TileDB Embedded universal data engine.
README.md
true
true
- 5.17.0
+ 5.18.0
diff --git a/sources/TileDB.CSharp/VFS.cs b/sources/TileDB.CSharp/VFS.cs
index 40ac7477..b7cdefcf 100644
--- a/sources/TileDB.CSharp/VFS.cs
+++ b/sources/TileDB.CSharp/VFS.cs
@@ -33,9 +33,7 @@ public VFS(Context ctx) : this(ctx, null) { }
///
/// The context to associate the VFS with. Defaults to
/// The ' . Defaults to 's config.
-#pragma warning disable S3427 // Method overloads with default parameter values should not overlap
public VFS(Context? ctx = null, Config? config = null)
-#pragma warning restore S3427 // Method overloads with default parameter values should not overlap
{
ctx_ = ctx ?? Context.GetDefault();
handle_ = VFSHandle.Create(ctx_, config?.Handle);
@@ -352,6 +350,25 @@ private static int VisitRecursiveCallback(sbyte* uriPtr, nuint uriSize, ulong si
return shouldContinue ? 1 : 0;
}
+ [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])]
+ private static int VisitRecursiveV2Callback(sbyte* uriPtr, nuint uriSize, ulong size, byte is_dir, void* data)
+ {
+ string uri = MarshaledStringOut.GetStringFromNullTerminated(uriPtr);
+ VisitRecursiveV2CallbackData* callbackData = (VisitRecursiveV2CallbackData*)data;
+ Debug.Assert(callbackData->Exception is null);
+ bool shouldContinue;
+ try
+ {
+ shouldContinue = callbackData->Invoke(uri, size, is_dir != 0);
+ }
+ catch (Exception e)
+ {
+ callbackData->Exception = ExceptionDispatchInfo.Capture(e);
+ shouldContinue = false;
+ }
+ return shouldContinue ? 1 : 0;
+ }
+
///
/// Lists the top-level children of a directory.
///
@@ -384,9 +401,12 @@ public List GetChildren(string uri)
public List<(string Uri, ulong Size)> GetChildrenRecursive(string uri)
{
var list = new List<(string Uri, ulong Size)>();
- VisitChildrenRecursive(uri, static (uri, size, list) =>
+ VisitChildrenRecursive(uri, static (uri, size, isDir, list) =>
{
- list.Add((uri, size));
+ if (!isDir)
+ {
+ list.Add((uri, size));
+ }
return true;
}, list);
return list;
@@ -439,6 +459,7 @@ public void VisitChildren(string uri, Func callback, T callb
///
/// This operation is supported only on URIs to local file system, S3, Azure and GCS.
///
+ [Obsolete(Obsoletions.VisitChildrenRecursiveV1Message, DiagnosticId = Obsoletions.VisitChildrenRecursiveV1DiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public void VisitChildrenRecursive(string uri, Func callback, T callbackArg)
{
ValueTuple, T> data = (callback, callbackArg);
@@ -463,6 +484,42 @@ public void VisitChildrenRecursive(string uri, Func c
callbackData.Exception?.Throw();
}
+ ///
+ /// Visits all files and subdirectories of a directory and its subdirectories recursively.
+ ///
+ /// The URI of the directory to visit.
+ /// A callback delegate that will be called with the URI of each file,
+ /// its size, whether it is a directory and , and returns whether
+ /// to continue visiting.
+ /// An argument that will be passed to .
+ /// The type of .
+ ///
+ /// This operation is supported only on URIs to local file system, S3, Azure and GCS.
+ ///
+ public void VisitChildrenRecursive(string uri, Func callback, T callbackArg)
+ {
+ ValueTuple, T> data = (callback, callbackArg);
+ var callbackData = new VisitRecursiveV2CallbackData()
+ {
+ Callback = static (uri, size, is_dir, arg) =>
+ {
+ var dataPtr = (ValueTuple, T>*)arg;
+ return dataPtr->Item1(uri, size, is_dir, dataPtr->Item2);
+ },
+ CallbackArgument = (IntPtr)(&data)
+ };
+
+ using var ctxHandle = ctx_.Handle.Acquire();
+ using var handle = handle_.Acquire();
+ using var ms_uri = new MarshaledString(uri);
+ // Taking a pointer to callbackData is safe; the callback will be invoked only
+ // during the call to tiledb_vfs_ls_recursive. Contrast this with tiledb_query_submit_async where we
+ // had to use a GCHandle because the callback might be invoked after we return from it.
+ // We also are not susceptible to GC holes; callbackData is in the stack and won't be moved around.
+ ctx_.handle_error(Methods.tiledb_vfs_ls_recursive_v2(ctxHandle, handle, ms_uri, &VisitRecursiveV2Callback, &callbackData));
+ callbackData.Exception?.Throw();
+ }
+
private struct VisitCallbackData
{
public Func Callback;
@@ -490,4 +547,18 @@ private struct VisitRecursiveCallbackData
public readonly bool Invoke(string uri, ulong size) => Callback(uri, size, CallbackArgument);
}
+
+ private struct VisitRecursiveV2CallbackData
+ {
+ public Func Callback;
+
+ public IntPtr CallbackArgument;
+
+ // If the callback threw an exception we will save it here and rethrow it once we leave native code.
+ // The reason we do this is that throwing exceptions in P/Invoke is not portable (works only on Windows
+ // and because the native library is compiled with MSVC).
+ public ExceptionDispatchInfo? Exception;
+
+ public readonly bool Invoke(string uri, ulong size, bool is_dir) => Callback(uri, size, is_dir, CallbackArgument);
+ }
}
diff --git a/tests/TileDB.CSharp.Test/VFSTest.cs b/tests/TileDB.CSharp.Test/VFSTest.cs
index 826c913a..5d11427c 100644
--- a/tests/TileDB.CSharp.Test/VFSTest.cs
+++ b/tests/TileDB.CSharp.Test/VFSTest.cs
@@ -3,6 +3,8 @@
using System.IO;
using System.Security.Cryptography;
+#pragma warning disable TILEDB0017
+
namespace TileDB.CSharp.Test;
[TestClass]
@@ -76,7 +78,7 @@ public void TestCopyMove()
using var vfs = new VFS();
- WriteRandomData(vfs, file1Uri, DataSize, out var dataWrite);
+ WriteRandomData(vfs, file1Uri, DataSize, out var _);
Assert.AreEqual((ulong)DataSize, vfs.FileSize(file1Uri));
vfs.MoveFile(file1Uri, file2Uri);
Assert.IsFalse(vfs.IsFile(file1Uri));
@@ -157,7 +159,7 @@ public void TestVisitPropagatesExceptions()
[TestMethod]
public void TestVisitRecursive()
{
- using var dir = new TemporaryDirectory("vfs-visit");
+ using var dir = new TemporaryDirectory("vfs-visit-recursive");
using var vfs = new VFS();
vfs.CreateDir(Path.Combine(dir, "dir1"));
@@ -172,7 +174,37 @@ public void TestVisitRecursive()
vfs.VisitChildrenRecursive(dir, (uri, size, arg) =>
{
string path = new Uri(uri).LocalPath;
- Assert.IsTrue(Directory.Exists(path) || System.IO.File.Exists(path));
+ Assert.IsTrue(System.IO.File.Exists(path) || Directory.Exists(path));
+ Assert.AreEqual(path.EndsWith("file3") ? 5ul : 0ul, size);
+ Assert.AreEqual(555, arg);
+
+ i++;
+ return i != 2;
+ }, 555);
+
+ Assert.AreEqual(2, i);
+ }
+
+ [TestMethod]
+ public void TestVisitRecursiveV2()
+ {
+ using var dir = new TemporaryDirectory("vfs-visit-recursive-v2");
+
+ using var vfs = new VFS();
+ vfs.CreateDir(Path.Combine(dir, "dir1"));
+ vfs.Touch(Path.Combine(dir, "dir1/file1"));
+ vfs.CreateDir(Path.Combine(dir, "dir2"));
+ vfs.Touch(Path.Combine(dir, "dir2/file2"));
+ vfs.CreateDir(Path.Combine(dir, "dir3"));
+ System.IO.File.WriteAllBytes(Path.Combine(dir, "dir3/file3"), "12345"u8.ToArray());
+
+ int i = 0;
+
+ vfs.VisitChildrenRecursive(dir, (uri, size, isDir, arg) =>
+ {
+ string path = new Uri(uri).LocalPath;
+ Assert.AreEqual(isDir, Directory.Exists(path));
+ Assert.AreEqual(!isDir, System.IO.File.Exists(path));
Assert.AreEqual(path.EndsWith("file3") ? 5ul : 0ul, size);
Assert.AreEqual(555, arg);
@@ -186,7 +218,7 @@ public void TestVisitRecursive()
[TestMethod]
public void TestVisitRecursivePropagatesExceptions()
{
- using var dir = new TemporaryDirectory("vfs-visit-exceptions");
+ using var dir = new TemporaryDirectory("vfs-visit-recursive-exceptions");
const string ExceptionKey = "foo";
@@ -214,4 +246,36 @@ public void TestVisitRecursivePropagatesExceptions()
Assert.Fail("Exception was not propagated.");
}
+
+ [TestMethod]
+ public void TestVisitRecursiveV2PropagatesExceptions()
+ {
+ using var dir = new TemporaryDirectory("vfs-visit-recursive-v2-exceptions");
+
+ const string ExceptionKey = "foo";
+
+ using var vfs = new VFS();
+ vfs.CreateDir(Path.Combine(dir, "dir1"));
+ vfs.Touch(Path.Combine(dir, "dir1/file1"));
+
+ int i = 0;
+
+ try
+ {
+ vfs.VisitChildrenRecursive(dir, (_, _, _, _) =>
+ {
+ i++;
+ throw new Exception(ExceptionKey);
+ }, 0);
+ }
+ catch (Exception e)
+ {
+ Assert.AreEqual(1, i);
+ Assert.AreEqual(typeof(Exception), e.GetType());
+ Assert.AreEqual(ExceptionKey, e.Message);
+ return;
+ }
+
+ Assert.Fail("Exception was not propagated.");
+ }
}