Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions .github/workflows/main-push-nuget-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,9 @@ jobs:
name: native-osx-arm64
path: cas-dotnet-sdk/artifacts/native/osx-arm64

native-macos-x64:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: dtolnay/rust-toolchain@stable

- name: Build Rust (macOS x64)
working-directory: cas-core-lib
run: cargo build --release

- name: Stage native
run: |
mkdir -p cas-dotnet-sdk/artifacts/native/osx-x64
cp cas-core-lib/target/release/libcas_core_lib.dylib cas-dotnet-sdk/artifacts/native/osx-x64/

- uses: actions/upload-artifact@v4
with:
name: native-osx-x64
path: cas-dotnet-sdk/artifacts/native/osx-x64

pack-and-publish:
runs-on: ubuntu-latest
needs: [native-windows, native-linux, native-macos-arm64, native-macos-x64]
needs: [native-windows, native-linux, native-macos-arm64]

steps:
- uses: actions/checkout@v4
Expand All @@ -125,18 +102,12 @@ jobs:
name: native-osx-arm64
path: cas-dotnet-sdk/artifacts/native/osx-arm64

- uses: actions/download-artifact@v4
with:
name: native-osx-x64
path: cas-dotnet-sdk/artifacts/native/osx-x64

- name: Verify staged natives
run: |
ls -R cas-dotnet-sdk/artifacts/native
test -f cas-dotnet-sdk/artifacts/native/linux-x64/libcas_core_lib.so
test -f cas-dotnet-sdk/artifacts/native/win-x64/cas_core_lib.dll
test -f cas-dotnet-sdk/artifacts/native/osx-arm64/libcas_core_lib.dylib
test -f cas-dotnet-sdk/artifacts/native/osx-x64/libcas_core_lib.dylib

- uses: actions/setup-dotnet@v4
with:
Expand Down
57 changes: 0 additions & 57 deletions .github/workflows/pr-tests-macos-x64.yml

This file was deleted.

4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dotnet test ./cas-dotnet-sdk-tests/cas-dotnet-sdk-tests.csproj -f net8.0 --filte
dotnet test ./cas-dotnet-sdk-tests/cas-dotnet-sdk-tests.csproj -f net8.0 --filter "DisplayName~Hash512"
```

The same commands work for local development on macOS: a Rust toolchain on PATH builds `libcas_core_lib.dylib`, and the `StageRustArtifacts` MSBuild target detects the host (Apple Silicon vs Intel) and stages it into `artifacts/native/osx-arm64/` or `artifacts/native/osx-x64/` automatically — no extra flags needed.
The same commands work for local development on macOS (Apple Silicon): a Rust toolchain on PATH builds `libcas_core_lib.dylib`, and the `StageRustArtifacts` MSBuild target stages it into `artifacts/native/osx-arm64/` automatically — no extra flags needed.

Note: CI (`.github/workflows/pr-tests-*.yml`) builds `cargo build --release` separately, then copies the native lib into the test `bin/Release/<tfm>` directory before running `dotnet test`. If you build the Rust lib by hand and the MSBuild target is skipped, the native artifact must end up next to the test assembly the same way.

Expand Down Expand Up @@ -69,6 +69,6 @@ Categories with interchangeable algorithms expose a `*Factory` (e.g. `HasherFact

## Cross-platform constraint

