Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build with .NET 9.0 SDK #1427

Merged
merged 3 commits into from
Jun 16, 2024
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
71 changes: 36 additions & 35 deletions test/Renci.SshNet.IntegrationTests/SftpTests.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void GetBytes()
Assert.AreEqual((uint)size, sshDataStream.ReadUInt32());

var actualData = new byte[size];
sshDataStream.Read(actualData, 0, size);
_ = sshDataStream.Read(actualData, 0, size);
Assert.IsTrue(actualData.SequenceEqual(data.Take(offset, size)));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ public void GetBytes()
Assert.AreEqual((uint)target.ChannelType.Length, actualChannelTypeLength);

var actualChannelType = new byte[actualChannelTypeLength];
sshDataStream.Read(actualChannelType, 0, (int)actualChannelTypeLength);
_ = sshDataStream.Read(actualChannelType, 0, (int)actualChannelTypeLength);
Assert.IsTrue(target.ChannelType.SequenceEqual(actualChannelType));

Assert.AreEqual(localChannelNumber, sshDataStream.ReadUInt32());
Assert.AreEqual(initialWindowSize, sshDataStream.ReadUInt32());
Assert.AreEqual(maximumPacketSize, sshDataStream.ReadUInt32());

var actualInfo = new byte[infoBytes.Length];
sshDataStream.Read(actualInfo, 0, actualInfo.Length);
_ = sshDataStream.Read(actualInfo, 0, actualInfo.Length);
Assert.IsTrue(infoBytes.SequenceEqual(actualInfo));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void GetBytes()
Assert.AreEqual((uint)_data.Length, sshDataStream.ReadUInt32());

var actualData = new byte[_data.Length];
sshDataStream.Read(actualData, 0, actualData.Length);
_ = sshDataStream.Read(actualData, 0, actualData.Length);
Assert.IsTrue(_data.SequenceEqual(actualData));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ private static RsaKey GetRsaKey(string fileName, string passPhrase = null)
// This is just to line up any differences in the assertion message.
private static void AssertEqual(byte[] actualBytes, string expectedHex)
{
#if NET
string actualHex = Convert.ToHexString(actualBytes);
#else
string actualHex = BitConverter.ToString(actualBytes).Replace("-", "");
#endif

Assert.AreEqual(expectedHex, actualHex,
$"{Environment.NewLine}Expected: {expectedHex}{Environment.NewLine} Actual: {actualHex}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ public void GetBytes()
Assert.AreEqual((uint)_nameBytes.Length, sshDataStream.ReadUInt32());

var actualNameBytes = new byte[_nameBytes.Length];
sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
_ = sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));

Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());

var actualHandle = new byte[_handle.Length];
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
_ = sshDataStream.Read(actualHandle, 0, actualHandle.Length);
Assert.IsTrue(_handle.SequenceEqual(actualHandle));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@ public void GetBytes()
Assert.AreEqual((uint)_nameBytes.Length, sshDataStream.ReadUInt32());

var actualNameBytes = new byte[_nameBytes.Length];
sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
_ = sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));

Assert.AreEqual((uint)_oldPathBytes.Length, sshDataStream.ReadUInt32());

var actualOldPath = new byte[_oldPathBytes.Length];
sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
_ = sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
Assert.IsTrue(_oldPathBytes.SequenceEqual(actualOldPath));

Assert.AreEqual((uint)_newPathBytes.Length, sshDataStream.ReadUInt32());

var actualNewPath = new byte[_newPathBytes.Length];
sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
_ = sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
Assert.IsTrue(_newPathBytes.SequenceEqual(actualNewPath));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ public void GetBytes()
Assert.AreEqual((uint)_nameBytes.Length, sshDataStream.ReadUInt32());

var actualNameBytes = new byte[_nameBytes.Length];
sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
_ = sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));

Assert.AreEqual((uint)_oldPathBytes.Length, sshDataStream.ReadUInt32());

var actualOldPath = new byte[_oldPathBytes.Length];
sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
_ = sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
Assert.IsTrue(_oldPathBytes.SequenceEqual(actualOldPath));

Assert.AreEqual((uint)_newPathBytes.Length, sshDataStream.ReadUInt32());

var actualNewPath = new byte[_newPathBytes.Length];
sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
_ = sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
Assert.IsTrue(_newPathBytes.SequenceEqual(actualNewPath));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ public void GetBytes()
Assert.AreEqual((uint)_nameBytes.Length, sshDataStream.ReadUInt32());

var actualNameBytes = new byte[_nameBytes.Length];
sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
_ = sshDataStream.Read(actualNameBytes, 0, actualNameBytes.Length);
Assert.IsTrue(_nameBytes.SequenceEqual(actualNameBytes));

Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());

