Skip to content

Commit 2f8d380

Browse files
committed
v2.0 + .net8
1 parent eaa7451 commit 2f8d380

20 files changed

Lines changed: 474 additions & 241 deletions

.github/workflows/nuget_push.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: NuGet Push
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup .NET
15+
uses: actions/setup-dotnet@v4
16+
with:
17+
dotnet-version: 8.0.x
18+
19+
- name: Restore dependencies
20+
run: dotnet restore ./src
21+
22+
- name: Build
23+
run: dotnet build ./src --no-restore --configuration Release
24+
25+
- name: Pack NuGet Package(s)
26+
run: dotnet pack ./src --no-restore --no-build --configuration Release --output ./nuget-packages
27+
28+
- name: Upload Build Artifact(s)
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: nuget-packages
32+
path: ./nuget-packages
33+
34+
- name: Push NuGet Package(s)
35+
run: dotnet nuget push ./nuget-packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
36+
env:
37+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Officer
3+
Copyright (c) 2024 NotOfficer
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/Oodle.NET.Tests/Oodle.NET.Tests.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
5-
4+
<TargetFramework>net8.0</TargetFramework>
5+
<RootNamespace>OodleDotNet.Tests</RootNamespace>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

@@ -17,13 +17,13 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
21-
<PackageReference Include="xunit" Version="2.4.1" />
22-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
21+
<PackageReference Include="xunit" Version="2.7.0" />
22+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2424
<PrivateAssets>all</PrivateAssets>
2525
</PackageReference>
26-
<PackageReference Include="coverlet.collector" Version="3.0.3">
26+
<PackageReference Include="coverlet.collector" Version="6.0.2">
2727
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2828
<PrivateAssets>all</PrivateAssets>
2929
</PackageReference>

src/Oodle.NET.Tests/OodleCompressorTests.cs

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

src/Oodle.NET.Tests/Tests.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.IO;
3+
using System.Runtime.CompilerServices;
4+
using System.Runtime.InteropServices;
5+
using System.Text;
6+
7+
using Xunit;
8+
9+
namespace OodleDotNet.Tests;
10+
11+
public class Tests
12+
{
13+
private readonly Oodle _oodle = new(Path.Combine(
14+
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
15+
@"Libraries\oo2core_9_win64.dll"));
16+
17+
[Fact]
18+
public void CompressAndDecompress()
19+
{
20+
const OodleCompressor compressor = OodleCompressor.Kraken;
21+
var randomString = GetRandomString(8192);
22+
var randomStringBuffer = Encoding.ASCII.GetBytes(randomString);
23+
24+
var compressedBufferSize = _oodle.GetCompressedBufferSizeNeeded(compressor, randomStringBuffer.Length);
25+
Assert.NotEqual(0, compressedBufferSize);
26+
27+
var compressedBuffer = new byte[compressedBufferSize];
28+
var compressedSize = (int)_oodle.Compress(compressor, OodleCompressionLevel.Max, randomStringBuffer, compressedBuffer);
29+
Assert.NotEqual(0, compressedSize);
30+
31+
var decompressedBuffer = new byte[randomStringBuffer.Length];
32+
var decompressedSize = (int)_oodle.Decompress(compressedBuffer.AsSpan(0, compressedSize), decompressedBuffer);
33+
Assert.NotEqual(0, decompressedSize);
34+
35+
Assert.Equal(decompressedSize, randomStringBuffer.Length);
36+
Assert.True(randomStringBuffer.AsSpan().SequenceEqual(decompressedBuffer));
37+
}
38+
39+
private static string GetRandomString(int length)
40+
{
41+
const string chars = "0123456789ABCDEF";
42+
var result = new string('\0', length);
43+
var resultReadonlySpan = result.AsSpan();
44+
var resultSpan = MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in resultReadonlySpan.GetPinnableReference()), length);
45+
46+
for (var i = 0; i < resultSpan.Length; i++)
47+
{
48+
resultSpan[i] = chars[Random.Shared.Next(chars.Length)];
49+
}
50+
51+
return result;
52+
}
53+
}

