Skip to content

Commit d25203e

Browse files
committed
implemented new usmap versions
1 parent faa3376 commit d25203e

File tree

10 files changed

+210
-52
lines changed

10 files changed

+210
-52
lines changed
1.49 MB
Binary file not shown.
1.44 MB
Binary file not shown.
4.61 MB
Binary file not shown.

src/Usmap.NET.Tests/Tests.cs

Lines changed: 123 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,23 @@ public class Tests
1616
/*private const int ExpectedSchemas = 13890;
1717
private const int ExpectedEnums = 2367;
1818
private const int ExpectedNames = 74908;*/
19+
1920
private const int ExpectedSchemas = 28697;
2021
private const int ExpectedEnums = 4391;
2122
private const int ExpectedNames = 141495;
2223

24+
private const int ExpectedSchemasV3 = 29520;
25+
private const int ExpectedEnumsV3 = 4484;
26+
private const int ExpectedNamesV3 = 144915;
27+
2328
private readonly string _uncompressedUsmapPath;
2429
private readonly string _brotliCompressedUsmapPath;
2530
private readonly string _oodleCompressedUsmapPath;
2631

32+
private readonly string _uncompressedUsmapV3Path;
33+
private readonly string _brotliCompressedUsmapV3Path;
34+
private readonly string _oodleCompressedUsmapV3Path;
35+
2736
public Tests()
2837
{
2938
var currentDir = Directory.GetCurrentDirectory();
@@ -32,10 +41,14 @@ public Tests()
3241
_uncompressedUsmapPath = Path.Combine(testFilesDir, "xx1.usmap");
3342
_brotliCompressedUsmapPath = Path.Combine(testFilesDir, "br1.usmap");
3443
_oodleCompressedUsmapPath = Path.Combine(testFilesDir, "oo1.usmap");
44+
45+
_uncompressedUsmapV3Path = Path.Combine(testFilesDir, "xx2.usmap");
46+
_brotliCompressedUsmapV3Path = Path.Combine(testFilesDir, "br2.usmap");
47+
_oodleCompressedUsmapV3Path = Path.Combine(testFilesDir, "oo2.usmap");
3548
}
3649

3750
[Fact]
38-
public void ParseUncompressedUsmapFromFile()
51+
public void ParseUncompressedFromFile()
3952
{
4053
var usmap = new Usmap(_uncompressedUsmapPath);
4154
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
@@ -45,7 +58,7 @@ public void ParseUncompressedUsmapFromFile()
4558
}
4659

4760
[Fact]
48-
public void ParseUncompressedUsmapFromStream()
61+
public void ParseUncompressedFromStream()
4962
{
5063
var usmap = new Usmap(File.OpenRead(_uncompressedUsmapPath));
5164
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
@@ -55,7 +68,7 @@ public void ParseUncompressedUsmapFromStream()
5568
}
5669

5770
[Fact]
58-
public void ParseUncompressedUsmapFromBuffer()
71+
public void ParseUncompressedFromBuffer()
5972
{
6073
var buffer = File.ReadAllBytes(_uncompressedUsmapPath);
6174
var usmap = new Usmap(buffer);
@@ -138,4 +151,111 @@ public void ParseOodleCompressedFromBuffer()
138151
Assert.Equal(ExpectedNames, usmap.Names.Length);
139152
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
140153
}
154+
155+
// v3
156+
157+
[Fact]
158+
public void ParseUncompressedV3FromFile()
159+
{
160+
var usmap = new Usmap(_uncompressedUsmapV3Path);
161+
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
162+
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
163+
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
164+
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
165+
}
166+
167+
[Fact]
168+
public void ParseUncompressedV3FromStream()
169+
{
170+
var usmap = new Usmap(File.OpenRead(_uncompressedUsmapV3Path));
171+
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
172+
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
173+
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
174+
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
175+
}
176+
177+
[Fact]
178+
public void ParseUncompressedV3FromBuffer()
179+
{
180+
var buffer = File.ReadAllBytes(_uncompressedUsmapV3Path);
181+
var usmap = new Usmap(buffer);
182+
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
183+
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
184+
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
185+
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
186+
}
187+
188+
[Fact]
189+
public void ParseBrotliCompressedV3FromFile()
190+
{
191+
var usmap = new Usmap(_brotliCompressedUsmapV3Path);
192+
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
193+
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
194+
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
195+
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
196+
}
197+
198+
[Fact]
199+
public void ParseBrotliCompressedV3FromStream()
200+
{
201+
var usmap = new Usmap(File.OpenRead(_brotliCompressedUsmapV3Path));
202+
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
203+
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
204+
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
205+
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
206+
}
207+
208+
[Fact]
209+
public void ParseBrotliCompressedV3FromBuffer()
210+
{
211+
var buffer = File.ReadAllBytes(_brotliCompressedUsmapV3Path);
212+
var usmap = new Usmap(buffer);
213+
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
214+
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
215+
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
216+
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
217+
}
218+
219+
[Fact]
220+
public void ParseOodleCompressedV3FromFile()
221+
{
222+
var options = new UsmapOptions
223+
{
224+
Oodle = OodleInstance
225+
};
226+
var usmap = new Usmap(_oodleCompressedUsmapV3Path, options);
227+
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
228+
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
229+
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
230+
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
231+
}
232+
233+
[Fact]
234+
public void ParseOodleCompressedV3FromStream()
235+
{
236+
var options = new UsmapOptions
237+
{
238+
Oodle = OodleInstance
239+
};
240+
var usmap = new Usmap(File.OpenRead(_oodleCompressedUsmapV3Path), options);
241+
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
242+
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
243+
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
244+
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
245+
}
246+
247+
[Fact]
248+
public void ParseOodleCompressedV3FromBuffer()
249+
{
250+
var buffer = File.ReadAllBytes(_oodleCompressedUsmapV3Path);
251+
var options = new UsmapOptions
252+
{
253+
Oodle = OodleInstance
254+
};
255+
var usmap = new Usmap(buffer, options);
256+
Assert.Equal(ExpectedSchemasV3, usmap.Schemas.Length);
257+
Assert.Equal(ExpectedEnumsV3, usmap.Enums.Length);
258+
Assert.Equal(ExpectedNamesV3, usmap.Names.Length);
259+
Assert.All(usmap.Names, x => Assert.False(string.IsNullOrEmpty(x)));
260+
}
141261
}

