Skip to content

Commit 602085c

Browse files
authored
Merge pull request #3 from Shuttle/v20
V20
2 parents 44be980 + 571cf0b commit 602085c

9 files changed

Lines changed: 103 additions & 211 deletions

File tree

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ PM> Install-Package Shuttle.Core.Streams
77
Provides `Stream` extensions.
88

99
``` c#
10-
byte[] ToBytes(this Stream stream)
1110
Task<byte[]> ToBytesAsync(this Stream stream)
1211
```
1312

14-
Returns the given `stream` as a `byte` array.
13+
Returns the given `Stream` as a `byte` array.
1514

1615
``` c#
17-
Stream Copy(this Stream stream)
1816
Task<Stream> CopyAsync(this Stream stream)
1917
```
2018

21-
Creates a copyof the given `stream`. THe copy will be at position 0 and the source `stream` will remain at its original position.
19+
Creates a copy of the given `Stream`. THe copy will be at position 0 and the source `Stream` will remain at its original position.
2220

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
9-
<PackageReference Include="NUnit" Version="3.14.0" />
10-
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
8+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
9+
<PackageReference Include="NUnit" Version="4.2.2" />
10+
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
1111
</ItemGroup>
1212

1313
<ItemGroup>
1414
<ProjectReference Include="..\Shuttle.Core.Streams\Shuttle.Core.Streams.csproj" />
1515
</ItemGroup>
1616

17-
</Project>
17+
</Project>

Shuttle.Core.Streams.Tests/StreamExtensionsFixture.cs

Lines changed: 41 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2,111 +2,59 @@
22
using System.Threading.Tasks;
33
using NUnit.Framework;
44

