Skip to content

Commit 4c1f55b

Browse files
authored
Target .NET 10 runtime (#12)
2 parents 36ca706 + 3c841fe commit 4c1f55b

15 files changed

Lines changed: 57 additions & 124 deletions

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: setup dotnet
3838
uses: actions/setup-dotnet@v5
3939
with:
40-
dotnet-version: 8
40+
dotnet-version: 10
4141

4242
- name: restore
4343
run: dotnet restore

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: setup dotnet
3434
uses: actions/setup-dotnet@v5
3535
with:
36-
dotnet-version: 8
36+
dotnet-version: 10
3737

3838
- name: restore
3939
run: dotnet restore

Kavod.Vba.Compression.sln

Lines changed: 0 additions & 31 deletions
This file was deleted.

Kavod.Vba.Compression.sln.DotSettings

Lines changed: 0 additions & 4 deletions
This file was deleted.

Kavod.Vba.Compression.slnx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<Solution>
2+
<Project Path="src/Kavod.Vba.Compression.Tests/Kavod.Vba.Compression.Tests.csproj" />
3+
<Project Path="src/Kavod.Vba.Compression/Kavod.Vba.Compression.csproj" />
4+
</Solution>

src/Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project>
22

33
<PropertyGroup>
4-
<VersionPrefix>2.0.0</VersionPrefix>
5-
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
6-
<LangVersion>12.0</LangVersion>
4+
<VersionPrefix>3.0.0</VersionPrefix>
5+
<TargetFrameworks>net10.0</TargetFrameworks>
6+
<LangVersion>14.0</LangVersion>
77
</PropertyGroup>
88

99
<PropertyGroup>

src/Kavod.Vba.Compression.Tests/Kavod.Vba.Compression.Tests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net48;net8.0</TargetFrameworks>
5-
<TargetFrameworks Condition=" '$(TestNetCoreOnly)' == 'true' ">net8.0</TargetFrameworks>
4+
<TargetFrameworks>net10.0</TargetFrameworks>
65
<IsPackable>false</IsPackable>
76
</PropertyGroup>
87

src/Kavod.Vba.Compression/CompressedChunk.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ internal class CompressedChunk
1616
{
1717
internal CompressedChunk(DecompressedChunk decompressedChunk)
1818
{
19-
if (decompressedChunk == null)
20-
{
21-
throw new ArgumentNullException(nameof(decompressedChunk));
22-
}
19+
ArgumentNullException.ThrowIfNull(decompressedChunk);
2320

2421
ChunkData = new CompressedChunkData(decompressedChunk);
2522
if (ChunkData.Size >= Globals.MaxBytesPerChunk)
@@ -31,10 +28,7 @@ internal CompressedChunk(DecompressedChunk decompressedChunk)
3128

3229
internal CompressedChunk(BinaryReader dataReader)
3330
{
34-
if (dataReader == null)
35-
{
36-
throw new ArgumentNullException(nameof(dataReader));
37-
}
31+
ArgumentNullException.ThrowIfNull(dataReader);
3832

3933
Header = new CompressedChunkHeader(dataReader);
4034
if (Header.IsCompressed)

src/Kavod.Vba.Compression/CompressedChunkData.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ internal class CompressedChunkData : IChunkData
1818

1919
internal CompressedChunkData(DecompressedChunk chunk)
2020
{
21-
if (chunk == null)
22-
{
23-
throw new ArgumentNullException(nameof(chunk));
24-
}
21+
ArgumentNullException.ThrowIfNull(chunk);
2522

2623
var tokens = Tokenizer.TokenizeUncompressedData(chunk.Data);
2724
_tokensequences.AddRange(tokens.ToTokenSequences());
@@ -31,15 +28,13 @@ internal CompressedChunkData(BinaryReader dataReader, UInt16 compressedChunkData
3128
{
3229
var data = dataReader.ReadBytes(compressedChunkDataSize);
3330

34-
using (var reader = new BinaryReader(new MemoryStream(data)))
31+
using var reader = new BinaryReader(new MemoryStream(data));
32+
var position = 0;
33+
while (reader.BaseStream.Position < reader.BaseStream.Length)
3534
{
36-
var position = 0;
37-
while (reader.BaseStream.Position < reader.BaseStream.Length)
38-
{
39-
var sequence = TokenSequence.GetFromCompressedData(reader, position);
40-
_tokensequences.Add(sequence);
41-
position += (int)sequence.Tokens.Sum(t => t.Length);
42-
}
35+
var sequence = TokenSequence.GetFromCompressedData(reader, position);
36+
_tokensequences.Add(sequence);
37+
position += (int)sequence.Tokens.Sum(t => t.Length);
4338
}
4439
}
4540

src/Kavod.Vba.Compression/CompressedContainer.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal class CompressedContainer
1818
{
1919
private const byte SignatureByteSig = 0x1;
2020

21-
private readonly List<CompressedChunk> _compressedChunks = new List<CompressedChunk>();
21+
private readonly List<CompressedChunk> _compressedChunks = [];
2222

2323
internal CompressedContainer(byte[] compressedData)
2424
{
@@ -47,21 +47,17 @@ internal CompressedContainer(DecompressedBuffer buffer)
4747

4848
internal byte[] SerializeData()
4949
{
50-
using (var writer = new BinaryWriter(new MemoryStream()))
51-
{
52-
writer.Write(SignatureByteSig);
53-
54-
foreach (var chunk in CompressedChunks)
55-
{
56-
writer.Write(chunk.SerializeData());
57-
}
50+
using var writer = new BinaryWriter(new MemoryStream());
51+
writer.Write(SignatureByteSig);
5852

59-
using (var reader = new BinaryReader(writer.BaseStream))
60-
{
61-
reader.BaseStream.Position = 0;
62-
return reader.ReadBytes((int) reader.BaseStream.Length);
63-
}
53+
foreach (var chunk in CompressedChunks)
54+
{
55+
writer.Write(chunk.SerializeData());
6456
}
57+
58+
using var reader = new BinaryReader(writer.BaseStream);
59+
reader.BaseStream.Position = 0;
60+
return reader.ReadBytes((int)reader.BaseStream.Length);
6561
}
6662
}
67-
}
63+
}

0 commit comments

Comments
 (0)