Skip to content

Commit

Permalink
v2.0 - optimizations & breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NotOfficer committed Mar 31, 2024
1 parent abb5d18 commit b7de39a
Show file tree
Hide file tree
Showing 19 changed files with 460 additions and 371 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/nuget_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: NuGet Push

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore ./src

- name: Build
run: dotnet build ./src --no-restore --configuration Release

- name: Pack NuGet Package(s)
run: dotnet pack ./src --no-restore --no-build --configuration Release --output ./nuget-packages

- name: Upload Build Artifact(s)
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ./nuget-packages

- name: Push NuGet Package(s)
run: dotnet nuget push ./nuget-packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Officer
Copyright (c) 2024 Officer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Binary file added src/Usmap.NET.Tests/TestFiles/br1.usmap
Binary file not shown.
Binary file added src/Usmap.NET.Tests/TestFiles/oo1.usmap
Binary file not shown.
Binary file added src/Usmap.NET.Tests/TestFiles/xx1.usmap
Binary file not shown.
132 changes: 132 additions & 0 deletions src/Usmap.NET.Tests/Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
using System;
using System.IO;

using OodleDotNet;

using Xunit;

namespace UsmapDotNet.Tests;

public class Tests
{
private static readonly Oodle OodleInstance = new(Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
@"Libraries\oo2core_9_win64.dll"));

/*private const int ExpectedSchemas = 13890;
private const int ExpectedEnums = 2367;
private const int ExpectedNames = 74908;*/
private const int ExpectedSchemas = 28697;
private const int ExpectedEnums = 4391;
private const int ExpectedNames = 141495;

private readonly string _uncompressedUsmapPath;
private readonly string _brotliCompressedUsmapPath;
private readonly string _oodleCompressedUsmapPath;

public Tests()
{
var currentDir = Directory.GetCurrentDirectory();
var testFilesDir = Path.Combine(currentDir, "TestFiles");

_uncompressedUsmapPath = Path.Combine(testFilesDir, "xx1.usmap");
_brotliCompressedUsmapPath = Path.Combine(testFilesDir, "br1.usmap");
_oodleCompressedUsmapPath = Path.Combine(testFilesDir, "oo1.usmap");
}

[Fact]
public void ParseUncompressedUsmapFromFile()
{
var usmap = new Usmap(_uncompressedUsmapPath);
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Assert.Equal(ExpectedEnums, usmap.Enums.Length);
Assert.Equal(ExpectedNames, usmap.Names.Length);
}

[Fact]
public void ParseUncompressedUsmapFromStream()
{
var usmap = new Usmap(File.OpenRead(_uncompressedUsmapPath));
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Assert.Equal(ExpectedEnums, usmap.Enums.Length);
Assert.Equal(ExpectedNames, usmap.Names.Length);
}

[Fact]
public void ParseUncompressedUsmapFromBuffer()
{
var buffer = File.ReadAllBytes(_uncompressedUsmapPath);
var usmap = new Usmap(buffer);
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Assert.Equal(ExpectedEnums, usmap.Enums.Length);
Assert.Equal(ExpectedNames, usmap.Names.Length);
}

[Fact]
public void ParseBrotliCompressedFromFile()
{
var usmap = new Usmap(_brotliCompressedUsmapPath);
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Assert.Equal(ExpectedEnums, usmap.Enums.Length);
Assert.Equal(ExpectedNames, usmap.Names.Length);
}

[Fact]
public void ParseBrotliCompressedFromStream()
{
var usmap = new Usmap(File.OpenRead(_brotliCompressedUsmapPath));
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Assert.Equal(ExpectedEnums, usmap.Enums.Length);
Assert.Equal(ExpectedNames, usmap.Names.Length);
}

[Fact]
public void ParseBrotliCompressedFromBuffer()
{
var buffer = File.ReadAllBytes(_brotliCompressedUsmapPath);
var usmap = new Usmap(buffer);
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Assert.Equal(ExpectedEnums, usmap.Enums.Length);
Assert.Equal(ExpectedNames, usmap.Names.Length);
}

[Fact]
public void ParseOodleCompressedFromFile()
{
var options = new UsmapOptions
{
Oodle = OodleInstance
};
var usmap = new Usmap(_oodleCompressedUsmapPath, options);
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Assert.Equal(ExpectedEnums, usmap.Enums.Length);
Assert.Equal(ExpectedNames, usmap.Names.Length);
}

[Fact]
public void ParseOodleCompressedFromStream()
{
var options = new UsmapOptions
{
Oodle = OodleInstance
};
var usmap = new Usmap(File.OpenRead(_oodleCompressedUsmapPath), options);
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Assert.Equal(ExpectedEnums, usmap.Enums.Length);
Assert.Equal(ExpectedNames, usmap.Names.Length);
}

[Fact]
public void ParseOodleCompressedFromBuffer()
{
var buffer = File.ReadAllBytes(_oodleCompressedUsmapPath);
var options = new UsmapOptions
{
Oodle = OodleInstance
};
var usmap = new Usmap(buffer, options);
Assert.Equal(ExpectedSchemas, usmap.Schemas.Length);
Assert.Equal(ExpectedEnums, usmap.Enums.Length);
Assert.Equal(ExpectedNames, usmap.Names.Length);
}
}
29 changes: 14 additions & 15 deletions src/Usmap.NET.Tests/Usmap.NET.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>UsmapDotNet.Tests</RootNamespace>

<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -32,18 +25,24 @@
</ItemGroup>

<ItemGroup>
<None Update="oo.usmap">
<None Update="TestFiles\br.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\br.usmap">
<None Update="TestFiles\br1.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\oo.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\oo1.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\xx.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestFiles\xx1.usmap">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
94 changes: 0 additions & 94 deletions src/Usmap.NET.Tests/UsmapTests.cs

This file was deleted.

20 changes: 11 additions & 9 deletions src/Usmap.NET/EUsmapCompressionMethod.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace Usmap.NET
namespace UsmapDotNet;

public enum EUsmapCompressionMethod : byte
{
public enum EUsmapCompressionMethod : byte
{
None,
Oodle,
Brotli,
Unknown = byte.MaxValue
}
}
None,
Oodle,
Brotli,

MaxPlusOne,
Max = MaxPlusOne - 1,
Unknown = byte.MaxValue
}
Loading

0 comments on commit b7de39a

Please sign in to comment.