diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3035e1d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# editorconfig dotnet +root = true + +# Default settings: +[*] +insert_final_newline = false +indent_style = space +indent_size = 2 + +[*.cs] +indent_style = space +indent_size = 4 +end_of_line = crlf + +# organize usings +dotnet_sort_system_directives_first = true +dotnet_separate_import_directive_groups = false \ No newline at end of file diff --git a/.github/workflows/dotnet-package.yml b/.github/workflows/dotnet-package.yml index 326f161..89dd411 100644 --- a/.github/workflows/dotnet-package.yml +++ b/.github/workflows/dotnet-package.yml @@ -6,17 +6,17 @@ on: jobs: deploy: - runs-on: ubuntu-latest permissions: packages: write contents: read steps: - - uses: actions/checkout@v2 - - uses: actions/setup-dotnet@v1 + - uses: actions/checkout@v3 + - name: Setup .NET + - uses: actions/setup-dotnet@v3 with: - dotnet-version: '5.0.x' # SDK Version to use. + dotnet-version: 6.0.x - run: dotnet build --configuration Release . - name: Create the package run: dotnet pack --configuration Release . diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index dc7d0c7..274d452 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -10,16 +10,13 @@ jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - dotnet: [ '2.1.x', '3.1.x', '5.0.x' ] steps: - - uses: actions/checkout@v2 - - name: Setup .NET ${{ matrix.dotnet-version }} - uses: actions/setup-dotnet@v1 + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 with: - dotnet-version: ${{ matrix.dotnet-version }} + dotnet-version: 6.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/Base62.Tests/Base62.Tests.csproj b/Base62.Tests/Base62.Tests.csproj index f0183b9..59676a7 100644 --- a/Base62.Tests/Base62.Tests.csproj +++ b/Base62.Tests/Base62.Tests.csproj @@ -1,23 +1,28 @@  - netcoreapp2.1;netcoreapp3.1;net5.0 + netcoreapp3.1;net5.0;net6.0 false - 7.3 + latest - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + all runtime; build; native; contentfiles; analyzers; buildtransitive + - - all + runtime; build; native; contentfiles; analyzers; buildtransitive + all diff --git a/Base62.Tests/Base62Tests.cs b/Base62.Tests/Base62Tests.cs index 354b7e6..966c6fb 100644 --- a/Base62.Tests/Base62Tests.cs +++ b/Base62.Tests/Base62Tests.cs @@ -59,10 +59,11 @@ public void ASCII_AND_UTF8_Can_RoundTrip(string input, string expected) public void FirstZeroBytesAreConvertedCorrectly() { var sourceBytes = new byte[] { 0, 0, 1, 2, 0, 0 }; - var encoded = Base62Converter.BaseConvert(sourceBytes, 256, 62); - var decoded = Base62Converter.BaseConvert(encoded, 62, 256); + var converter = new Base62Converter(Base62Converter.CharacterSet.DEFAULT); + var encoded = converter.Encode(sourceBytes); + var decoded = converter.Decode(encoded); + Assert.Equal(sourceBytes, decoded); - } public static IEnumerable GetData() diff --git a/Base62.sln b/Base62.sln index fb07937..44a445d 100644 --- a/Base62.sln +++ b/Base62.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30804.86 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32210.238 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Base62", "Base62\Base62.csproj", "{AE1B5455-F004-4948-AE22-AC59C03C53BC}" EndProject @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Base62.Tests", "Base62.Test EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5CF4F621-110B-4ADF-A464-A75042EFCF6B}" ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + .editorconfig = .editorconfig LICENSE.md = LICENSE.md README.md = README.md EndProjectSection diff --git a/Base62/Base62.csproj b/Base62/Base62.csproj index 48559be..04abed3 100644 --- a/Base62/Base62.csproj +++ b/Base62/Base62.csproj @@ -1,24 +1,23 @@  - netstandard1.3;netstandard2.0;netstandard2.1;net5.0 + netstandard1.3;netstandard2.0;netstandard2.1;net5.0;net6.0 Base62 encoder and decoder for .NET for URL shortening and/or obfuscation. true - 2021 + 2022 https://github.com/ghost1face/base62 https://github.com/ghost1face/base62 base62 encoder decoder url-shortener conversion - Daniel Destouche + ghost1face - * Expose methods for converting from array - * No direct .net framework support, netstandard1.3; netstandard2.0; netstandard2.1; net5.0 support going forward + * Addresses bug with leading zeros - 1.2.0.0 - 1.2.0.0 + 1.3.0.0 + 1.3.0.0 LICENSE.md - 1.2.0 + 1.3.0 git true true @@ -32,27 +31,21 @@ - - - <_Parameter1>Base62.Tests - - - true true - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + all runtime; build; native; contentfiles; analyzers diff --git a/Base62/Base62Converter.cs b/Base62/Base62Converter.cs index 72b37f7..de06a7e 100644 --- a/Base62/Base62Converter.cs +++ b/Base62/Base62Converter.cs @@ -94,7 +94,7 @@ public byte[] Decode(byte[] value) /// Source base to convert from. /// Target base to convert to. /// Converted byte array. - internal static byte[] BaseConvert(byte[] source, int sourceBase, int targetBase) + private static byte[] BaseConvert(byte[] source, int sourceBase, int targetBase) { if (targetBase < 2 || targetBase > 256) throw new ArgumentOutOfRangeException(nameof(targetBase), targetBase, "Value must be between 2 & 256 (inclusive)");