Skip to content

Commit

Permalink
upgrade fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
petertsualign committed Feb 23, 2024
1 parent 6ea540d commit 3709e12
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/ClamAV.Net/ClamAV.Net.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFrameworks>netstandard2.1;netstandard2.0;</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>petertsu@github</Authors>
<Product>ClamAV.Net</Product>
Expand All @@ -19,6 +19,7 @@
<Copyright>Copyright 2020 petertsu@github</Copyright>
<Summary>The ClamAV server .NETStandard client</Summary>
<ProjectGuid>4E284927-EFC1-443E-BC27-D598404ACE71</ProjectGuid>
<LangVersion>12.0</LangVersion>
</PropertyGroup>
<PropertyGroup>
<DocumentationFile>ClamAV.Net.xml</DocumentationFile>
Expand Down
4 changes: 4 additions & 0 deletions src/ClamAV.Net/Commands/InStreamCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ public ScanResult ProcessRawResponse(byte[] rawResponse)
new ClamAvException($"Invalid raw response '{actualResponse}'");
}

#if NETSTANDARD2_0
return new ScanResult(true, responseParts[responseParts.Length - 2]);
#else
return new ScanResult(true, responseParts[^2]);
#endif
}
}
}
2 changes: 1 addition & 1 deletion src/ClamAV.Net/Socket/TcpSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task ConnectAsync(CancellationToken cancellationToken = default)

private async Task<byte[]> ReadResponse(CancellationToken cancellationToken)
{
await using MemoryStream memoryStream = new MemoryStream();
using MemoryStream memoryStream = new MemoryStream();

do
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ClamAV.Net.Tests/ClamAV.Net.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
18 changes: 0 additions & 18 deletions tests/ClamAV.Net.Tests/Exceptions/ClamAvExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,5 @@ public void Ctor_Validation()
clamAvException.Message.Should().Be(expectedMessage);
clamAvException.InnerException.Should().NotBeNull();
}

[Fact]
public void Serialization_Test()
{
const string expectedMessage = "Some error";
ClamAvException clamAvException = new ClamAvException(expectedMessage, new Exception("Error"));

BinaryFormatter binaryFormatter = new BinaryFormatter();

using MemoryStream memoryStream = new MemoryStream();
binaryFormatter.Serialize(memoryStream, clamAvException);
memoryStream.Seek(0, SeekOrigin.Begin);

ClamAvException actual = binaryFormatter.Deserialize(memoryStream) as ClamAvException;

actual.Should().NotBeNull();
actual.Should().BeEquivalentTo(clamAvException);
}
}
}

0 comments on commit 3709e12

Please sign in to comment.