var actualPath = new byte[_pathBytes.Length];
sshDataStream.Read(actualPath, 0, actualPath.Length);
_ = sshDataStream.Read(actualPath, 0, actualPath.Length);
Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void GetBytes()

Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
var actualHandle = new byte[_handle.Length];
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
_ = sshDataStream.Read(actualHandle, 0, actualHandle.Length);
Assert.IsTrue(_handle.SequenceEqual(actualHandle));

Assert.AreEqual(_offset, sshDataStream.ReadUInt64());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void GetBytes()

Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
var actualHandle = new byte[_handle.Length];
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
_ = sshDataStream.Read(actualHandle, 0, actualHandle.Length);
Assert.IsTrue(_handle.SequenceEqual(actualHandle));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public void GetBytes()

Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
var actualHandle = new byte[_handle.Length];
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
_ = sshDataStream.Read(actualHandle, 0, actualHandle.Length);
Assert.IsTrue(_handle.SequenceEqual(actualHandle));

var actualAttributes = new byte[_attributesBytes.Length];
sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
_ = sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void GetBytes()

Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
var actualHandle = new byte[_handle.Length];
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
_ = sshDataStream.Read(actualHandle, 0, actualHandle.Length);
Assert.IsTrue(_handle.SequenceEqual(actualHandle));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void GetBytes()

Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());
var actualPath = new byte[_pathBytes.Length];
sshDataStream.Read(actualPath, 0, actualPath.Length);
_ = sshDataStream.Read(actualPath, 0, actualPath.Length);
Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ public void GetBytes()

Assert.AreEqual((uint)_newLinkPathBytes.Length, sshDataStream.ReadUInt32());
var actualNewLinkPath = new byte[_newLinkPathBytes.Length];
sshDataStream.Read(actualNewLinkPath, 0, actualNewLinkPath.Length);
_ = sshDataStream.Read(actualNewLinkPath, 0, actualNewLinkPath.Length);
Assert.IsTrue(_newLinkPathBytes.SequenceEqual(actualNewLinkPath));

Assert.AreEqual((uint)_existingPathBytes.Length, sshDataStream.ReadUInt32());
var actualExistingPath = new byte[_existingPathBytes.Length];
sshDataStream.Read(actualExistingPath, 0, actualExistingPath.Length);
_ = sshDataStream.Read(actualExistingPath, 0, actualExistingPath.Length);
Assert.IsTrue(_existingPathBytes.SequenceEqual(actualExistingPath));

Assert.AreEqual(1, sshDataStream.ReadByte());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ public void GetBytes()

Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());
var actualPath = new byte[_pathBytes.Length];
sshDataStream.Read(actualPath, 0, actualPath.Length);
_ = sshDataStream.Read(actualPath, 0, actualPath.Length);
Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));

var actualAttributes = new byte[_attributesBytes.Length];
sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
_ = sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void GetBytes()

Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());
var actualPath = new byte[_pathBytes.Length];
sshDataStream.Read(actualPath, 0, actualPath.Length);
_ = sshDataStream.Read(actualPath, 0, actualPath.Length);
Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ public void GetBytes()

Assert.AreEqual((uint)_filenameBytes.Length, sshDataStream.ReadUInt32());
var actualPath = new byte[_filenameBytes.Length];
sshDataStream.Read(actualPath, 0, actualPath.Length);
_ = sshDataStream.Read(actualPath, 0, actualPath.Length);
Assert.IsTrue(_filenameBytes.SequenceEqual(actualPath));

Assert.AreEqual((uint)_flags, sshDataStream.ReadUInt32());

var actualAttributes = new byte[_attributesBytes.Length];
sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
_ = sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void GetBytes()

Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
var actualHandle = new byte[_handle.Length];
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
_ = sshDataStream.Read(actualHandle, 0, actualHandle.Length);
Assert.IsTrue(_handle.SequenceEqual(actualHandle));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void GetBytes()

Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());
var actualPath = new byte[_pathBytes.Length];
sshDataStream.Read(actualPath, 0, actualPath.Length);
_ = sshDataStream.Read(actualPath, 0, actualPath.Length);
Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void GetBytes()

Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
var actualHandle = new byte[_handle.Length];
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
_ = sshDataStream.Read(actualHandle, 0, actualHandle.Length);
Assert.IsTrue(_handle.SequenceEqual(actualHandle));

Assert.AreEqual(_offset, sshDataStream.ReadUInt64());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void GetBytes()

Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());
var actualPath = new byte[_pathBytes.Length];
sshDataStream.Read(actualPath, 0, actualPath.Length);
_ = sshDataStream.Read(actualPath, 0, actualPath.Length);
Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void GetBytes()

Assert.AreEqual((uint)_filenameBytes.Length, sshDataStream.ReadUInt32());
var actualFilename = new byte[_filenameBytes.Length];
sshDataStream.Read(actualFilename, 0, actualFilename.Length);
_ = sshDataStream.Read(actualFilename, 0, actualFilename.Length);
Assert.IsTrue(_filenameBytes.SequenceEqual(actualFilename));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ public void GetBytes()

