diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8e393d8..bfe7c94 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index bfe190b..8a3aac6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@  - 1.0.0-rc.2 + 1.0.0-rc.3 bitc0der Copyright 2024 © bitc0der bitc0der diff --git a/README.md b/README.md index b6ef12b..de86262 100644 --- a/README.md +++ b/README.md @@ -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) { @@ -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) { diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..a750d01 Binary files /dev/null and b/logo.png differ diff --git a/src/StreamTools.Benchmarks/StreamTools.Benchmarks.csproj b/src/BitSoft.StreamTools.Benchmarks/BitSoft.StreamTools.Benchmarks.csproj similarity index 78% rename from src/StreamTools.Benchmarks/StreamTools.Benchmarks.csproj rename to src/BitSoft.StreamTools.Benchmarks/BitSoft.StreamTools.Benchmarks.csproj index ac24ae8..104f6fd 100644 --- a/src/StreamTools.Benchmarks/StreamTools.Benchmarks.csproj +++ b/src/BitSoft.StreamTools.Benchmarks/BitSoft.StreamTools.Benchmarks.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/StreamTools.Benchmarks/Program.cs b/src/BitSoft.StreamTools.Benchmarks/Program.cs similarity index 100% rename from src/StreamTools.Benchmarks/Program.cs rename to src/BitSoft.StreamTools.Benchmarks/Program.cs diff --git a/src/StreamTools.Benchmarks/README.md b/src/BitSoft.StreamTools.Benchmarks/README.md similarity index 100% rename from src/StreamTools.Benchmarks/README.md rename to src/BitSoft.StreamTools.Benchmarks/README.md diff --git a/src/StreamTools.Benchmarks/StringBufferBenchmark.cs b/src/BitSoft.StreamTools.Benchmarks/StringBufferBenchmark.cs similarity index 88% rename from src/StreamTools.Benchmarks/StringBufferBenchmark.cs rename to src/BitSoft.StreamTools.Benchmarks/StringBufferBenchmark.cs index e3a63d4..042c0a7 100644 --- a/src/StreamTools.Benchmarks/StringBufferBenchmark.cs +++ b/src/BitSoft.StreamTools.Benchmarks/StringBufferBenchmark.cs @@ -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] diff --git a/src/StreamTools.Benchmarks/StringStreamReadBenchmark.cs b/src/BitSoft.StreamTools.Benchmarks/StringStreamReadBenchmark.cs similarity index 92% rename from src/StreamTools.Benchmarks/StringStreamReadBenchmark.cs rename to src/BitSoft.StreamTools.Benchmarks/StringStreamReadBenchmark.cs index 93eed5b..38f9ae1 100644 --- a/src/StreamTools.Benchmarks/StringStreamReadBenchmark.cs +++ b/src/BitSoft.StreamTools.Benchmarks/StringStreamReadBenchmark.cs @@ -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] diff --git a/src/StreamTools.Benchmarks/StringStreamWriteBenchmark.cs b/src/BitSoft.StreamTools.Benchmarks/StringStreamWriteBenchmark.cs similarity index 92% rename from src/StreamTools.Benchmarks/StringStreamWriteBenchmark.cs rename to src/BitSoft.StreamTools.Benchmarks/StringStreamWriteBenchmark.cs index 3e3e1c0..da9ffbb 100644 --- a/src/StreamTools.Benchmarks/StringStreamWriteBenchmark.cs +++ b/src/BitSoft.StreamTools.Benchmarks/StringStreamWriteBenchmark.cs @@ -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] diff --git a/src/StreamTools.Benchmarks/Utils/CompressExtensions.cs b/src/BitSoft.StreamTools.Benchmarks/Utils/CompressExtensions.cs similarity index 94% rename from src/StreamTools.Benchmarks/Utils/CompressExtensions.cs rename to src/BitSoft.StreamTools.Benchmarks/Utils/CompressExtensions.cs index 49cd748..6d669c2 100644 --- a/src/StreamTools.Benchmarks/Utils/CompressExtensions.cs +++ b/src/BitSoft.StreamTools.Benchmarks/Utils/CompressExtensions.cs @@ -3,7 +3,7 @@ using System.IO.Compression; using System.Text; -namespace StreamTools.Benchmarks.Utils; +namespace BitSoft.StreamTools.Benchmarks.Utils; internal static class CompressExtensions { diff --git a/src/StreamTools.Benchmarks/Utils/Create.cs b/src/BitSoft.StreamTools.Benchmarks/Utils/Create.cs similarity index 84% rename from src/StreamTools.Benchmarks/Utils/Create.cs rename to src/BitSoft.StreamTools.Benchmarks/Utils/Create.cs index dbe3652..caa3add 100644 --- a/src/StreamTools.Benchmarks/Utils/Create.cs +++ b/src/BitSoft.StreamTools.Benchmarks/Utils/Create.cs @@ -1,7 +1,7 @@ using System; using System.Text; -namespace StreamTools.Benchmarks.Utils; +namespace BitSoft.StreamTools.Benchmarks.Utils; internal static class Create { @@ -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++) diff --git a/src/StreamTools.Tests/StreamTools.Tests.csproj b/src/BitSoft.StreamTools.Tests/BitSoft.StreamTools.Tests.csproj similarity index 81% rename from src/StreamTools.Tests/StreamTools.Tests.csproj rename to src/BitSoft.StreamTools.Tests/BitSoft.StreamTools.Tests.csproj index be5f24c..5110eb3 100644 --- a/src/StreamTools.Tests/StreamTools.Tests.csproj +++ b/src/BitSoft.StreamTools.Tests/BitSoft.StreamTools.Tests.csproj @@ -7,13 +7,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -21,7 +21,7 @@ - + diff --git a/src/StreamTools.Tests/BufferTests.cs b/src/BitSoft.StreamTools.Tests/BufferTests.cs similarity index 92% rename from src/StreamTools.Tests/BufferTests.cs rename to src/BitSoft.StreamTools.Tests/BufferTests.cs index 7c60e69..726af27 100644 --- a/src/StreamTools.Tests/BufferTests.cs +++ b/src/BitSoft.StreamTools.Tests/BufferTests.cs @@ -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 diff --git a/src/StreamTools.Tests/StringStreamTests.cs b/src/BitSoft.StreamTools.Tests/StringStreamTests.cs similarity index 88% rename from src/StreamTools.Tests/StringStreamTests.cs rename to src/BitSoft.StreamTools.Tests/StringStreamTests.cs index e3c11c0..c71cdfb 100644 --- a/src/StreamTools.Tests/StringStreamTests.cs +++ b/src/BitSoft.StreamTools.Tests/StringStreamTests.cs @@ -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 { @@ -237,5 +237,29 @@ public void Should_Throw_When_WriteMode() Assert.Throws(() => 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(); } \ No newline at end of file diff --git a/src/StreamTools.sln b/src/BitSoft.StreamTools.sln similarity index 82% rename from src/StreamTools.sln rename to src/BitSoft.StreamTools.sln index 871a2ce..e959185 100644 --- a/src/StreamTools.sln +++ b/src/BitSoft.StreamTools.sln @@ -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 @@ -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 diff --git a/src/StreamTools/StreamTools.csproj b/src/BitSoft.StreamTools/BitSoft.StreamTools.csproj similarity index 82% rename from src/StreamTools/StreamTools.csproj rename to src/BitSoft.StreamTools/BitSoft.StreamTools.csproj index 734266e..48fa272 100644 --- a/src/StreamTools/StreamTools.csproj +++ b/src/BitSoft.StreamTools/BitSoft.StreamTools.csproj @@ -2,7 +2,6 @@ net8 - BitSoft.StreamTools @@ -10,12 +9,14 @@ BitSoft.StreamTools StreamTools: high perfomance streaming tool Yet another one library with .NET streaming helpers. - README.md stream;string;performance;memory;cache; + README.md + logo.png + \ No newline at end of file diff --git a/src/StreamTools/Buffers/ArrayStringBuffer.cs b/src/BitSoft.StreamTools/Buffers/ArrayStringBuffer.cs similarity index 97% rename from src/StreamTools/Buffers/ArrayStringBuffer.cs rename to src/BitSoft.StreamTools/Buffers/ArrayStringBuffer.cs index a89acb4..0c9cd94 100644 --- a/src/StreamTools/Buffers/ArrayStringBuffer.cs +++ b/src/BitSoft.StreamTools/Buffers/ArrayStringBuffer.cs @@ -3,7 +3,7 @@ using System.Runtime.CompilerServices; using System.Text; -namespace StreamTools.Buffers; +namespace BitSoft.StreamTools.Buffers; public class ArrayStringBuffer : IStringBuffer { diff --git a/src/StreamTools/Buffers/IStringBuffer.cs b/src/BitSoft.StreamTools/Buffers/IStringBuffer.cs similarity index 79% rename from src/StreamTools/Buffers/IStringBuffer.cs rename to src/BitSoft.StreamTools/Buffers/IStringBuffer.cs index be86617..09054c6 100644 --- a/src/StreamTools/Buffers/IStringBuffer.cs +++ b/src/BitSoft.StreamTools/Buffers/IStringBuffer.cs @@ -1,6 +1,6 @@ using System; -namespace StreamTools.Buffers; +namespace BitSoft.StreamTools.Buffers; public interface IStringBuffer : IDisposable { diff --git a/src/StreamTools/Buffers/MemoryStringBuffer.cs b/src/BitSoft.StreamTools/Buffers/MemoryStringBuffer.cs similarity index 97% rename from src/StreamTools/Buffers/MemoryStringBuffer.cs rename to src/BitSoft.StreamTools/Buffers/MemoryStringBuffer.cs index 371a5be..1125740 100644 --- a/src/StreamTools/Buffers/MemoryStringBuffer.cs +++ b/src/BitSoft.StreamTools/Buffers/MemoryStringBuffer.cs @@ -3,7 +3,7 @@ using System.Runtime.CompilerServices; using System.Text; -namespace StreamTools.Buffers; +namespace BitSoft.StreamTools.Buffers; public class MemoryStringBuffer : IStringBuffer { diff --git a/src/StreamTools/Buffers/StringBuilderBuffer.cs b/src/BitSoft.StreamTools/Buffers/StringBuilderBuffer.cs similarity index 96% rename from src/StreamTools/Buffers/StringBuilderBuffer.cs rename to src/BitSoft.StreamTools/Buffers/StringBuilderBuffer.cs index 7894390..c8e1404 100644 --- a/src/StreamTools/Buffers/StringBuilderBuffer.cs +++ b/src/BitSoft.StreamTools/Buffers/StringBuilderBuffer.cs @@ -2,7 +2,7 @@ using System.Buffers; using System.Text; -namespace StreamTools.Buffers; +namespace BitSoft.StreamTools.Buffers; public sealed class StringBuilderBuffer : IStringBuffer { diff --git a/src/StreamTools/README.md b/src/BitSoft.StreamTools/README.md similarity index 96% rename from src/StreamTools/README.md rename to src/BitSoft.StreamTools/README.md index 8f75395..4f4e3fa 100644 --- a/src/StreamTools/README.md +++ b/src/BitSoft.StreamTools/README.md @@ -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) { @@ -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) { diff --git a/src/StreamTools/StringStream.cs b/src/BitSoft.StreamTools/StringStream.cs similarity index 98% rename from src/StreamTools/StringStream.cs rename to src/BitSoft.StreamTools/StringStream.cs index d8dfcd1..cfc2762 100644 --- a/src/StreamTools/StringStream.cs +++ b/src/BitSoft.StreamTools/StringStream.cs @@ -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 { @@ -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;