This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 643b9e307 chore(bindings/dotnet): update framework and use
LibraryImport (#7222)
643b9e307 is described below
commit 643b9e30772ea9842e68477a638a63e6a828fe2c
Author: Fatorin <[email protected]>
AuthorDate: Tue Feb 24 16:35:34 2026 +0800
chore(bindings/dotnet): update framework and use LibraryImport (#7222)
---
.github/workflows/ci_bindings_dotnet.yml | 37 ++++++++++++++--
bindings/dotnet/Cargo.toml | 51 +++++++++++++++++++++-
.../DotOpenDAL.Tests/DotOpenDAL.Tests.csproj | 4 +-
bindings/dotnet/DotOpenDAL/BlockingOperator.cs | 26 +++--------
bindings/dotnet/DotOpenDAL/DotOpenDAL.csproj | 18 +++++---
bindings/dotnet/README.md | 2 +-
bindings/dotnet/dotnet.sln | 22 ----------
bindings/dotnet/dotnet.slnx | 4 ++
8 files changed, 110 insertions(+), 54 deletions(-)
diff --git a/.github/workflows/ci_bindings_dotnet.yml
b/.github/workflows/ci_bindings_dotnet.yml
index 1ff0c1a5c..5ef5c6101 100644
--- a/.github/workflows/ci_bindings_dotnet.yml
+++ b/.github/workflows/ci_bindings_dotnet.yml
@@ -40,24 +40,55 @@ permissions:
contents: read
jobs:
- test:
+ check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup dotnet toolchain
uses: actions/setup-dotnet@v5
with:
- dotnet-version: '7.0.x'
+ dotnet-version: '10.0.x'
- name: Setup Rust toolchain
uses: ./.github/actions/setup
+ with:
+ need-nextest: true
+ need-protoc: true
+ need-rocksdb: true
+ github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Clippy Check
working-directory: "bindings/dotnet"
run: |
cargo clippy -- -D warnings
+ test:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os:
+ - ubuntu-latest
+ - macos-latest
+ - windows-latest
+ dotnet-version:
+ - '8.0.x'
+ - '10.0.x'
+ steps:
+ - uses: actions/checkout@v6
+ - name: Setup dotnet toolchain
+ uses: actions/setup-dotnet@v5
+ with:
+ dotnet-version: ${{ matrix.dotnet-version }}
+ - name: Setup Rust toolchain
+ uses: ./.github/actions/setup
+ with:
+ need-nextest: true
+ need-protoc: true
+ need-rocksdb: true
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+
- name: Build & Test
working-directory: "bindings/dotnet"
run: |
cargo build
- dotnet test
+ dotnet test -f ${{ matrix.dotnet-version == '8.0.x' && 'net8.0' ||
'net10.0' }}
diff --git a/bindings/dotnet/Cargo.toml b/bindings/dotnet/Cargo.toml
index fc716a9bf..88956e7c6 100644
--- a/bindings/dotnet/Cargo.toml
+++ b/bindings/dotnet/Cargo.toml
@@ -34,8 +34,16 @@ doc = false
# this crate won't be published, we always use the local version
opendal = { version = ">=0", path = "../../core", features = [
"blocking",
+ "reqwest-rustls-tls",
+ "executors-tokio",
- # These are default features before v0.46. TODO: change to optional features
+ # enabled layers
+ "layers-concurrent-limit",
+ "layers-logging",
+ "layers-retry",
+ "layers-timeout",
+
+ # enabled services
"services-azblob",
"services-azdls",
"services-cos",
@@ -50,6 +58,45 @@ opendal = { version = ">=0", path = "../../core", features =
[
"services-s3",
"services-webdav",
"services-webhdfs",
+ "services-aliyun-drive",
+ "services-cacache",
+ "services-dashmap",
+ "services-dropbox",
+ "services-etcd",
+ # FIXME this requires a preinstalled fdb library
+ # "services-foundationdb",
+ # FIXME requires openssl.
+ # "services-ftp",
+ "services-gdrive",
+ # FIXME how to support HDFS services in bindings?
+ # "services-hdfs",
+ # "services-hdfs-native",
+ "services-hf",
+ "services-ipfs",
+ "services-memcached",
+ "services-mini-moka",
+ "services-moka",
+ "services-onedrive",
+ "services-persy",
+ "services-postgresql",
+ "services-koofr",
+ "services-mysql",
+ "services-redb",
+ "services-redis",
+ # FIXME: rocksdb will lead to "cannot allocate memory in static TLS block"
while linking.
+ # "services-rocksdb",
+ "services-sled",
+ "services-tikv",
+ "services-vercel-artifacts",
+ "services-mongodb",
+ "services-gridfs",
+ "services-sqlite",
"services-azfile",
+ "services-swift",
+ "services-alluxio",
+ "services-b2",
+ "services-seafile",
+ "services-upyun",
+ "services-yandex-disk",
] }
-tokio = { version = "1", features = ["full"] }
+tokio = { version = "1.49.0", features = ["full"] }
diff --git a/bindings/dotnet/DotOpenDAL.Tests/DotOpenDAL.Tests.csproj
b/bindings/dotnet/DotOpenDAL.Tests/DotOpenDAL.Tests.csproj
index 7209d89b2..0efccf26f 100644
--- a/bindings/dotnet/DotOpenDAL.Tests/DotOpenDAL.Tests.csproj
+++ b/bindings/dotnet/DotOpenDAL.Tests/DotOpenDAL.Tests.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net7.0</TargetFramework>
+ <TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@@ -13,7 +13,7 @@
<ProjectReference Include="../DotOpenDAL/DotOpenDAL.csproj" />
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers;
buildtransitive</IncludeAssets>
diff --git a/bindings/dotnet/DotOpenDAL/BlockingOperator.cs
b/bindings/dotnet/DotOpenDAL/BlockingOperator.cs
index 9404e581d..8ec4da78b 100644
--- a/bindings/dotnet/DotOpenDAL/BlockingOperator.cs
+++ b/bindings/dotnet/DotOpenDAL/BlockingOperator.cs
@@ -22,7 +22,7 @@ using System.Runtime.InteropServices;
namespace DotOpenDAL;
-public class BlockingOperator
+public partial class BlockingOperator
{
public IntPtr Op { get; }
@@ -41,24 +41,12 @@ public class BlockingOperator
return blocking_operator_read(Op, path);
}
- [DllImport(
- "opendal_dotnet",
- EntryPoint = "blocking_operator_construct",
- CallingConvention = CallingConvention.Cdecl,
- CharSet = CharSet.Auto)]
- private static extern IntPtr blocking_operator_construct(string scheme);
+ [LibraryImport("opendal_dotnet", EntryPoint =
"blocking_operator_construct", StringMarshalling = StringMarshalling.Utf8)]
+ private static partial IntPtr blocking_operator_construct(string scheme);
- [DllImport(
- "opendal_dotnet",
- EntryPoint = "blocking_operator_write",
- CallingConvention = CallingConvention.Cdecl,
- CharSet = CharSet.Auto)]
- private static extern void blocking_operator_write(IntPtr op, string path,
string content);
+ [LibraryImport("opendal_dotnet", EntryPoint = "blocking_operator_write",
StringMarshalling = StringMarshalling.Utf8)]
+ private static partial void blocking_operator_write(IntPtr op, string
path, string content);
- [DllImport(
- "opendal_dotnet",
- EntryPoint = "blocking_operator_read",
- CallingConvention = CallingConvention.Cdecl,
- CharSet = CharSet.Auto)]
- private static extern string blocking_operator_read(IntPtr op, string
path);
+ [LibraryImport("opendal_dotnet", EntryPoint = "blocking_operator_read",
StringMarshalling = StringMarshalling.Utf8)]
+ private static partial string blocking_operator_read(IntPtr op, string
path);
}
diff --git a/bindings/dotnet/DotOpenDAL/DotOpenDAL.csproj
b/bindings/dotnet/DotOpenDAL/DotOpenDAL.csproj
index 5c7b03821..bf72c21c6 100644
--- a/bindings/dotnet/DotOpenDAL/DotOpenDAL.csproj
+++ b/bindings/dotnet/DotOpenDAL/DotOpenDAL.csproj
@@ -11,16 +11,24 @@
<Copyright>$(Company)</Copyright>
<PackageTags>Apache;OpenDAL</PackageTags>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
-
- <TargetFramework>net7.0</TargetFramework>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
- <None Include="../target/debug/libopendal_dotnet.*">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ <!-- Linux/macOS -->
+ <None Include="../target/debug/libopendal_dotnet.*"
+ Condition="'$(OS)' != 'Windows_NT'">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+
+ <!-- Windows -->
+ <None Include="../target/debug/opendal_dotnet.dll"
+ Condition="'$(OS)' == 'Windows_NT'">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/bindings/dotnet/README.md b/bindings/dotnet/README.md
index a44424cb3..1968686e8 100644
--- a/bindings/dotnet/README.md
+++ b/bindings/dotnet/README.md
@@ -10,7 +10,7 @@ This binding is currently under development. Please check
back later.
To compile OpenDAL .NET binding from source code, you need:
-- [.NET](https://dotnet.microsoft.com/en-us/download/dotnet) version 7.0
+- [.NET](https://dotnet.microsoft.com/en-us/download/dotnet) version 10.0
```bash
cargo build
diff --git a/bindings/dotnet/dotnet.sln b/bindings/dotnet/dotnet.sln
deleted file mode 100644
index 4325aa65a..000000000
--- a/bindings/dotnet/dotnet.sln
+++ /dev/null
@@ -1,22 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotOpenDAL",
"DotOpenDAL\DotOpenDAL.csproj", "{9DE3EBDB-D64A-4432-89A6-AB6BC1183935}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotOpenDAL.Tests",
"DotOpenDAL.Tests\DotOpenDAL.Tests.csproj",
"{060008AD-FEAD-49B8-97D0-3EFDC2505315}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {9DE3EBDB-D64A-4432-89A6-AB6BC1183935}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
- {9DE3EBDB-D64A-4432-89A6-AB6BC1183935}.Debug|Any CPU.Build.0 =
Debug|Any CPU
- {9DE3EBDB-D64A-4432-89A6-AB6BC1183935}.Release|Any
CPU.ActiveCfg = Release|Any CPU
- {9DE3EBDB-D64A-4432-89A6-AB6BC1183935}.Release|Any CPU.Build.0
= Release|Any CPU
- {060008AD-FEAD-49B8-97D0-3EFDC2505315}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
- {060008AD-FEAD-49B8-97D0-3EFDC2505315}.Debug|Any CPU.Build.0 =
Debug|Any CPU
- {060008AD-FEAD-49B8-97D0-3EFDC2505315}.Release|Any
CPU.ActiveCfg = Release|Any CPU
- {060008AD-FEAD-49B8-97D0-3EFDC2505315}.Release|Any CPU.Build.0
= Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/bindings/dotnet/dotnet.slnx b/bindings/dotnet/dotnet.slnx
new file mode 100644
index 000000000..97a5f7497
--- /dev/null
+++ b/bindings/dotnet/dotnet.slnx
@@ -0,0 +1,4 @@
+<Solution>
+ <Project Path="DotOpenDAL.Tests/DotOpenDAL.Tests.csproj" />
+ <Project Path="DotOpenDAL/DotOpenDAL.csproj" />
+</Solution>