diff --git a/docs/obsoletions.md b/docs/obsoletions.md index 5315c7c9..8893f3a2 100644 --- a/docs/obsoletions.md +++ b/docs/obsoletions.md @@ -7,6 +7,7 @@ Following [the deprecation policy of TileDB Embedded][core-deprecation], obsolet |Diagnostic codes|Deprecated in version|Removed in version| |----------------|---------------------|------------------| |[`TILEDB0001`](#TILEDB0001) …[`TILEDB0011`](#TILEDB0011)|5.3.0|5.5.0| +|[`TILEDB0012`](#TILEDB0012) …[`TILEDB0012`](#TILEDB0012)|5.7.0|5.9.0| ## `TILEDB0001` - Enum value names that start with `TILEDB_` were replaced with C#-friendly names. @@ -299,4 +300,23 @@ Some of these methods were renamed or had their signature changed (for example t Instead of setting ranges and subarrays on the `Query`, create and configure a `Subarray` object, and assign it to the query using the `Query.SetSubarray` method. +## `TILEDB0012` - Members of the `TileDB.Interop` namespace will become internal in a future version and should not be used by user code. + + + +Some APIs in the `TileDB.Interop` namespace that were inadvertently removed in version 5.3.0 were reintroduced in version 5.7.0. They are marked as obsolete and hidden from IntelliSense and will be removed from the public API for good in version 5.9.0. They were also reintroduced in patch releases 5.3.1 and 5.4.1, obsoleted under the [`TILEDB0003`](#TILEDB0003) code. + +### Version introduced + +5.7.0 + +### Recommended action + +The obsoleted APIs fall into the following categories: + +- The `MarshaledString` and `MarshaledStringOut` types are used to help convert strings from and to ASCII and pass them to native code. If you are using them in user code for native code interop, you should use .NET's [built-in P/Invoke](https://learn.microsoft.com/en-us/dotnet/standard/native-interop/charset) marshaling instead. For other kinds of encoding conversions, you should use APIs from the [`System.Text.Encoding`](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding) class. +- The `__sFile` and `LibC` types have no members and there is no reason to use them anyway. +- The types that derive from `SafeHandle` are used to safely manage the lifetime of native TileDB objects. With the APIs in the `TileDB.CSharp` namespace providing broad coverage of TileDB's functionalities while also being safer and easier to sue, these types provide limited utility. You should use the APIs in the `TileDB.CSharp` namespace instead. +- Types with the name `tiledb_***_t` were made public again only to support the APIs of the safe handles above. They have little other use on their own. You should use APIs in the `TileDB.CSharp` namespace instead. + [core-deprecation]: https://github.com/TileDB-Inc/TileDB/blob/dev/doc/policy/api_changes.md diff --git a/sources/TileDB.CSharp/Array.cs b/sources/TileDB.CSharp/Array.cs index 1ba3ca04..7c04c1a4 100644 --- a/sources/TileDB.CSharp/Array.cs +++ b/sources/TileDB.CSharp/Array.cs @@ -5,6 +5,9 @@ using TileDB.CSharp.Marshalling; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using ArrayHandle = TileDB.CSharp.Marshalling.SafeHandles.ArrayHandle; +using ArraySchemaHandle = TileDB.CSharp.Marshalling.SafeHandles.ArraySchemaHandle; +using ConfigHandle = TileDB.CSharp.Marshalling.SafeHandles.ConfigHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/ArraySchema.cs b/sources/TileDB.CSharp/ArraySchema.cs index b9d37f2c..376d9a60 100644 --- a/sources/TileDB.CSharp/ArraySchema.cs +++ b/sources/TileDB.CSharp/ArraySchema.cs @@ -2,6 +2,10 @@ using System.Collections.Generic; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using ArraySchemaHandle = TileDB.CSharp.Marshalling.SafeHandles.ArraySchemaHandle; +using FilterListHandle = TileDB.CSharp.Marshalling.SafeHandles.FilterListHandle; +using DomainHandle = TileDB.CSharp.Marshalling.SafeHandles.DomainHandle; +using AttributeHandle = TileDB.CSharp.Marshalling.SafeHandles.AttributeHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/ArraySchemaEvolution.cs b/sources/TileDB.CSharp/ArraySchemaEvolution.cs index 7611967d..76040185 100644 --- a/sources/TileDB.CSharp/ArraySchemaEvolution.cs +++ b/sources/TileDB.CSharp/ArraySchemaEvolution.cs @@ -1,6 +1,7 @@ using System; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using ArraySchemaEvolutionHandle = TileDB.CSharp.Marshalling.SafeHandles.ArraySchemaEvolutionHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/Attribute.cs b/sources/TileDB.CSharp/Attribute.cs index f3f9ba5b..98f478f6 100644 --- a/sources/TileDB.CSharp/Attribute.cs +++ b/sources/TileDB.CSharp/Attribute.cs @@ -2,8 +2,10 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; -using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using TileDB.CSharp.Marshalling.SafeHandles; +using AttributeHandle = TileDB.CSharp.Marshalling.SafeHandles.AttributeHandle; +using FilterListHandle = TileDB.CSharp.Marshalling.SafeHandles.FilterListHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/Config.cs b/sources/TileDB.CSharp/Config.cs index bbeed7d4..92eb2531 100644 --- a/sources/TileDB.CSharp/Config.cs +++ b/sources/TileDB.CSharp/Config.cs @@ -2,6 +2,7 @@ using System.Text; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using ConfigHandle = TileDB.CSharp.Marshalling.SafeHandles.ConfigHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/ConfigIterator.cs b/sources/TileDB.CSharp/ConfigIterator.cs index 0b570668..6e56e36b 100644 --- a/sources/TileDB.CSharp/ConfigIterator.cs +++ b/sources/TileDB.CSharp/ConfigIterator.cs @@ -1,6 +1,8 @@ using System; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using ConfigHandle = TileDB.CSharp.Marshalling.SafeHandles.ConfigHandle; +using ConfigIteratorHandle = TileDB.CSharp.Marshalling.SafeHandles.ConfigIteratorHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/Context.cs b/sources/TileDB.CSharp/Context.cs index 9e5bd072..d633ba85 100644 --- a/sources/TileDB.CSharp/Context.cs +++ b/sources/TileDB.CSharp/Context.cs @@ -7,6 +7,8 @@ using System.Text; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using ContextHandle = TileDB.CSharp.Marshalling.SafeHandles.ContextHandle; +using ConfigHandle = TileDB.CSharp.Marshalling.SafeHandles.ConfigHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/Dimension.cs b/sources/TileDB.CSharp/Dimension.cs index aab689e8..009ffa6d 100644 --- a/sources/TileDB.CSharp/Dimension.cs +++ b/sources/TileDB.CSharp/Dimension.cs @@ -4,6 +4,8 @@ using TileDB.CSharp.Marshalling; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using DimensionHandle = TileDB.CSharp.Marshalling.SafeHandles.DimensionHandle; +using FilterListHandle = TileDB.CSharp.Marshalling.SafeHandles.FilterListHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/Domain.cs b/sources/TileDB.CSharp/Domain.cs index 24a25f81..f23a3ea8 100644 --- a/sources/TileDB.CSharp/Domain.cs +++ b/sources/TileDB.CSharp/Domain.cs @@ -1,6 +1,8 @@ using System; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using DomainHandle = TileDB.CSharp.Marshalling.SafeHandles.DomainHandle; +using DimensionHandle = TileDB.CSharp.Marshalling.SafeHandles.DimensionHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/File.cs b/sources/TileDB.CSharp/File.cs index 4a38e751..0d7df6e3 100644 --- a/sources/TileDB.CSharp/File.cs +++ b/sources/TileDB.CSharp/File.cs @@ -1,6 +1,7 @@ using System.ComponentModel; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using ArraySchemaHandle = TileDB.CSharp.Marshalling.SafeHandles.ArraySchemaHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/Filter.cs b/sources/TileDB.CSharp/Filter.cs index e1a4b6ec..3f8fc57a 100644 --- a/sources/TileDB.CSharp/Filter.cs +++ b/sources/TileDB.CSharp/Filter.cs @@ -3,6 +3,7 @@ using System.Runtime.InteropServices; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using FilterHandle = TileDB.CSharp.Marshalling.SafeHandles.FilterHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/FilterList.cs b/sources/TileDB.CSharp/FilterList.cs index 89c4fa59..ec8e627b 100644 --- a/sources/TileDB.CSharp/FilterList.cs +++ b/sources/TileDB.CSharp/FilterList.cs @@ -1,6 +1,8 @@ using System; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using FilterHandle = TileDB.CSharp.Marshalling.SafeHandles.FilterHandle; +using FilterListHandle = TileDB.CSharp.Marshalling.SafeHandles.FilterListHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/FragmentInfo.cs b/sources/TileDB.CSharp/FragmentInfo.cs index f9e6f35d..5db26a0d 100644 --- a/sources/TileDB.CSharp/FragmentInfo.cs +++ b/sources/TileDB.CSharp/FragmentInfo.cs @@ -3,6 +3,8 @@ using TileDB.CSharp.Marshalling; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using ArraySchemaHandle = TileDB.CSharp.Marshalling.SafeHandles.ArraySchemaHandle; +using ConfigHandle = TileDB.CSharp.Marshalling.SafeHandles.ConfigHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/Group.cs b/sources/TileDB.CSharp/Group.cs index 1ee4ab71..af2c3875 100644 --- a/sources/TileDB.CSharp/Group.cs +++ b/sources/TileDB.CSharp/Group.cs @@ -1,6 +1,8 @@ using System; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using GroupHandle = TileDB.CSharp.Marshalling.SafeHandles.GroupHandle; +using ConfigHandle = TileDB.CSharp.Marshalling.SafeHandles.ConfigHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/Interop/InteropAux.cs b/sources/TileDB.CSharp/Interop/InteropAux.cs new file mode 100644 index 00000000..550fb248 --- /dev/null +++ b/sources/TileDB.CSharp/Interop/InteropAux.cs @@ -0,0 +1,13 @@ +using System.ComponentModel; +using System; +using TileDB.CSharp; + +namespace TileDB.Interop +{ + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + // placeholder struct to avoid errors loading generated code + public partial struct __sFILE + { + } +} \ No newline at end of file diff --git a/sources/TileDB.CSharp/Interop/SpanExtensions.cs b/sources/TileDB.CSharp/Interop/SpanExtensions.cs new file mode 100644 index 00000000..99a4ae4b --- /dev/null +++ b/sources/TileDB.CSharp/Interop/SpanExtensions.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. +//https://github.com/dotnet/ClangSharp/blob/67c1e5243b9d58f2b28f10e3f9a82f7537fd9d88/sources/ClangSharp.Interop/Internals/SpanExtensions.cs + +using System; +using System.ComponentModel; +using System.Text; +using TileDB.CSharp; + +namespace TileDB.Interop +{ + [Obsolete(Obsoletions.TileDBInteropMessage, DiagnosticId = Obsoletions.TileDBInteropDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public static unsafe class SpanExtensions + { + public static string AsString(this Span self) => AsString((ReadOnlySpan)self); + + public static string AsString(this ReadOnlySpan self) + { + if (self.IsEmpty) + { + return string.Empty; + } + + fixed (byte* pSelf = self) + { + return Encoding.ASCII.GetString(pSelf, self.Length); + } + } + } + +}//namespace \ No newline at end of file diff --git a/sources/TileDB.CSharp/Interop/TileDBSafeHandle.cs b/sources/TileDB.CSharp/Interop/TileDBSafeHandle.cs new file mode 100644 index 00000000..864b4061 --- /dev/null +++ b/sources/TileDB.CSharp/Interop/TileDBSafeHandle.cs @@ -0,0 +1,663 @@ +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; +using TileDB.CSharp; + +namespace TileDB.Interop +{ + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class ConfigHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + + public ConfigHandle() : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_config_t*[1]; + var e = stackalloc tiledb_error_t*[1]; + Methods.tiledb_config_alloc(h, e); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_config_t*)handle; + Methods.tiledb_config_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_config_t* h) { SetHandle((IntPtr)h); } + private protected ConfigHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(ConfigHandle h) => h.handle; + public static implicit operator tiledb_config_t*(ConfigHandle h) => (tiledb_config_t*)h.handle; + public static implicit operator ConfigHandle(tiledb_config_t* value) => new ConfigHandle((IntPtr)value); + }//public unsafe partial class ConfigHandle + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class ConfigIteratorHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + + public ConfigIteratorHandle(ConfigHandle hconfig, string prefix) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_config_iter_t*[1]; + var e = stackalloc tiledb_error_t*[1]; + var ms_prefix = new MarshaledString(prefix); + Methods.tiledb_config_iter_alloc(hconfig, ms_prefix, h, e); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHTha andle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_config_iter_t*)handle; + Methods.tiledb_config_iter_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_config_iter_t* h) { SetHandle((IntPtr)h); } + private protected ConfigIteratorHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(ConfigIteratorHandle h) => h.handle; + public static implicit operator tiledb_config_iter_t*(ConfigIteratorHandle h) => (tiledb_config_iter_t*)h.handle; + public static implicit operator ConfigIteratorHandle(tiledb_config_iter_t* value) => new ConfigIteratorHandle((IntPtr)value); + }//public unsafe partial class ConfigHandle + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class ContextHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + public ContextHandle() : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_ctx_t*[1]; + var hconfig = new ConfigHandle(); + Methods.tiledb_ctx_alloc(hconfig, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + public ContextHandle(ConfigHandle hconfig) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_ctx_t*[1]; + Methods.tiledb_ctx_alloc(hconfig, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_ctx_t*)handle; + Methods.tiledb_ctx_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_ctx_t* h) { SetHandle((IntPtr)h); } + private protected ContextHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(ContextHandle h) => h.handle; + public static implicit operator tiledb_ctx_t*(ContextHandle h) => (tiledb_ctx_t*)h.handle; + public static implicit operator ContextHandle(tiledb_ctx_t* value) => new ContextHandle((IntPtr)value); + }//public unsafe partial class ContextHandle + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class FilterHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + + public FilterHandle(ContextHandle hcontext, tiledb_filter_type_t filterType) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_filter_t*[1]; + + Methods.tiledb_filter_alloc(hcontext, filterType, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_filter_t*)handle; + Methods.tiledb_filter_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_filter_t* h) { SetHandle((IntPtr)h); } + private protected FilterHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(FilterHandle h) => h.handle; + public static implicit operator tiledb_filter_t*(FilterHandle h) => (tiledb_filter_t*)h.handle; + public static implicit operator FilterHandle(tiledb_filter_t* value) => new FilterHandle((IntPtr)value); + }//public unsafe partial class FilterHandle + + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class FilterListHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + public FilterListHandle(ContextHandle hcontext) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_filter_list_t*[1]; + + Methods.tiledb_filter_list_alloc(hcontext, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_filter_list_t*)handle; + Methods.tiledb_filter_list_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_filter_list_t* h) { SetHandle((IntPtr)h); } + private protected FilterListHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(FilterListHandle h) => h.handle; + public static implicit operator tiledb_filter_list_t*(FilterListHandle h) => (tiledb_filter_list_t*)h.handle; + public static implicit operator FilterListHandle(tiledb_filter_list_t* value) => new FilterListHandle((IntPtr)value); + }//public unsafe partial class FilterListHandle + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe partial class VFSHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + + public VFSHandle(ContextHandle hcontext, ConfigHandle hconfig) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_vfs_t*[1]; + + int status = TileDB.Interop.Methods.tiledb_vfs_alloc(hcontext, hconfig, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + tiledb_vfs_t* p = (tiledb_vfs_t*)handle; + TileDB.Interop.Methods.tiledb_vfs_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public UInt64 get() { return (UInt64)this.handle; } + private protected void SetHandle(tiledb_vfs_t* h) { SetHandle((IntPtr)h); } + private protected VFSHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => this.handle == IntPtr.Zero; + public static implicit operator IntPtr(VFSHandle h) => h.handle; + public static implicit operator tiledb_vfs_t*(VFSHandle h) => (tiledb_vfs_t*)h.handle; + public static implicit operator VFSHandle(tiledb_vfs_t* value) => new VFSHandle((IntPtr)value); + }//public unsafe partial class VFSHandle + + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class AttributeHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + public AttributeHandle(ContextHandle hcontext, string name, tiledb_datatype_t datatype) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_attribute_t*[1]; + + var ms_name = new MarshaledString(name); + Methods.tiledb_attribute_alloc(hcontext, ms_name, datatype, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_attribute_t*)handle; + Methods.tiledb_attribute_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_attribute_t* h) { SetHandle((IntPtr)h); } + private protected AttributeHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(AttributeHandle h) => h.handle; + public static implicit operator tiledb_attribute_t*(AttributeHandle h) => (tiledb_attribute_t*)h.handle; + public static implicit operator AttributeHandle(tiledb_attribute_t* value) => new AttributeHandle((IntPtr)value); + }//public unsafe partial class AttributeHandle + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class DimensionHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + + public DimensionHandle(ContextHandle hcontext, string name, tiledb_datatype_t datatype, void* dimDomain, void* tileExtent) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_dimension_t*[1]; + + var ms_name = new MarshaledString(name); + + Methods.tiledb_dimension_alloc(hcontext, ms_name, datatype, dimDomain, tileExtent, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_dimension_t*)handle; + Methods.tiledb_dimension_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_dimension_t* h) { SetHandle((IntPtr)h); } + private protected DimensionHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(DimensionHandle h) => h.handle; + public static implicit operator tiledb_dimension_t*(DimensionHandle h) => (tiledb_dimension_t*)h.handle; + public static implicit operator DimensionHandle(tiledb_dimension_t* value) => new DimensionHandle((IntPtr)value); + }//public unsafe partial class DimensionHandle + + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class DomainHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + + public DomainHandle(ContextHandle hcontext) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_domain_t*[1]; + + Methods.tiledb_domain_alloc(hcontext, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_domain_t*)handle; + Methods.tiledb_domain_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_domain_t* h) { SetHandle((IntPtr)h); } + private protected DomainHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(DomainHandle h) => h.handle; + public static implicit operator tiledb_domain_t*(DomainHandle h) => (tiledb_domain_t*)h.handle; + public static implicit operator DomainHandle(tiledb_domain_t* value) => new DomainHandle((IntPtr)value); + }//public unsafe partial class DomainHandle + + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class ArraySchemaHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + public ArraySchemaHandle(ContextHandle contextHandle, tiledb_array_type_t arrayType) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_array_schema_t*[1]; + + Methods.tiledb_array_schema_alloc(contextHandle, arrayType, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_array_schema_t*)handle; + Methods.tiledb_array_schema_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_array_schema_t* h) { SetHandle((IntPtr)h); } + private protected ArraySchemaHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(ArraySchemaHandle h) => h.handle; + public static implicit operator tiledb_array_schema_t*(ArraySchemaHandle h) => (tiledb_array_schema_t*)h.handle; + public static implicit operator ArraySchemaHandle(tiledb_array_schema_t* value) => new ArraySchemaHandle((IntPtr)value); + }//public unsafe partial class ArraySchemaHandle + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class ArrayHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + public ArrayHandle(ContextHandle contextHandle, sbyte* uri) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_array_t*[1]; + + Methods.tiledb_array_alloc(contextHandle, uri, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_array_t*)handle; + Methods.tiledb_array_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_array_t* h) { SetHandle((IntPtr)h); } + private protected ArrayHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(ArrayHandle h) => h.handle; + public static implicit operator tiledb_array_t*(ArrayHandle h) => (tiledb_array_t*)h.handle; + public static implicit operator ArrayHandle(tiledb_array_t* value) => new ArrayHandle((IntPtr)value); + }//public unsafe partial class ArrayHandle + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class ArraySchemaEvolutionHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + public ArraySchemaEvolutionHandle(ContextHandle contextHandle) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_array_schema_evolution_t*[1]; + Methods.tiledb_array_schema_evolution_alloc(contextHandle, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate ArraySchemaEvolutionHandle!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + protected override bool ReleaseHandle() + { + var p = (tiledb_array_schema_evolution_t*)handle; + Methods.tiledb_array_schema_evolution_free(&p); + SetHandle(IntPtr.Zero); + return true; + } + + // Conversions, getters, operators + public ulong Get() => (ulong)handle; + private protected void SetHandle(tiledb_array_schema_evolution_t* h) => SetHandle((IntPtr)h); + private protected ArraySchemaEvolutionHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(ArraySchemaEvolutionHandle h) => h.handle; + public static implicit operator tiledb_array_schema_evolution_t*(ArraySchemaEvolutionHandle h) => + (tiledb_array_schema_evolution_t*)h.handle; + public static implicit operator ArraySchemaEvolutionHandle(tiledb_array_schema_evolution_t* value) => + new ArraySchemaEvolutionHandle((IntPtr)value); + }//public unsafe class ArraySchemaEvolutionHandle + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class QueryHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + public QueryHandle(ContextHandle contextHandle, ArrayHandle arrayHandle, tiledb_query_type_t queryType) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_query_t*[1]; + + Methods.tiledb_query_alloc(contextHandle, arrayHandle, queryType, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_query_t*)handle; + Methods.tiledb_query_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_query_t* h) { SetHandle((IntPtr)h); } + private protected QueryHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(QueryHandle h) => h.handle; + public static implicit operator tiledb_query_t*(QueryHandle h) => (tiledb_query_t*)h.handle; + public static implicit operator QueryHandle(tiledb_query_t* value) => new QueryHandle((IntPtr)value); + }//public unsafe partial class QueryHandle + + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class QueryConditionHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + public QueryConditionHandle(ContextHandle contextHandle) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_query_condition_t*[1]; + + Methods.tiledb_query_condition_alloc(contextHandle, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_query_condition_t*)handle; + Methods.tiledb_query_condition_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_query_condition_t* h) { SetHandle((IntPtr)h); } + private protected QueryConditionHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(QueryConditionHandle h) => h.handle; + public static implicit operator tiledb_query_condition_t*(QueryConditionHandle h) => (tiledb_query_condition_t*)h.handle; + public static implicit operator QueryConditionHandle(tiledb_query_condition_t* value) => new QueryConditionHandle((IntPtr)value); + }//public unsafe partial class QueryConditionHandle + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class GroupHandle : SafeHandle + { + // Constructor for a Handle + // - calls native allocator + // - exception on failure + public GroupHandle(ContextHandle contextHandle, sbyte* uri) : base(IntPtr.Zero, ownsHandle: true) + { + var h = stackalloc tiledb_group_t*[1]; + + Methods.tiledb_group_alloc(contextHandle, uri, h); + + if (h[0] == (void*)0) + { + throw new Exception("Failed to allocate!"); + } + SetHandle(h[0]); + } + + // Deallocator: call native free with CER guarantees from SafeHandle + override protected bool ReleaseHandle() + { + // Free the native object + var p = (tiledb_group_t*)handle; + Methods.tiledb_group_free(&p); + // Invalidate the contained pointer + SetHandle(IntPtr.Zero); + + return true; + } + + // Conversions, getters, operators + public ulong Get() { return (ulong)handle; } + private protected void SetHandle(tiledb_group_t* h) { SetHandle((IntPtr)h); } + private protected GroupHandle(IntPtr value) : base(value, ownsHandle: false) { } + public override bool IsInvalid => handle == IntPtr.Zero; + public static implicit operator IntPtr(GroupHandle h) => h.handle; + public static implicit operator tiledb_group_t*(GroupHandle h) => (tiledb_group_t*)h.handle; + public static implicit operator GroupHandle(tiledb_group_t* value) => new GroupHandle((IntPtr)value); + }//public unsafe partial class GroupHandle + +}//namespace \ No newline at end of file diff --git a/sources/TileDB.CSharp/Interop/tiledb_array_schema_evolution_t.cs b/sources/TileDB.CSharp/Interop/tiledb_array_schema_evolution_t.cs index 5963a931..62f30fd0 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_array_schema_evolution_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_array_schema_evolution_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_array_schema_evolution_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_array_schema_evolution_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_array_schema_t.cs b/sources/TileDB.CSharp/Interop/tiledb_array_schema_t.cs index 0ed17363..d6e93260 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_array_schema_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_array_schema_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_array_schema_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_array_schema_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_array_t.cs b/sources/TileDB.CSharp/Interop/tiledb_array_t.cs index f4ac4bd3..bae73dd0 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_array_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_array_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_array_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_array_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_array_type_t.cs b/sources/TileDB.CSharp/Interop/tiledb_array_type_t.cs index 76531f36..68bb1502 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_array_type_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_array_type_t.cs @@ -2,7 +2,7 @@ namespace TileDB.Interop { - internal enum tiledb_array_type_t + public enum tiledb_array_type_t { TILEDB_DENSE = 0, TILEDB_SPARSE = 1, diff --git a/sources/TileDB.CSharp/Interop/tiledb_attribute_t.cs b/sources/TileDB.CSharp/Interop/tiledb_attribute_t.cs index 8fbcb379..1f2fd94a 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_attribute_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_attribute_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_attribute_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_attribute_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_config_iter_t.cs b/sources/TileDB.CSharp/Interop/tiledb_config_iter_t.cs index 82bae077..b3d56456 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_config_iter_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_config_iter_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_config_iter_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_config_iter_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_config_t.cs b/sources/TileDB.CSharp/Interop/tiledb_config_t.cs index 2aed2874..96028ce4 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_config_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_config_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_config_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_config_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_ctx_t.cs b/sources/TileDB.CSharp/Interop/tiledb_ctx_t.cs index 2f85340b..fa79c90d 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_ctx_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_ctx_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_ctx_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_ctx_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_datatype_t.cs b/sources/TileDB.CSharp/Interop/tiledb_datatype_t.cs index 2d699b8f..b9d04e93 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_datatype_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_datatype_t.cs @@ -2,7 +2,7 @@ namespace TileDB.Interop { - internal enum tiledb_datatype_t + public enum tiledb_datatype_t { TILEDB_INT32 = 0, TILEDB_INT64 = 1, diff --git a/sources/TileDB.CSharp/Interop/tiledb_dimension_t.cs b/sources/TileDB.CSharp/Interop/tiledb_dimension_t.cs index 9bd83817..2e6b4810 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_dimension_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_dimension_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_dimension_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_dimension_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_domain_t.cs b/sources/TileDB.CSharp/Interop/tiledb_domain_t.cs index 7f452823..37300e31 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_domain_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_domain_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_domain_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_domain_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_filter_list_t.cs b/sources/TileDB.CSharp/Interop/tiledb_filter_list_t.cs index 863bd8cf..2f6f888f 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_filter_list_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_filter_list_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_filter_list_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_filter_list_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_filter_t.cs b/sources/TileDB.CSharp/Interop/tiledb_filter_t.cs index b0e96e82..f7d7ff77 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_filter_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_filter_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_filter_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_filter_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_filter_type_t.cs b/sources/TileDB.CSharp/Interop/tiledb_filter_type_t.cs index dfced45f..749a8ad0 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_filter_type_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_filter_type_t.cs @@ -2,7 +2,7 @@ namespace TileDB.Interop { - internal enum tiledb_filter_type_t + public enum tiledb_filter_type_t { TILEDB_FILTER_NONE = 0, TILEDB_FILTER_GZIP = 1, diff --git a/sources/TileDB.CSharp/Interop/tiledb_group_t.cs b/sources/TileDB.CSharp/Interop/tiledb_group_t.cs index e0f44057..70553720 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_group_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_group_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_group_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_group_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_query_condition_t.cs b/sources/TileDB.CSharp/Interop/tiledb_query_condition_t.cs index 75b882fb..80146f30 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_query_condition_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_query_condition_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_query_condition_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_query_condition_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_query_t.cs b/sources/TileDB.CSharp/Interop/tiledb_query_t.cs index f789f361..d4394468 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_query_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_query_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_query_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_query_t { } } diff --git a/sources/TileDB.CSharp/Interop/tiledb_query_type_t.cs b/sources/TileDB.CSharp/Interop/tiledb_query_type_t.cs index 21fa4db6..c917e8a7 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_query_type_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_query_type_t.cs @@ -2,7 +2,7 @@ namespace TileDB.Interop { - internal enum tiledb_query_type_t + public enum tiledb_query_type_t { TILEDB_READ = 0, TILEDB_WRITE = 1, diff --git a/sources/TileDB.CSharp/Interop/tiledb_vfs_t.cs b/sources/TileDB.CSharp/Interop/tiledb_vfs_t.cs index 49275ccf..af349707 100644 --- a/sources/TileDB.CSharp/Interop/tiledb_vfs_t.cs +++ b/sources/TileDB.CSharp/Interop/tiledb_vfs_t.cs @@ -1,8 +1,14 @@ // +using System.ComponentModel; +using System; +using TileDB.CSharp; + namespace TileDB.Interop { - internal partial struct tiledb_vfs_t + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public partial struct tiledb_vfs_t { } } diff --git a/sources/TileDB.CSharp/Marshalling/MarshaledString.cs b/sources/TileDB.CSharp/Marshalling/MarshaledString.cs index 4bebefa4..428d437e 100644 --- a/sources/TileDB.CSharp/Marshalling/MarshaledString.cs +++ b/sources/TileDB.CSharp/Marshalling/MarshaledString.cs @@ -1,13 +1,17 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System; +using System.ComponentModel; using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; +using TileDB.CSharp; namespace TileDB.Interop { - internal unsafe struct MarshaledString : IDisposable + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe struct MarshaledString : IDisposable { public MarshaledString(string input) { @@ -15,7 +19,7 @@ public MarshaledString(string input) Value = (sbyte*)ptr; } - public static (IntPtr Pointer, int Length) AllocNullTerminated(string str) + internal static (IntPtr Pointer, int Length) AllocNullTerminated(string str) { if (str is null) { @@ -30,7 +34,9 @@ public static (IntPtr Pointer, int Length) AllocNullTerminated(string str) return ((IntPtr)ptr, length); } - public static void FreeNullTerminated(IntPtr ptr) => Marshal.FreeHGlobal(ptr); + internal static void FreeNullTerminated(IntPtr ptr) => Marshal.FreeHGlobal(ptr); + + public ReadOnlySpan AsSpan() => new ReadOnlySpan(Value, Length); public int Length { get; private set; } diff --git a/sources/TileDB.CSharp/Marshalling/MarshaledStringOut.cs b/sources/TileDB.CSharp/Marshalling/MarshaledStringOut.cs index 1e6eb41e..4850c2b7 100644 --- a/sources/TileDB.CSharp/Marshalling/MarshaledStringOut.cs +++ b/sources/TileDB.CSharp/Marshalling/MarshaledStringOut.cs @@ -1,18 +1,36 @@ using System; +using System.ComponentModel; using System.Text; using TileDB.CSharp; namespace TileDB.Interop { - internal static class MarshaledStringOut + [Obsolete(Obsoletions.TileDBInteropMessage, DiagnosticId = Obsoletions.TileDBInteropDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class LibC { + // public struct handle_t {} + // [DllImport(LibDllImport.LibCPath)] + // public static extern void free(void* p); + } + + [Obsolete(Obsoletions.TileDBInterop2Message, DiagnosticId = Obsoletions.TileDBInterop2DiagId, UrlFormat = Obsoletions.SharedUrlFormat)] + [EditorBrowsable(EditorBrowsableState.Never)] + public unsafe class MarshaledStringOut + { + public sbyte* Value; + public MarshaledStringOut() + { + Value = null; + } + /// /// Encodes a read-only span of bytes into a string, using the default encoding. /// - public static string GetString(ReadOnlySpan span) => - Encoding.UTF8.GetString(span); + internal static string GetString(ReadOnlySpan span) => + Encoding.ASCII.GetString(span); - public static string GetString(ReadOnlySpan span, DataType dataType) => + internal static string GetString(ReadOnlySpan span, DataType dataType) => dataType switch { DataType.StringAscii => Encoding.ASCII.GetString(span), @@ -25,7 +43,7 @@ public static string GetString(ReadOnlySpan span, DataType dataType) => /// /// Encodes a null-terminated pointer of bytes into a string, using the default encoding. /// - public static unsafe string GetStringFromNullTerminated(sbyte* ptr) + internal static unsafe string GetStringFromNullTerminated(sbyte* ptr) { if (ptr == null) { @@ -36,5 +54,7 @@ public static unsafe string GetStringFromNullTerminated(sbyte* ptr) span = span[0..span.IndexOf((byte)0)]; return GetString(span); } + + public static implicit operator string(MarshaledStringOut s) => GetStringFromNullTerminated(s.Value); } } diff --git a/sources/TileDB.CSharp/Obsoletions.cs b/sources/TileDB.CSharp/Obsoletions.cs index 400419ba..33850a81 100644 --- a/sources/TileDB.CSharp/Obsoletions.cs +++ b/sources/TileDB.CSharp/Obsoletions.cs @@ -38,5 +38,8 @@ internal static class Obsoletions public const string QuerySubarrayMessage = "Subarray-related methods of the Query class are obsolete and will become unavailable in a future version."; public const string QuerySubarrayDiagId = "TILEDB0011"; + + public const string TileDBInterop2Message = "Members of the TileDB.Interop namespace should not be used by user code and will become internal in a future version."; + public const string TileDBInterop2DiagId = "TILEDB0012"; } } diff --git a/sources/TileDB.CSharp/Query.cs b/sources/TileDB.CSharp/Query.cs index 9f7d9530..800d3ce0 100644 --- a/sources/TileDB.CSharp/Query.cs +++ b/sources/TileDB.CSharp/Query.cs @@ -7,6 +7,8 @@ using System.Text; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using QueryHandle = TileDB.CSharp.Marshalling.SafeHandles.QueryHandle; +using ConfigHandle = TileDB.CSharp.Marshalling.SafeHandles.ConfigHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/QueryCondition.cs b/sources/TileDB.CSharp/QueryCondition.cs index 2bfb4886..f12cc4c0 100644 --- a/sources/TileDB.CSharp/QueryCondition.cs +++ b/sources/TileDB.CSharp/QueryCondition.cs @@ -1,6 +1,7 @@ using System; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using QueryConditionHandle = TileDB.CSharp.Marshalling.SafeHandles.QueryConditionHandle; namespace TileDB.CSharp { diff --git a/sources/TileDB.CSharp/TileDB.CSharp.csproj b/sources/TileDB.CSharp/TileDB.CSharp.csproj index d066dde8..01330c29 100644 --- a/sources/TileDB.CSharp/TileDB.CSharp.csproj +++ b/sources/TileDB.CSharp/TileDB.CSharp.csproj @@ -1,4 +1,4 @@ - + net5.0 @@ -12,6 +12,7 @@ true true 5.6.0 + $(NoWarn);TILEDB0012 diff --git a/sources/TileDB.CSharp/VFS.cs b/sources/TileDB.CSharp/VFS.cs index 66054314..8782a49e 100644 --- a/sources/TileDB.CSharp/VFS.cs +++ b/sources/TileDB.CSharp/VFS.cs @@ -6,6 +6,8 @@ using System.Runtime.InteropServices; using TileDB.CSharp.Marshalling.SafeHandles; using TileDB.Interop; +using ConfigHandle = TileDB.CSharp.Marshalling.SafeHandles.ConfigHandle; +using VFSHandle = TileDB.CSharp.Marshalling.SafeHandles.VFSHandle; namespace TileDB.CSharp {