Supported targets: **Windows x64**, **Linux x64**, and **macOS** (both `osx-arm64` Apple Silicon and `osx-x64` Intel). Since the csbindgen migration (#191), P/Invoke goes through the generated `generated/NativeMethods.g.cs` using the bare library name `cas_core_lib`; the .NET runtime resolves it per-OS to `cas_core_lib.dll` / `libcas_core_lib.so` / `libcas_core_lib.dylib`, so there are no per-platform `[DllImport]` files to keep in sync. The native lib is built (`cargo build --release`), staged into `artifacts/native/<rid>/`, and packed into `runtimes/<rid>/native` for each RID. Tests run against .NET 6–10 on all three OSes in CI on every PR: `pr-tests-windows` and `pr-tests-linux` fan out one job per TFM, while macOS is split by architecture into two separate workflows — `pr-tests-macos-arm64` (`macos-latest`, Apple Silicon) and `pr-tests-macos-x64` (`macos-13`, Intel) — each running all five target frameworks in a single `dotnet test` invocation (no `-f`). The `OperatingSystemDeterminator` resolves Windows, Linux, and OSX and throws on anything else.
Supported targets: **Windows x64**, **Linux x64**, and **macOS Apple Silicon** (`osx-arm64`). Intel macs (`osx-x64`) are intentionally not supported — the Intel runners were too slow for this project's CI. Since the csbindgen migration (#191), P/Invoke goes through the generated `generated/NativeMethods.g.cs` using the bare library name `cas_core_lib`; the .NET runtime resolves it per-OS to `cas_core_lib.dll` / `libcas_core_lib.so` / `libcas_core_lib.dylib`, so there are no per-platform `[DllImport]` files to keep in sync. The native lib is built (`cargo build --release`), staged into `artifacts/native/<rid>/`, and packed into `runtimes/<rid>/native` for each RID. Tests run against .NET 6–10 on all three OSes in CI on every PR: `pr-tests-windows` and `pr-tests-linux` fan out one job per TFM, while `pr-tests-macos-arm64` (`macos-latest`, Apple Silicon) runs all five target frameworks in a single `dotnet test` invocation (no `-f`). The `OperatingSystemDeterminator` resolves Windows, Linux, and OSX and throws on anything else.

Note: this is desktop **macOS / Darwin**, not iOS. Real iOS (`aarch64-apple-ios`) would need a cross-compiled native lib and a simulator/device to run tests, neither of which the current CI provides.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CAS .NET SDK is a comprehensive cryptographic toolkit for .NET, designed to prov
- Seamless integration with [cas-lib](https://github.com/Cryptographic-API-Services/cas-lib) Rust FFI layer for optimal performance
- Unified interface: no need to manage multiple cryptography packages or surf disparate documentation
- Built on trusted, open-source cryptography libraries
- Cross-platform support: Windows x64, Linux x64, macOS (Apple Silicon arm64 & Intel x64)
- Cross-platform support: Windows x64, Linux x64, macOS (Apple Silicon arm64)
- Multi-framework support: .NET 6, 7, 8, 9, 10

## Documentation & References
Expand All @@ -35,7 +35,6 @@ We aim to provide cross-compatibility wherever possible. Test cases are run on .
- [X] Windows x64
- [X] Linux x64
- [X] macOS arm64 (Apple Silicon)
- [X] macOS x64 (Intel)

## Disclaimer
This SDK leverages several cryptographic crates via our core FFI [layer](https://github.com/Cryptographic-API-Services/cas-core-lib). Please note that many of these crates have not undergone formal security audits. Use this library at your own risk and always review the underlying cryptographic implementations for your security requirements.
Expand Down
2 changes: 1 addition & 1 deletion cas-core-lib
Submodule cas-core-lib updated 1 files
+1 −1 Cargo.toml
3 changes: 1 addition & 2 deletions cas-dotnet-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CAS .NET SDK is a comprehensive cryptographic toolkit for .NET, designed to prov
- Seamless integration with [cas-lib](https://github.com/Cryptographic-API-Services/cas-lib) Rust FFI layer for optimal performance
- Unified interface: no need to manage multiple cryptography packages or surf disparate documentation
- Built on trusted, open-source cryptography libraries
- Cross-platform support: Windows x64, Linux x64, macOS (Apple Silicon arm64 & Intel x64)
- Cross-platform support: Windows x64, Linux x64, macOS (Apple Silicon arm64)
- Multi-framework support: .NET 6, 7, 8, 9, 10

## Documentation & References
Expand All @@ -35,7 +35,6 @@ We aim to provide cross-compatibility wherever possible. Test cases are run on .
- [X] Windows x64
- [X] Linux x64
- [X] macOS arm64 (Apple Silicon)
- [X] macOS x64 (Intel)

## Disclaimer
This SDK leverages several cryptographic crates via our core FFI [layer](https://github.com/Cryptographic-API-Services/cas-core-lib). Please note that many of these crates have not undergone formal security audits. Use this library at your own risk and always review the underlying cryptographic implementations for your security requirements.
Expand Down
14 changes: 2 additions & 12 deletions cas-dotnet-sdk/cas-dotnet-sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,17 @@
<PropertyGroup>
<!-- $(OS) is 'Unix' on both Linux and macOS, so distinguish macOS explicitly. -->
<_IsOSX>$([MSBuild]::IsOSPlatform('OSX'))</_IsOSX>
<!-- Host arch -> RID suffix (Arm64 -> arm64, X64 -> x64) so a dev build on
Apple Silicon stages osx-arm64 and an Intel Mac stages osx-x64. -->
<_HostArch>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</_HostArch>
</PropertyGroup>

<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
<_RustOut Include="$(RustProjectDir)\target\release\cas_core_lib.dll" />
<_DestDir Include="$(NativeArtifactsDir)/win-x64/" />
</ItemGroup>

<!-- macOS support is Apple Silicon (osx-arm64) only. -->
<ItemGroup Condition="'$(_IsOSX)' == 'true'">
<_RustOut Include="$(RustProjectDir)/target/release/libcas_core_lib.dylib" />
<_DestDir Include="$(NativeArtifactsDir)/osx-$(_HostArch)/" />
<_DestDir Include="$(NativeArtifactsDir)/osx-arm64/" />
</ItemGroup>

<ItemGroup Condition="'$(OS)' != 'Windows_NT' AND '$(_IsOSX)' != 'true'">
Expand Down Expand Up @@ -92,14 +90,6 @@
<Link>libcas_core_lib.dylib</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

<None Include="$(NativeArtifactsDir)\osx-x64\libcas_core_lib.dylib"
Condition="Exists('$(NativeArtifactsDir)\osx-x64\libcas_core_lib.dylib')">
<Pack>true</Pack>
<PackagePath>runtimes\osx-x64\native</PackagePath>
<Link>libcas_core_lib.dylib</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<!--
Expand Down
Loading