5-
namespace Shuttle.Core.Streams.Tests
5+
namespace Shuttle.Core.Streams.Tests;
6+
7+
[TestFixture]
8+
public class StreamExtensionsFixture
69
{
7-
[TestFixture]
8-
public class StreamExtensionsFixture
10+
[Test]
11+
public async Task Should_be_able_to_convert_a_stream_to_an_array_of_bytes_async()
912
{
10-
[Test]
11-
public void Should_be_able_to_convert_a_stream_to_an_array_of_bytes()
12-
{
13-
var stream = new MemoryStream(new byte[] {0, 1, 2, 3, 4});
14-
var bytes = stream.ToBytes();
15-
16-
Assert.AreEqual(5, bytes.Length);
17-
Assert.AreEqual(0, bytes[0]);
18-
Assert.AreEqual(4, bytes[4]);
19-
}
20-
21-
[Test]
22-
public async Task Should_be_able_to_convert_a_stream_to_an_array_of_bytes_async()
23-
{
24-
var stream = new MemoryStream(new byte[] {0, 1, 2, 3, 4});
25-
var bytes = await stream.ToBytesAsync();
26-
27-
Assert.AreEqual(5, bytes.Length);
28-
Assert.AreEqual(0, bytes[0]);
29-
Assert.AreEqual(4, bytes[4]);
30-
}
31-
32-
[Test]
33-
public void Should_be_able_to_make_a_copy_of_a_stream()
34-
{
35-
var bytes = new byte[] {0, 1, 2, 3, 4};
36-
var stream = new MemoryStream(bytes);
37-
var output = new MemoryStream();
38-
39-
stream.CopyTo(output);
40-
41-
Assert.AreEqual(5, output.Length);
42-
Assert.AreEqual(5, output.Position);
43-
Assert.AreEqual(5, stream.Position);
44-
45-
var copy = stream.Copy();
46-
47-
Assert.AreEqual(5, copy.Length);
48-
Assert.AreEqual(0, copy.Position);
49-
Assert.AreEqual(5, stream.Position);
50-
}
13+
var stream = new MemoryStream(new byte[] { 0, 1, 2, 3, 4 });
14+
var bytes = await stream.ToBytesAsync();
5115

52-
[Test]
53-
public void Should_be_able_to_make_a_readonly_copy_of_a_stream()
54-
{
55-
var bytes = new byte[] {0, 1, 2, 3, 4};
56-
var stream = new MemoryStream(bytes, 0, bytes.Length, false, true);
57-
var output = new MemoryStream();
58-
59-
stream.CopyTo(output);
60-
61-
Assert.AreEqual(5, output.Length);
62-
Assert.AreEqual(5, output.Position);
63-
Assert.AreEqual(5, stream.Position);
64-
65-
var copy = stream.Copy();
66-
67-
Assert.AreEqual(5, copy.Length);
68-
Assert.AreEqual(0, copy.Position);
69-
Assert.AreEqual(5, stream.Position);
70-
}
16+
Assert.That(bytes.Length, Is.EqualTo(5));
17+
Assert.That(bytes[0], Is.EqualTo(0));
18+
Assert.That(bytes[4], Is.EqualTo(4));
19+
}
7120

72-
[Test]
73-
public async Task Should_be_able_to_make_a_copy_of_a_stream_async()
74-
{
75-
var bytes = new byte[] {0, 1, 2, 3, 4};
76-
var stream = new MemoryStream(bytes);
77-
var output = new MemoryStream();
21+
[Test]
22+
public async Task Should_be_able_to_make_a_copy_of_a_stream_async()
23+
{
24+
var bytes = new byte[] { 0, 1, 2, 3, 4 };
25+
var stream = new MemoryStream(bytes);
26+
var output = new MemoryStream();
7827

79-
await stream.CopyToAsync(output);
28+
await stream.CopyToAsync(output);
8029

81-
Assert.AreEqual(5, output.Length);
82-
Assert.AreEqual(5, output.Position);
83-
Assert.AreEqual(5, stream.Position);
30+
Assert.That(output.Length, Is.EqualTo(5));
31+
Assert.That(output.Position, Is.EqualTo(5));
32+
Assert.That(stream.Position, Is.EqualTo(5));
8433

85-
var copy = await stream.CopyAsync();
34+
var copy = await stream.CopyAsync();
8635

87-
Assert.AreEqual(5, copy.Length);
88-
Assert.AreEqual(0, copy.Position);
89-
Assert.AreEqual(5, stream.Position);
90-
}
36+
Assert.That(copy.Length, Is.EqualTo(5));
37+
Assert.That(copy.Position, Is.EqualTo(0));
38+
Assert.That(stream.Position, Is.EqualTo(5));
39+
}
9140

92-
[Test]
93-
public async Task Should_be_able_to_make_a_readonly_copy_of_a_stream_async()
94-
{
95-
var bytes = new byte[] {0, 1, 2, 3, 4};
96-
var stream = new MemoryStream(bytes, 0, bytes.Length, false, true);
97-
var output = new MemoryStream();
41+
[Test]
42+
public async Task Should_be_able_to_make_a_readonly_copy_of_a_stream_async()
43+
{
44+
var bytes = new byte[] { 0, 1, 2, 3, 4 };
45+
var stream = new MemoryStream(bytes, 0, bytes.Length, false, true);
46+
var output = new MemoryStream();
9847

99-
await stream.CopyToAsync(output);
48+
await stream.CopyToAsync(output);
10049

101-
Assert.AreEqual(5, output.Length);
102-
Assert.AreEqual(5, output.Position);
103-
Assert.AreEqual(5, stream.Position);
50+
Assert.That(output.Length, Is.EqualTo(5));
51+
Assert.That(output.Position, Is.EqualTo(5));
52+
Assert.That(stream.Position, Is.EqualTo(5));
10453

105-
var copy = await stream.CopyAsync();
54+
var copy = await stream.CopyAsync();
10655

107-
Assert.AreEqual(5, copy.Length);
108-
Assert.AreEqual(0, copy.Position);
109-
Assert.AreEqual(5, stream.Position);
110-
}
56+
Assert.That(copy.Length, Is.EqualTo(5));
57+
Assert.That(copy.Position, Is.EqualTo(0));
58+
Assert.That(stream.Position, Is.EqualTo(5));
11159
}
11260
}

Shuttle.Core.Streams/.package/AssemblyInfo.cs.template

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
using System.Reflection;
22
using System.Runtime.InteropServices;
33

4-
#if NETFRAMEWORK
5-
[assembly: AssemblyTitle(".NET Framework")]
6-
#endif
7-
8-
#if NETCOREAPP
9-
[assembly: AssemblyTitle(".NET Core")]
10-
#endif
11-
12-
#if NETSTANDARD
13-
[assembly: AssemblyTitle(".NET Standard")]
14-
#endif
15-
4+
[assembly: AssemblyTitle(".NET Unified Platform")]
165
[assembly: AssemblyVersion("#{SemanticVersionCore}#.0")]
176
[assembly: AssemblyCopyright("Copyright (c) #{Year}#, Eben Roux")]
187
[assembly: AssemblyProduct("Shuttle.Core.Streams")]

