Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ jobs:
- name: Pack
run: dotnet pack ./src -c Release -o "./nupkgs"
- name: Publish
run: dotnet nuget push "./*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
run: dotnet nuget push "./*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
working-directory: nupkgs
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.0.0-rc.2</VersionPrefix>
<VersionPrefix>1.0.0-rc.3</VersionPrefix>
<Authors>bitc0der</Authors>
<Copyright>Copyright 2024 © bitc0der</Copyright>
<Company>bitc0der</Company>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ using Stream outputStream = StringStream.Write();

For example, generate stream from a string value to compress with gZip:
```csharp
using StreamTools;
using System.IO.Compression;
using BitSoft.StreamTools;

public static byte[] Compress(string source)
{
Expand All @@ -51,8 +51,8 @@ public static byte[] Compress(string source)
Decompress an input stream with gZip and convert it to a string value:

```csharp
using StreamTools;
using System.IO.Compression;
using BitSoft.StreamTools;

public static string Decompress(Stream sourceStream)
{
Expand Down
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\StreamTools\StreamTools.csproj" />
<ProjectReference Include="..\BitSoft.StreamTools\BitSoft.StreamTools.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Text;
using BenchmarkDotNet.Attributes;
using StreamTools.Benchmarks.Utils;
using StreamTools.Buffers;
using BitSoft.StreamTools.Benchmarks.Utils;
using BitSoft.StreamTools.Buffers;

namespace StreamTools.Benchmarks;
namespace BitSoft.StreamTools.Benchmarks;

[ShortRunJob]
[MemoryDiagnoser]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.IO.Compression;
using System.Text;
using BenchmarkDotNet.Attributes;
using StreamTools.Benchmarks.Utils;
using BitSoft.StreamTools.Benchmarks.Utils;

namespace StreamTools.Benchmarks;
namespace BitSoft.StreamTools.Benchmarks;

[ShortRunJob]
[MemoryDiagnoser]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.IO;
using System.Text;
using BenchmarkDotNet.Attributes;
using StreamTools.Benchmarks.Utils;
using BitSoft.StreamTools.Benchmarks.Utils;

namespace StreamTools.Benchmarks;
namespace BitSoft.StreamTools.Benchmarks;

[ShortRunJob]
[MemoryDiagnoser]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO.Compression;
using System.Text;

namespace StreamTools.Benchmarks.Utils;
namespace BitSoft.StreamTools.Benchmarks.Utils;

internal static class CompressExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Text;

namespace StreamTools.Benchmarks.Utils;
namespace BitSoft.StreamTools.Benchmarks.Utils;

internal static class Create
{
Expand All @@ -21,8 +21,8 @@ public static byte[] Buffer(int length)
{
var result = new byte[length];

const int min = (int)'a';
const int max = (int)'z';
const int min = 'a';
const int max = 'z';

var random = new Random();
for (var i = 0; i < length; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" >
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit.Analyzers" >
<PackageReference Include="NUnit.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\StreamTools\StreamTools.csproj" />
<ProjectReference Include="..\BitSoft.StreamTools\BitSoft.StreamTools.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using StreamTools.Buffers;
using System;
using System;
using System.Collections.Generic;
using System.Text;
using BitSoft.StreamTools.Buffers;

namespace StreamTools.Tests;
namespace BitSoft.StreamTools.Tests;

[TestFixture]
public sealed class BufferTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace StreamTools.Tests;
namespace BitSoft.StreamTools.Tests;

public class StringStreamTests
{
Expand Down Expand Up @@ -237,5 +237,29 @@ public void Should_Throw_When_WriteMode()
Assert.Throws<InvalidOperationException>(() => stream.Position = 1);
}

[TestCase("Source", true, 16)]
[TestCase("Source", false, 16)]
[TestCase("a", true, 16)]
[TestCase("a", false, 16)]
[TestCase("String with smile 😀", true, 16)]
[TestCase("String with smile 😀", false, 16)]
public async Task Should_ReturnSameString(string source, bool async, int bufferSize)
{
// Arrange
using var read = StringStream.Read(source);
using var write = StringStream.Write();

// Act
if (async)
await read.CopyToAsync(write, bufferSize: bufferSize);
else
read.CopyTo(write, bufferSize: bufferSize);

// Assert
var result = write.GetString();

Assert.That(result, Is.EqualTo(source));
}

private static string CreateString() => Guid.NewGuid().ToString();
}
6 changes: 3 additions & 3 deletions src/StreamTools.sln → src/BitSoft.StreamTools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreamTools", "StreamTools\StreamTools.csproj", "{9CCEE64A-A4B3-4893-A850-C71760ADADF6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BitSoft.StreamTools", "BitSoft.StreamTools\BitSoft.StreamTools.csproj", "{9CCEE64A-A4B3-4893-A850-C71760ADADF6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreamTools.Tests", "StreamTools.Tests\StreamTools.Tests.csproj", "{99D605A4-FBA8-4E97-A52B-611EB986F944}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BitSoft.StreamTools.Tests", "BitSoft.StreamTools.Tests\BitSoft.StreamTools.Tests.csproj", "{99D605A4-FBA8-4E97-A52B-611EB986F944}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F3B63F0B-9B1D-4C67-B8E9-0885FBCD4809}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -17,7 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreamTools.Benchmarks", "StreamTools.Benchmarks\StreamTools.Benchmarks.csproj", "{416739A8-1E4F-46B9-AD2A-D73E03117FD8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BitSoft.StreamTools.Benchmarks", "BitSoft.StreamTools.Benchmarks\BitSoft.StreamTools.Benchmarks.csproj", "{416739A8-1E4F-46B9-AD2A-D73E03117FD8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{DF7E20F3-9084-4D64-A710-DE33090E7536}"
ProjectSection(SolutionItems) = preProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

<PropertyGroup>
<TargetFramework>net8</TargetFramework>
<AssemblyName>BitSoft.StreamTools</AssemblyName>
</PropertyGroup>

<PropertyGroup>
<IsPackable>true</IsPackable>
<PackageId>BitSoft.StreamTools</PackageId>
<Title>StreamTools: high perfomance streaming tool</Title>
<Description>Yet another one library with .NET streaming helpers.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>stream;string;performance;memory;cache;</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>logo.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
<None Include="$(MSBuildThisFileDirectory)../../logo.png" Pack="true" PackagePath="" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Runtime.CompilerServices;
using System.Text;

namespace StreamTools.Buffers;
namespace BitSoft.StreamTools.Buffers;

public class ArrayStringBuffer : IStringBuffer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace StreamTools.Buffers;
namespace BitSoft.StreamTools.Buffers;

public interface IStringBuffer : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Runtime.CompilerServices;
using System.Text;

namespace StreamTools.Buffers;
namespace BitSoft.StreamTools.Buffers;

public class MemoryStringBuffer : IStringBuffer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Buffers;
using System.Text;

namespace StreamTools.Buffers;
namespace BitSoft.StreamTools.Buffers;

public sealed class StringBuilderBuffer : IStringBuffer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ using Stream outputStream = StringStream.Write();

For example, generate stream from a string value to compress with gZip:
```csharp
using StreamTools;
using System.IO.Compression;
using BitSoft.StreamTools;

public static byte[] Compress(string source)
{
Expand All @@ -39,8 +39,8 @@ public static byte[] Compress(string source)
Decompress an input stream with gZip and convert it to a string value:

```csharp
using StreamTools;
using System.IO.Compression;
using BitSoft.StreamTools;

public static string Decompress(Stream sourceStream)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using StreamTools.Buffers;
using BitSoft.StreamTools.Buffers;

namespace StreamTools;
namespace BitSoft.StreamTools;

public class StringStream : Stream
{
Expand All @@ -23,7 +23,7 @@ public class StringStream : Stream

private int _offset;

public override bool CanRead => _mode == StringStreamMode.Read && _offset < _source.Length - 1;
public override bool CanRead => _mode == StringStreamMode.Read && _offset < _source.Length;
public override bool CanSeek => _mode == StringStreamMode.Read;
public override bool CanWrite => _mode == StringStreamMode.Write;

Expand Down
Loading