diff --git a/appveyor.yml b/appveyor.yml
index 7793c15dc..56f84c117 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -12,20 +12,20 @@ for:
- image: Ubuntu2204
install:
- - sh: sudo apt-get update && sudo apt-get install -y dotnet-sdk-7.0=7.0.403-1
+ - sh: sudo apt-get update && sudo apt-get install -y dotnet-sdk-8.0=8.0.100-1
before_build:
- sh: mkdir artifacts -p
build_script:
- echo build
- - dotnet build Renci.SshNet.sln -c Debug -f net7.0
+ - dotnet build Renci.SshNet.sln -c Debug -f net8.0
test_script:
- sh: echo "Run unit tests"
- - sh: dotnet test -f net7.0 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_unit_test_net_7_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_unit_test_net_7_coverage.xml test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
+ - sh: dotnet test -f net8.0 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_unit_test_net_8_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_unit_test_net_8_coverage.xml test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
- sh: echo "Run integration tests"
- - sh: dotnet test -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_integration_test_net_7_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_integration_test_net_7_coverage.xml test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
+ - sh: dotnet test -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_integration_test_net_8_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_integration_test_net_8_coverage.xml test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
# on_failure:
# - sh: appveyor PushArtifact artifacts/tcpdump.pcap
@@ -36,7 +36,7 @@ for:
- image: Visual Studio 2022
install:
- - ps: choco install dotnet-7.0-sdk --version=7.0.403
+ - ps: choco install dotnet-8.0-sdk --version=8.0.100
before_build:
- ps: mkdir artifacts -f
@@ -46,8 +46,8 @@ for:
- dotnet build Renci.SshNet.sln -c Debug
test_script:
- - ps: echo "Run unit tests for .NET 7.0"
- - ps: dotnet test -f net7.0 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=windows_unit_test_net_7_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/windows_unit_test_net_7_coverage.xml test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
+ - ps: echo "Run unit tests for .NET 8.0"
+ - ps: dotnet test -f net8.0 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=windows_unit_test_net_8_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/windows_unit_test_net_8_coverage.xml test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
- ps: echo "Run unit tests for .NET Framework 4.6.2"
- ps: dotnet test -f net462 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=windows_unit_test_net_4_6_2_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/windows_unit_test_net_4_6_2_coverage.xml test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
diff --git a/build/nuget/SSH.NET.nuspec b/build/nuget/SSH.NET.nuspec
index 55ce42e28..fec2d2fcf 100644
--- a/build/nuget/SSH.NET.nuspec
+++ b/build/nuget/SSH.NET.nuspec
@@ -29,6 +29,9 @@
+
+
+
-
\ No newline at end of file
+
diff --git a/global.json b/global.json
index 44da40565..d07970ac2 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "7.0.403",
+ "version": "8.0.100",
"rollForward": "latestMajor"
}
-}
\ No newline at end of file
+}
diff --git a/src/Renci.SshNet/Common/SshData.cs b/src/Renci.SshNet/Common/SshData.cs
index 9cbf4fd95..4e7ff0438 100644
--- a/src/Renci.SshNet/Common/SshData.cs
+++ b/src/Renci.SshNet/Common/SshData.cs
@@ -158,10 +158,14 @@ protected byte[] ReadBytes(int length)
var data = new byte[length];
var bytesRead = _stream.Read(data, 0, length);
+#if NET8_0_OR_GREATER
+ ArgumentOutOfRangeException.ThrowIfGreaterThan(length, bytesRead);
+#else
if (bytesRead < length)
{
throw new ArgumentOutOfRangeException(nameof(length));
}
+#endif
return data;
}
diff --git a/src/Renci.SshNet/Renci.SshNet.csproj b/src/Renci.SshNet/Renci.SshNet.csproj
index 89e82349d..824ff52a7 100644
--- a/src/Renci.SshNet/Renci.SshNet.csproj
+++ b/src/Renci.SshNet/Renci.SshNet.csproj
@@ -2,14 +2,14 @@
false
Renci.SshNet
- net462;netstandard2.0;netstandard2.1;net6.0;net7.0
+ net462;netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0
$(DefineConstants);FEATURE_BINARY_SERIALIZATION;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_DNS_SYNC;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_RIPEMD160
-
+
@@ -17,7 +17,7 @@
-
+
$(DefineConstants);FEATURE_SOCKET_TAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_EAP;FEATURE_DNS_SYNC;FEATURE_DNS_APM;FEATURE_DNS_TAP
diff --git a/src/Renci.SshNet/Sftp/SftpFileStream.cs b/src/Renci.SshNet/Sftp/SftpFileStream.cs
index 03b9e088f..7880ffbbd 100644
--- a/src/Renci.SshNet/Sftp/SftpFileStream.cs
+++ b/src/Renci.SshNet/Sftp/SftpFileStream.cs
@@ -519,6 +519,10 @@ public override int Read(byte[] buffer, int offset, int count)
throw new ArgumentNullException(nameof(buffer));
}
+#if NET8_0_OR_GREATER
+ ArgumentOutOfRangeException.ThrowIfNegative(offset);
+ ArgumentOutOfRangeException.ThrowIfNegative(count);
+#else
if (offset < 0)
{
throw new ArgumentOutOfRangeException(nameof(offset));
@@ -528,7 +532,7 @@ public override int Read(byte[] buffer, int offset, int count)
{
throw new ArgumentOutOfRangeException(nameof(count));
}
-
+#endif
if ((buffer.Length - offset) < count)
{
throw new ArgumentException("Invalid array range.");
@@ -660,6 +664,10 @@ public override async Task ReadAsync(byte[] buffer, int offset, int count,
throw new ArgumentNullException(nameof(buffer));
}
+#if NET8_0_OR_GREATER
+ ArgumentOutOfRangeException.ThrowIfNegative(offset);
+ ArgumentOutOfRangeException.ThrowIfNegative(count);
+#else
if (offset < 0)
{
throw new ArgumentOutOfRangeException(nameof(offset));
@@ -669,7 +677,7 @@ public override async Task ReadAsync(byte[] buffer, int offset, int count,
{
throw new ArgumentOutOfRangeException(nameof(count));
}
-
+#endif
if ((buffer.Length - offset) < count)
{
throw new ArgumentException("Invalid array range.");
@@ -951,10 +959,14 @@ public override long Seek(long offset, SeekOrigin origin)
///
public override void SetLength(long value)
{
+#if NET8_0_OR_GREATER
+ ArgumentOutOfRangeException.ThrowIfNegative(value);
+#else
if (value < 0)
{
throw new ArgumentOutOfRangeException(nameof(value));
}
+#endif
// Lock down the file stream while we do this.
lock (_lock)
@@ -1005,6 +1017,10 @@ public override void Write(byte[] buffer, int offset, int count)
throw new ArgumentNullException(nameof(buffer));
}
+#if NET8_0_OR_GREATER
+ ArgumentOutOfRangeException.ThrowIfNegative(offset);
+ ArgumentOutOfRangeException.ThrowIfNegative(count);
+#else
if (offset < 0)
{
throw new ArgumentOutOfRangeException(nameof(offset));
@@ -1014,7 +1030,7 @@ public override void Write(byte[] buffer, int offset, int count)
{
throw new ArgumentOutOfRangeException(nameof(count));
}
-
+#endif
if ((buffer.Length - offset) < count)
{
throw new ArgumentException("Invalid array range.");
@@ -1104,6 +1120,10 @@ public override async Task WriteAsync(byte[] buffer, int offset, int count, Canc
throw new ArgumentNullException(nameof(buffer));
}
+#if NET8_0_OR_GREATER
+ ArgumentOutOfRangeException.ThrowIfNegative(offset);
+ ArgumentOutOfRangeException.ThrowIfNegative(count);
+#else
if (offset < 0)
{
throw new ArgumentOutOfRangeException(nameof(offset));
@@ -1113,7 +1133,7 @@ public override async Task WriteAsync(byte[] buffer, int offset, int count, Canc
{
throw new ArgumentOutOfRangeException(nameof(count));
}
-
+#endif
if ((buffer.Length - offset) < count)
{
throw new ArgumentException("Invalid array range.");
diff --git a/test/Renci.SshNet.Benchmarks/Renci.SshNet.Benchmarks.csproj b/test/Renci.SshNet.Benchmarks/Renci.SshNet.Benchmarks.csproj
index 3f1186f39..eee47fcf7 100644
--- a/test/Renci.SshNet.Benchmarks/Renci.SshNet.Benchmarks.csproj
+++ b/test/Renci.SshNet.Benchmarks/Renci.SshNet.Benchmarks.csproj
@@ -1,7 +1,7 @@
Exe
- net7.0
+ net8.0
enable
enable
diff --git a/test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj b/test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
index 6abe36e6a..40f0d3a08 100644
--- a/test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
+++ b/test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
@@ -1,7 +1,7 @@
- net7.0
+ net8.0
enable
false
true
diff --git a/test/Renci.SshNet.TestTools.OpenSSH/Renci.SshNet.TestTools.OpenSSH.csproj b/test/Renci.SshNet.TestTools.OpenSSH/Renci.SshNet.TestTools.OpenSSH.csproj
index 26ab725ef..6efdde6c1 100644
--- a/test/Renci.SshNet.TestTools.OpenSSH/Renci.SshNet.TestTools.OpenSSH.csproj
+++ b/test/Renci.SshNet.TestTools.OpenSSH/Renci.SshNet.TestTools.OpenSSH.csproj
@@ -1,6 +1,6 @@
- net7.0
+ net8.0
enable
enable
$(NoWarn);SYSLIB0021;SYSLIB1045
diff --git a/test/Renci.SshNet.Tests/Classes/BaseClientTest_Connected_KeepAliveInterval_NotNegativeOne.cs b/test/Renci.SshNet.Tests/Classes/BaseClientTest_Connected_KeepAliveInterval_NotNegativeOne.cs
index 2afb84609..f3650976a 100644
--- a/test/Renci.SshNet.Tests/Classes/BaseClientTest_Connected_KeepAliveInterval_NotNegativeOne.cs
+++ b/test/Renci.SshNet.Tests/Classes/BaseClientTest_Connected_KeepAliveInterval_NotNegativeOne.cs
@@ -56,12 +56,12 @@ protected override void Act()
{
_client.KeepAliveInterval = _keepAliveInterval;
- // allow keep-alive to be sent a few times. .NET 7 is faster and
+ // allow keep-alive to be sent a few times. .NET 8 is faster and
// we need to wait less because we want exactly three messages in a session.
#if NETFRAMEWORK
Thread.Sleep(195);
#else
- Thread.Sleep(180);
+ Thread.Sleep(170);
#endif
}
diff --git a/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj b/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
index 19f08f14b..43db2f5ef 100644
--- a/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
+++ b/test/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
@@ -1,6 +1,6 @@
- net462;net6.0;net7.0
+ net462;net6.0;net7.0;net8.0