src/Usmap.NET.Tests/Usmap.NET.Tests.csproj

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
12-
<PackageReference Include="xunit" Version="2.7.0" />
13-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
12+
<PackageReference Include="xunit" Version="2.8.0" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
<PrivateAssets>all</PrivateAssets>
1616
</PackageReference>
@@ -31,18 +31,27 @@
3131
<None Update="TestFiles\br1.usmap">
3232
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3333
</None>
34+
<None Update="TestFiles\br2.usmap">
35+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
36+
</None>
3437
<None Update="TestFiles\oo.usmap">
3538
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3639
</None>
3740
<None Update="TestFiles\oo1.usmap">
3841
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3942
</None>
43+
<None Update="TestFiles\oo2.usmap">
44+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
45+
</None>
4046
<None Update="TestFiles\xx.usmap">
4147
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4248
</None>
4349
<None Update="TestFiles\xx1.usmap">
4450
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4551
</None>
52+
<None Update="TestFiles\xx2.usmap">
53+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
54+
</None>
4655
</ItemGroup>
4756

4857
</Project>

src/Usmap.NET/EUsmapCompressionMethod.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ public enum EUsmapCompressionMethod : byte
99
Oodle,
1010
/// <summary/>
1111
Brotli,
12+
/// <summary/>
13+
ZStandard,
1214

1315
/// <summary/>
1416
MaxPlusOne,
1517
/// <summary/>
1618
Max = MaxPlusOne - 1,
1719
/// <summary/>
18-
Unknown = byte.MaxValue
20+
Unknown = 0xFF
1921
}

src/Usmap.NET/EUsmapVersion.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@ public enum EUsmapVersion : byte
55
{
66
/// <summary/>
77
Initial,
8-
8+
/// <summary>
9+
/// Adds package versioning to aid with compatibility
10+
/// </summary>
11+
PackageVersioning,
12+
/// <summary>
13+
/// Adds support for 16-bit wide name-lengths (ushort/uint16)
14+
/// </summary>
15+
LongFName,
16+
/// <summary>
17+
/// Adds support for enums with more than 255 values
18+
/// </summary>
19+
LargeEnums,
20+
921
/// <summary/>
1022
LatestPlusOne,
1123
/// <summary/>

src/Usmap.NET/Usmap.NET.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1919
<!--<PackageIcon>icon.png</PackageIcon>-->
2020
<GenerateDocumentationFile>true</GenerateDocumentationFile>
21-
<AssemblyVersion>2.0.2.0</AssemblyVersion>
22-
<FileVersion>2.0.2.0</FileVersion>
23-
<Version>2.0.2</Version>
21+
<AssemblyVersion>2.1.0.0</AssemblyVersion>
22+
<FileVersion>2.1.0.0</FileVersion>
23+
<Version>2.1.0</Version>
2424
</PropertyGroup>
2525

2626
<PropertyGroup>
@@ -32,7 +32,7 @@
3232

3333
<ItemGroup>
3434
<PackageReference Include="GenericReader" Version="2.1.2" />
35-
<PackageReference Include="NetEscapades.EnumGenerators" Version="1.0.0-beta08" PrivateAssets="all" />
35+
<PackageReference Include="NetEscapades.EnumGenerators" Version="1.0.0-beta09" PrivateAssets="all" />
3636
<PackageReference Include="Oodle.NET" Version="2.0.2" />
3737
</ItemGroup>
3838

0 commit comments

Comments
 (0)