Shuttle.Core.Streams/.package/Shuttle.NuGetPackager.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
23
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
34
<PropertyGroup>
45
<PackageTasksPath Condition="'$(PackageTasksPath)' == ''">Shuttle.NuGetPackager.MSBuild.dll</PackageTasksPath>
@@ -9,4 +10,4 @@
910
<UsingTask AssemblyFile="$(PackageTasksPath)" TaskName="Shuttle.NuGetPackager.MSBuild.NuGet.SetNuGetPackageVersions" />
1011
<UsingTask AssemblyFile="$(PackageTasksPath)" TaskName="Shuttle.NuGetPackager.MSBuild.Zip" />
1112
<UsingTask AssemblyFile="$(PackageTasksPath)" TaskName="Shuttle.NuGetPackager.MSBuild.NuGet.SemanticVersion" />
12-
</Project>
13+
</Project>

Shuttle.Core.Streams/.package/package.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package>
44
<metadata>
55
<id>Shuttle.Core.Streams</id>
6-
<version>10.3.0</version>
6+
<version>20.0.0</version>
77
<authors>Eben Roux</authors>
88
<owners>Eben Roux</owners>
99
<license type="expression">BSD-3-Clause</license>
@@ -13,10 +13,10 @@
1313
<repository type="git" url="https://github.com/shuttle/Shuttle.Core.Streams.git" />
1414
<projectUrl>https://github.com/shuttle/Shuttle.Core.Streams</projectUrl>
1515
<description>Stream infrastructure utilities.</description>
16-
<copyright>Copyright (c) 2024, Eben Roux</copyright>
16+
<copyright>Copyright (c) 2025, Eben Roux</copyright>
1717
<tags>shuttle stream</tags>
1818
<dependencies>
19-
<dependency id="Shuttle.Core.Contract" version="11.1.0" />
19+
<dependency id="Shuttle.Core.Contract" version="20.0.0" />
2020
</dependencies>
2121
</metadata>
2222
<files>
Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
using System.Reflection;
22
using System.Runtime.InteropServices;
33

4-
#if NETFRAMEWORK
5-
[assembly: AssemblyTitle(".NET Framework")]
6-
#endif
7-
8-
#if NETCOREAPP
9-
[assembly: AssemblyTitle(".NET Core")]
10-
#endif
11-
12-
#if NETSTANDARD
13-
[assembly: AssemblyTitle(".NET Standard")]
14-
#endif
15-
16-
[assembly: AssemblyVersion("10.3.0.0")]
17-
[assembly: AssemblyCopyright("Copyright (c) 2024, Eben Roux")]
4+
[assembly: AssemblyTitle(".NET Unified Platform")]
5+
[assembly: AssemblyVersion("20.0.0.0")]
6+
[assembly: AssemblyCopyright("Copyright (c) 2025, Eben Roux")]
187
[assembly: AssemblyProduct("Shuttle.Core.Streams")]
198
[assembly: AssemblyCompany("Eben Roux")]
209
[assembly: AssemblyConfiguration("Release")]
21-
[assembly: AssemblyInformationalVersion("10.3.0")]
10+
[assembly: AssemblyInformationalVersion("20.0.0")]
2211
[assembly: ComVisible(false)]

Shuttle.Core.Streams/Shuttle.Core.Streams.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
4+
<TargetFramework>net8.0</TargetFramework>
55
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
6+
<Nullable>enable</Nullable>
67
</PropertyGroup>
78

89
<ItemGroup>
@@ -14,7 +15,7 @@
1415
</ItemGroup>
1516

1617
<ItemGroup>
17-
<PackageReference Include="Shuttle.Core.Contract" Version="11.1.0" />
18+
<PackageReference Include="Shuttle.Core.Contract" Version="20.0.0" />
1819
</ItemGroup>
1920

2021
<ItemGroup>
@@ -32,4 +33,4 @@
3233
</EmbeddedResource>
3334
</ItemGroup>
3435

35-
</Project>
36+
</Project>

0 commit comments

Comments
 (0)