Skip to content

Commit 8e2ec85

Browse files
committed
Add support for .NET 8.0 and conditional threading enhancements
- Update project to target both .NET 8.0 and .NET 9.0. - Introduce conditional `Lock` and `object` usage based on framework version. - Improve `README.md` with updated badges and links. - Adjust NuGet dependency visibility with `PrivateAssets="All"`.
1 parent 0f7622e commit 8e2ec85

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

NullOpsDevs.LibSsh/Core/SshSession.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ namespace NullOpsDevs.LibSsh.Core;
1919
public sealed class SshSession : IDisposable
2020
{
2121
private static bool libraryInitialized;
22+
23+
#if NET9_0_OR_GREATER
2224
private readonly Lock localLock = new();
25+
#else
26+
private readonly object localLock = new();
27+
#endif
2328

2429
private Socket? socket;
2530
private unsafe _LIBSSH2_SESSION* session;

NullOpsDevs.LibSsh/Interop/LibSsh2.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ public static class LibSsh2
1717
/// <summary>
1818
/// Gets the global lock used for thread-safe library initialization.
1919
/// </summary>
20+
#if NET9_0_OR_GREATER
2021
public static readonly Lock GlobalLock = new();
22+
#else
23+
public static readonly object GlobalLock = new();
24+
#endif
2125

2226
/// <summary>
2327
/// Gets or sets the global logger action for libssh2 operations.

NullOpsDevs.LibSsh/NullOpsDevs.LibSsh.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8+
<LangVersion>latest</LangVersion>
89

910
<!-- NuGet Package Settings -->
1011
<PackageId>NullOpsDevs.LibSsh</PackageId>
@@ -78,11 +79,11 @@
7879
</Content>
7980
</ItemGroup>
8081
<ItemGroup>
81-
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2" />
82+
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2" PrivateAssets="All" />
8283
</ItemGroup>
8384

8485
<ItemGroup>
85-
<InternalsVisibleTo Include="NullOpsDevs.LibSsh.Test" />
86+
<InternalsVisibleTo Include="NullOpsDevs.LibSsh.Test" />
8687
</ItemGroup>
8788

8889
</Project>

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
A modern, cross-platform .NET library providing managed bindings for libssh2, enabling SSH operations including remote command execution, SCP file transfers, and advanced terminal (PTY) features.
44

55
[![NuGet](https://img.shields.io/badge/nuget-1.0.0-blue.svg)](https://www.nuget.org/packages/NullOpsDevs.LibSsh/)
6-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7+
[![.NET](https://img.shields.io/badge/.NET-8.0-purple.svg)](https://dotnet.microsoft.com/)
78
[![.NET](https://img.shields.io/badge/.NET-9.0-purple.svg)](https://dotnet.microsoft.com/)
89

910
## Features

0 commit comments

Comments
 (0)