Skip to content

Commit

Permalink
Merge pull request #14 from petertsu/upgrade
Browse files Browse the repository at this point in the history
Support .NetStandard 2.0
  • Loading branch information
petertsu authored Feb 23, 2024
2 parents f97f176 + 3709e12 commit 15a6bcd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 29 deletions.
5 changes: 3 additions & 2 deletions 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,12 +19,13 @@
<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>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup>
</Project>
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
16 changes: 8 additions & 8 deletions tests/ClamAV.Net.Tests/ClamAV.Net.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.8.1">
<PackageReference Include="coverlet.msbuild" Version="6.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.2.1">
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
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 15a6bcd

Please sign in to comment.