Assert.AreEqual((uint)_oldPathBytes.Length, sshDataStream.ReadUInt32());
var actualOldPath = new byte[_oldPathBytes.Length];
sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
_ = sshDataStream.Read(actualOldPath, 0, actualOldPath.Length);
Assert.IsTrue(_oldPathBytes.SequenceEqual(actualOldPath));

Assert.AreEqual((uint)_newPathBytes.Length, sshDataStream.ReadUInt32());
var actualNewPath = new byte[_newPathBytes.Length];
sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
_ = sshDataStream.Read(actualNewPath, 0, actualNewPath.Length);
Assert.IsTrue(_newPathBytes.SequenceEqual(actualNewPath));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ public void GetBytes()

Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());
var actualPath = new byte[_pathBytes.Length];
sshDataStream.Read(actualPath, 0, actualPath.Length);
_ = sshDataStream.Read(actualPath, 0, actualPath.Length);
Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));

var actualAttributes = new byte[_attributesBytes.Length];
sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
_ = sshDataStream.Read(actualAttributes, 0, actualAttributes.Length);
Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void GetBytes()

Assert.AreEqual((uint)_pathBytes.Length, sshDataStream.ReadUInt32());
var actualPath = new byte[_pathBytes.Length];
sshDataStream.Read(actualPath, 0, actualPath.Length);
_ = sshDataStream.Read(actualPath, 0, actualPath.Length);
Assert.IsTrue(_pathBytes.SequenceEqual(actualPath));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ public void GetBytes()

Assert.AreEqual((uint)_newLinkPathBytes.Length, sshDataStream.ReadUInt32());
var actualNewLinkPath = new byte[_newLinkPathBytes.Length];
sshDataStream.Read(actualNewLinkPath, 0, actualNewLinkPath.Length);
_ = sshDataStream.Read(actualNewLinkPath, 0, actualNewLinkPath.Length);
Assert.IsTrue(_newLinkPathBytes.SequenceEqual(actualNewLinkPath));

Assert.AreEqual((uint)_existingPathBytes.Length, sshDataStream.ReadUInt32());
var actualExistingPath = new byte[_existingPathBytes.Length];
sshDataStream.Read(actualExistingPath, 0, actualExistingPath.Length);
_ = sshDataStream.Read(actualExistingPath, 0, actualExistingPath.Length);
Assert.IsTrue(_existingPathBytes.SequenceEqual(actualExistingPath));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ public void GetBytes()

Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32());
var actualHandle = new byte[_handle.Length];
sshDataStream.Read(actualHandle, 0, actualHandle.Length);
_ = sshDataStream.Read(actualHandle, 0, actualHandle.Length);
Assert.IsTrue(_handle.SequenceEqual(actualHandle));

Assert.AreEqual(_serverFileOffset, sshDataStream.ReadUInt64());

Assert.AreEqual((uint)_length, sshDataStream.ReadUInt32());
var actualData = new byte[_length];
sshDataStream.Read(actualData, 0, actualData.Length);
_ = sshDataStream.Read(actualData, 0, actualData.Length);
Assert.IsTrue(_data.Take(_offset, _length).SequenceEqual(actualData));

Assert.IsTrue(sshDataStream.IsEndOfData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void ReadShouldThrowNotSupportedException()

try
{
_target.Read(buffer, 0, buffer.Length);
_ = _target.Read(buffer, 0, buffer.Length);
Assert.Fail();
}
catch (NotSupportedException ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void ReadShouldThrowNotSupportedException()

try
{
_target.Read(buffer, 0, buffer.Length);
_ = _target.Read(buffer, 0, buffer.Length);
Assert.Fail();
}
catch (NotSupportedException ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void ReadShouldThrowNotSupportedException()

try
{
_target.Read(buffer, 0, buffer.Length);
_ = _target.Read(buffer, 0, buffer.Length);
Assert.Fail();
}
catch (NotSupportedException ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void ReadShouldThrowNotSupportedException()

try
{
_target.Read(buffer, 0, buffer.Length);
_ = _target.Read(buffer, 0, buffer.Length);
Assert.Fail();
}
catch (NotSupportedException ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void ReadShouldThrowNotSupportedException()

try
{
_target.Read(buffer, 0, buffer.Length);
_ = _target.Read(buffer, 0, buffer.Length);
Assert.Fail();
}
catch (NotSupportedException ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void ReadShouldThrowNotSupportedException()

try
{
_target.Read(buffer, 0, buffer.Length);
_ = _target.Read(buffer, 0, buffer.Length);
Assert.Fail();
}
catch (NotSupportedException ex)
Expand Down
Loading