src/Oodle.NET.sln

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.31112.23
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.4.33213.308
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Oodle.NET", "Oodle.NET\Oodle.NET.csproj", "{AFF75C15-8DFA-454A-B24B-09F19BE68559}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Oodle.NET", "Oodle.NET\Oodle.NET.csproj", "{AFF75C15-8DFA-454A-B24B-09F19BE68559}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Oodle.NET.Tests", "Oodle.NET.Tests\Oodle.NET.Tests.csproj", "{0482F51C-6992-49AD-90AC-A4689FA32C52}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Oodle.NET.Tests", "Oodle.NET.Tests\Oodle.NET.Tests.csproj", "{0482F51C-6992-49AD-90AC-A4689FA32C52}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/Oodle.NET/Enums.cs

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
namespace OodleDotNet;
2+
3+
public enum OodleVerbosity
4+
{
5+
None = 0,
6+
Minimal = 1,
7+
Some = 2,
8+
Lots = 3,
9+
Force32 = 0x40000000
10+
}
11+
12+
public enum OodleFuzzSafe
13+
{
14+
No = 0,
15+
Yes = 1
16+
}
17+
18+
public enum OodleCheckCRC
19+
{
20+
No = 0,
21+
Yes = 1,
22+
Force32 = 0x40000000
23+
}
24+
25+
public enum OodleDecodeThreadPhase
26+
{
27+
Phase1 = 1,
28+
Phase2 = 2,
29+
All = 3,
30+
Unthreaded = All
31+
}
32+
33+
public enum OodleCompressionLevel
34+
{
35+
/// <summary>
36+
/// don't compress, just copy raw bytes
37+
/// </summary>
38+
None=0,
39+
/// <summary>
40+
/// super fast mode, lower compression ratio
41+
/// </summary>
42+
SuperFast=1,
43+
/// <summary>
44+
/// fastest LZ mode with still decent compression ratio
45+
/// </summary>
46+
VeryFast=2,
47+
/// <summary>
48+
/// fast - good for daily use
49+
/// </summary>
50+
Fast=3,
51+
/// <summary>
52+
/// standard medium speed LZ mode
53+
/// </summary>
54+
Normal=4,
55+
56+
/// <summary>
57+
/// optimal parse level 1 (faster optimal encoder)
58+
/// </summary>
59+
Optimal1=5,
60+
/// <summary>
61+
/// optimal parse level 2 (recommended baseline optimal encoder)
62+
/// </summary>
63+
Optimal2=6,
64+
/// <summary>
65+
/// optimal parse level 3 (slower optimal encoder)
66+
/// </summary>
67+
Optimal3=7,
68+
/// <summary>
69+
/// optimal parse level 4 (very slow optimal encoder)
70+
/// </summary>
71+
Optimal4=8,
72+
/// <summary>
73+
/// optimal parse level 5 (don't care about encode speed, maximum compression)
74+
/// </summary>
75+
Optimal5=9,
76+
77+
/// <summary>
78+
/// faster than SuperFast, less compression
79+
/// </summary>
80+
HyperFast1=-1,
81+
/// <summary>
82+
/// faster than HyperFast1, less compression
83+
/// </summary>
84+
HyperFast2=-2,
85+
/// <summary>
86+
/// faster than HyperFast2, less compression
87+
/// </summary>
88+
HyperFast3=-3,
89+
/// <summary>
90+
/// fastest, less compression
91+
/// </summary>
92+
HyperFast4=-4,
93+
94+
/// <summary>
95+
/// alias hyperfast base level
96+
/// </summary>
97+
HyperFast=HyperFast1,
98+
/// <summary>
99+
/// alias optimal standard level
100+
/// </summary>
101+
Optimal = Optimal2,
102+
/// <summary>
103+
/// maximum compression level
104+
/// </summary>
105+
Max = Optimal5,
106+
/// <summary>
107+
/// fastest compression level
108+
/// </summary>
109+
Min = HyperFast4,
110+
111+
Force32 = 0x40000000,
112+
Invalid = Force32
113+
}
114+
115+
public enum OodleCompressor
116+
{
117+
Invalid = -1,
118+
/// <summary>
119+
/// None = memcpy, pass through uncompressed bytes
120+
/// </summary>
121+
None = 3,
122+
123+
/// <summary>
124+
/// Fast decompression and high compression ratios, amazing!
125+
/// </summary>
126+
Kraken = 8,
127+
/// <summary>
128+
/// Leviathan = Kraken's big brother with higher compression, slightly slower decompression.
129+
/// </summary>
130+
Leviathan = 13,
131+
/// <summary>
132+
/// Mermaid is between Kraken
133+
/// </summary>& Selkie - crazy fast, still decent compression.
134+
Mermaid = 9,
135+
/// <summary>
136+
/// Selkie is a super-fast relative of Mermaid. For maximum decode speed.
137+
/// </summary>
138+
Selkie = 11,
139+
/// <summary>
140+
/// Hydra, the many-headed beast = Leviathan, Kraken, Mermaid, or Selkie (see $OodleLZ_About_Hydra)
141+
/// </summary>
142+
Hydra = 12,
143+
144+
/// <summary>
145+
/// no longer supported as of Oodle 2.9.0
146+
/// </summary>
147+
BitKnit = 10,
148+
/// <summary>
149+
/// no longer supported as of Oodle 2.9.0
150+
/// </summary>
151+
LZB16 = 4,
152+
/// <summary>
153+
/// no longer supported as of Oodle 2.9.0
154+
/// </summary>
155+
LZNA = 7,
156+
/// <summary>
157+
/// no longer supported as of Oodle 2.9.0
158+
/// </summary>
159+
LZH = 0,
160+
/// <summary>
161+
/// no longer supported as of Oodle 2.9.0
162+
/// </summary>
163+
LZHLW = 1,
164+
/// <summary>
165+
/// no longer supported as of Oodle 2.9.0
166+
/// </summary>
167+
LZNIB = 2,
168+
/// <summary>
169+
/// no longer supported as of Oodle 2.9.0
170+
/// </summary>
171+
LZBLW = 5,
172+
/// <summary>
173+
/// no longer supported as of Oodle 2.9.0
174+
/// </summary>
175+
LZA = 6,
176+
177+
Count = 14,
178+
Force32 = 0x40000000
179+
}

0 commit comments

Comments
 (0)