mirror of
https://github.com/nsnail/ns-ext.git
synced 2025-11-29 04:15:48 +08:00
Compare commits
14 Commits
v2.3.4
...
0c0f616f42
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c0f616f42 | |||
| a58f57c3dc | |||
| bce13faf2f | |||
| 6bf53000ef | |||
| 0ed999db2d | |||
| 43cf7dd954 | |||
| 1d5312bdbd | |||
| 2b15b748b6 | |||
| 4aee3cd210 | |||
| 0a9f93c5d3 | |||
| a288f21679 | |||
| c9975472bf | |||
| 97c93bd854 | |||
| 322cbc32df |
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -13,11 +13,13 @@ jobs:
|
|||||||
filter: tree:0
|
filter: tree:0
|
||||||
- uses: actions/setup-dotnet@v3
|
- uses: actions/setup-dotnet@v3
|
||||||
with:
|
with:
|
||||||
dotnet-version: 9.0.x
|
dotnet-version: 10.0.x
|
||||||
- working-directory: ./src/backend/NSExt
|
- working-directory: ./src/backend/NSExt
|
||||||
run: dotnet build -c Release -f net8.0
|
run: dotnet build -c Release -f net8.0
|
||||||
- working-directory: ./src/backend/NSExt
|
- working-directory: ./src/backend/NSExt
|
||||||
run: dotnet build -c Release -f net9.0
|
run: dotnet build -c Release -f net9.0
|
||||||
|
- working-directory: ./src/backend/NSExt
|
||||||
|
run: dotnet build -c Release -f net10.0
|
||||||
- working-directory: ./src/backend/NSExt
|
- working-directory: ./src/backend/NSExt
|
||||||
run: dotnet pack -c Release --no-build
|
run: dotnet pack -c Release --no-build
|
||||||
- uses: actions/create-release@v1
|
- uses: actions/create-release@v1
|
||||||
|
|||||||
15
CHANGELOG.md
15
CHANGELOG.md
@@ -2,6 +2,21 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [2.3.9](https://github.com/nsnail/NSExt/compare/v2.3.8...v2.3.9) (2025-11-24)
|
||||||
|
|
||||||
|
### [2.3.8](https://github.com/nsnail/NSExt/compare/v2.3.7...v2.3.8) (2025-07-29)
|
||||||
|
|
||||||
|
### [2.3.7](https://github.com/nsnail/NSExt/compare/v2.3.2...v2.3.7) (2025-06-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* ✨ 转36进制 ([#38](https://github.com/nsnail/NSExt/issues/38)) ([4aee3cd](https://github.com/nsnail/NSExt/commit/4aee3cd210722ec4861176dd53178f5f72cb2481))
|
||||||
|
|
||||||
|
### [2.3.6](https://github.com/nsnail/NSExt/compare/v2.3.2...v2.3.6) (2025-06-23)
|
||||||
|
|
||||||
|
### [2.3.5](https://github.com/nsnail/NSExt/compare/v2.3.2...v2.3.5) (2025-03-26)
|
||||||
|
|
||||||
### [2.3.4](https://github.com/nsnail/NSExt/compare/v2.3.2...v2.3.4) (2025-03-06)
|
### [2.3.4](https://github.com/nsnail/NSExt/compare/v2.3.2...v2.3.4) (2025-03-06)
|
||||||
|
|
||||||
### [2.3.3](https://github.com/nsnail/NSExt/compare/v2.3.2...v2.3.3) (2025-01-02)
|
### [2.3.3](https://github.com/nsnail/NSExt/compare/v2.3.2...v2.3.3) (2025-01-02)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<RepositoryUrl>https://github.com/nsnail/NSExt.git</RepositoryUrl>
|
<RepositoryUrl>https://github.com/nsnail/NSExt.git</RepositoryUrl>
|
||||||
<RootNamespace>NSExt</RootNamespace>
|
<RootNamespace>NSExt</RootNamespace>
|
||||||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -15,15 +15,15 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.12.19">
|
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.14.15">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Roslynator.Analyzers" Version="4.13.1">
|
<PackageReference Include="Roslynator.Analyzers" Version="4.14.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.7.0.110445">
|
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.15.0.120848">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"version": "2.3.4",
|
"version": "2.3.9",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cz-git": "^1.11.0",
|
"cz-git": "^1.12.0",
|
||||||
"commitizen": "^4.3.1",
|
"commitizen": "^4.3.1",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.6.2",
|
||||||
"standard-version": "^9.5.0"
|
"standard-version": "^9.5.0"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0-preview-25107-01"/>
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1"/>
|
||||||
<PackageReference Include="xunit" Version="2.9.3"/>
|
<PackageReference Include="xunit" Version="2.9.3"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
|
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ namespace NSExt.Extensions;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class LongExtensions
|
public static class LongExtensions
|
||||||
{
|
{
|
||||||
|
private const string _CHARS_36 = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 判断枚举是否包含某个位
|
/// 判断枚举是否包含某个位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -24,6 +26,22 @@ public static class LongExtensions
|
|||||||
return new Random(Guid.NewGuid().GetHashCode()).NextInt64(me[0], me[1]);
|
return new Random(Guid.NewGuid().GetHashCode()).NextInt64(me[0], me[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 转36进制
|
||||||
|
/// </summary>
|
||||||
|
public static string Sys36(this long me)
|
||||||
|
{
|
||||||
|
var ret = new StringBuilder();
|
||||||
|
while (me > 35)
|
||||||
|
{
|
||||||
|
_ = ret.Insert(0, _CHARS_36[(int)(me % 36)]);
|
||||||
|
me /= 36;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = ret.Insert(0, _CHARS_36[(int)me]);
|
||||||
|
return ret.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 1970毫秒数转换成日期对象
|
/// 1970毫秒数转换成日期对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace NSExt.Extensions;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static partial class StringExtensions
|
public static partial class StringExtensions
|
||||||
{
|
{
|
||||||
private const string _CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
private const string _CHARS_62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
private static readonly Regex _regexIpV4 = RegexIpV4();
|
private static readonly Regex _regexIpV4 = RegexIpV4();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -51,15 +51,43 @@ public static partial class StringExtensions
|
|||||||
return decrypted.HexDe();
|
return decrypted.HexDe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将指定的输入字符串进行Base62编码
|
||||||
|
/// </summary>
|
||||||
|
public static string Base62(this string me)
|
||||||
|
{
|
||||||
|
// Convert string to byte array
|
||||||
|
var bytes = Encoding.UTF8.GetBytes(me);
|
||||||
|
|
||||||
|
// Convert byte array to BigInteger for easier processing
|
||||||
|
var bigInteger = new BigInteger(bytes);
|
||||||
|
|
||||||
|
if (bigInteger == 0)
|
||||||
|
{
|
||||||
|
return _CHARS_62[0].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = new StringBuilder();
|
||||||
|
|
||||||
|
while (bigInteger > 0)
|
||||||
|
{
|
||||||
|
var remainder = (int)(bigInteger % 62);
|
||||||
|
bigInteger /= 62;
|
||||||
|
_ = result.Insert(0, _CHARS_62[remainder]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 将指定的输入字符串进行Base62解码
|
/// 将指定的输入字符串进行Base62解码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ArgumentException">ArgumentException</exception>
|
/// <exception cref="ArgumentException">ArgumentException</exception>
|
||||||
public static string Base62Decode(this string me)
|
public static string Base62De(this string me)
|
||||||
{
|
{
|
||||||
BigInteger result = 0;
|
BigInteger result = 0;
|
||||||
|
|
||||||
foreach (var index in me.Select(c => _CHARACTERS.IndexOf(c)))
|
foreach (var index in me.Select(c => _CHARS_62.IndexOf(c)))
|
||||||
{
|
{
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
@@ -81,34 +109,6 @@ public static partial class StringExtensions
|
|||||||
return Encoding.UTF8.GetString(bytes);
|
return Encoding.UTF8.GetString(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 将指定的输入字符串进行Base62编码
|
|
||||||
/// </summary>
|
|
||||||
public static string Base62Encode(this string me)
|
|
||||||
{
|
|
||||||
// Convert string to byte array
|
|
||||||
var bytes = Encoding.UTF8.GetBytes(me);
|
|
||||||
|
|
||||||
// Convert byte array to BigInteger for easier processing
|
|
||||||
var bigInteger = new BigInteger(bytes);
|
|
||||||
|
|
||||||
if (bigInteger == 0)
|
|
||||||
{
|
|
||||||
return _CHARACTERS[0].ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = new StringBuilder();
|
|
||||||
|
|
||||||
while (bigInteger > 0)
|
|
||||||
{
|
|
||||||
var remainder = (int)(bigInteger % 62);
|
|
||||||
bigInteger /= 62;
|
|
||||||
_ = result.Insert(0, _CHARACTERS[remainder]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// base64编码
|
/// base64编码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
<Import Project="$(SolutionDir)/build/copy.pkg.xml.comment.files.targets"/>
|
<Import Project="$(SolutionDir)/build/copy.pkg.xml.comment.files.targets"/>
|
||||||
<Import Project="$(SolutionDir)/build/prebuild.targets"/>
|
<Import Project="$(SolutionDir)/build/prebuild.targets"/>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.13.0"/>
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="5.0.0"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0"/>
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.0"/>
|
||||||
<PackageReference Include="System.IO.Hashing" Version="9.0.0"/>
|
<PackageReference Include="System.IO.Hashing" Version="10.0.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="*.json">
|
<None Update="*.json">
|
||||||
|
|||||||
Reference in New Issue
Block a user