diff --git a/.editorconfig b/.editorconfig index 8f642da..b432966 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,28 +15,6 @@ indent_size = 2 [*.cs] dotnet_analyzer_diagnostic.severity = warning -dotnet_diagnostic.CA1200.severity = none -dotnet_diagnostic.CA1707.severity = none -dotnet_diagnostic.CA1716.severity = none -dotnet_diagnostic.IDE0005.severity = none -dotnet_diagnostic.IDE0008.severity = none -dotnet_diagnostic.IDE0010.severity = none -dotnet_diagnostic.IDE0055.severity = none -dotnet_diagnostic.IDE0160.severity = none -dotnet_diagnostic.IDE0270.severity = none -dotnet_diagnostic.RCS1141.severity = none -dotnet_diagnostic.RCS1142.severity = none -dotnet_diagnostic.RCS1181.severity = none -dotnet_diagnostic.RCS1186.severity = none -dotnet_diagnostic.S101.severity = none -dotnet_diagnostic.S1121.severity = none -dotnet_diagnostic.S1199.severity = none -dotnet_diagnostic.S125.severity = none -dotnet_diagnostic.S2094.severity = none -dotnet_diagnostic.S3925.severity = none -dotnet_diagnostic.S4663.severity = none -dotnet_diagnostic.SYSLIB1045.severity = none - # ReSharper properties resharper_align_linq_query = true @@ -73,7 +51,6 @@ resharper_wrap_before_eq = true resharper_wrap_chained_method_calls = chop_if_long resharper_wrap_switch_expression = chop_if_long - # Microsoft .NET properties csharp_indent_braces = false csharp_new_line_before_open_brace = local_functions, methods, types \ No newline at end of file diff --git a/.gitignore b/.gitignore index acde096..d756a2e 100644 --- a/.gitignore +++ b/.gitignore @@ -55,7 +55,7 @@ nunit-*.xml dlldata.c # Benchmark Results -BenchmarkDotNet.Artifacts/ +BenchmarkNSExtNet.Artifacts/ # .NET Core project.lock.json @@ -130,12 +130,12 @@ $tf/ # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper -*.DotSettings.user +*.NSExtSettings.user # TeamCity is a build add-in _TeamCity* -# DotCover is a Code Coverage Tool +# NSExtCover is a Code Coverage Tool *.dotCover # AxoCover is a Code Coverage Tool @@ -400,6 +400,7 @@ FodyWeavers.xsd # User Define dist/ -refs/ *.[Dd]esigner.cs *.db +cache +/assets/res/Ln.resx diff --git a/.tgitconfig b/.tgitconfig deleted file mode 100644 index cea19aa..0000000 --- a/.tgitconfig +++ /dev/null @@ -1,4 +0,0 @@ -[hook "startcommit"] - cmdline = dot.clean.cmd - wait = true - show = true \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index 6a86153..593c51c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,26 +1,36 @@ + - $(MSBuildThisFileDirectory) + + + + true nsnail - $(SolutionDir)/dist/$(MSBuildProjectName)/obj - $(SolutionDir)/dist/$(MSBuildProjectName)/bin + $(SolutionDir)/dist/backend/$(MSBuildProjectName)/obj + $(SolutionDir)/dist/backend/$(MSBuildProjectName)/bin © 2006-2023 nsnail - A .NET extension function library + The NSExt is a .NET extension function library false true enable + preview beta + v + CA1707;IDE0005;IDE0008;IDE0010;IDE0028;IDE0055;IDE0160;IDE0300;IDE0305;RCS1141;RCS1142;RCS1181;S101;S1121;S1135;S125;S2094;S3604;S4663;SYSLIB1045;SA1010;RCS1123;SA1407;IDE0048;S1075;S3928 NSExt git https://github.com/nsnail/NSExt.git - net7.0;net8.0 + net6.0;net7.0;net8.0 $(AssemblyName) - + all runtime; build; native; contentfiles; analyzers; buildtransitive + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE index 7777560..25c689d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 nsnail +Copyright (c) 2023 nsnail Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/NSExt.sln b/NSExt.sln index 5897daf..bd5a9d0 100644 --- a/NSExt.sln +++ b/NSExt.sln @@ -3,38 +3,66 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C84EB5A0-37AD-4B17-A51E-E36888C4441E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "backend", "backend", "{4DAF9366-855F-46BB-AE4C-660C92FA0697}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{5198A03D-0CAC-4828-A807-34A693F73859}" ProjectSection(SolutionItems) = preProject + .commitlintrc.js = .commitlintrc.js .editorconfig = .editorconfig .gitattributes = .gitattributes .gitignore = .gitignore - .tgitconfig = .tgitconfig - build.cake = build.cake - code.cleanup.full.ps1 = code.cleanup.full.ps1 - code.quality.props = code.quality.props + CHANGELOG.md = CHANGELOG.md Directory.Build.props = Directory.Build.props - dot.clean.cmd = dot.clean.cmd dotnet-tools.json = dotnet-tools.json - git.pr.ps1 = git.pr.ps1 - git.rc.ps1 = git.rc.ps1 global.json = global.json - image.optimize.csx = image.optimize.csx - key.snk = key.snk LICENSE = LICENSE - logo.png = logo.png NSExt.sln.DotSettings = NSExt.sln.DotSettings - nuget.config = nuget.config - packable.props = packable.props + NuGet.Config = NuGet.Config + package.json = package.json README.md = README.md README.zh-CN.md = README.zh-CN.md - stylecop.analyzers.ruleset = stylecop.analyzers.ruleset - stylecop.json = stylecop.json - sync.metafiles.csx = sync.metafiles.csx EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NSExt.Tests", "src\NSExt.Tests\NSExt.Tests.csproj", "{557FBEF6-E6D5-4531-86DF-D772A10E2261}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{BB0B25C9-0901-4923-913F-00F9A6B352A5}" + ProjectSection(SolutionItems) = preProject + clean.ln.csx = scripts/clean.ln.csx + code.clean.csx = scripts/code.clean.csx + code.clean.ps1 = scripts/code.clean.ps1 + gen.cs.tt = scripts/gen.cs.tt + gen.ln.cmd = scripts/gen.ln.cmd + gen.resx.tt = scripts/gen.resx.tt + git.pr.ps1 = scripts/git.pr.ps1 + git.rc.ps1 = scripts/git.rc.ps1 + image.optimize.csx = scripts/image.optimize.csx + install.as.tpl.ps1 = scripts/install.as.tpl.ps1 + rename.csx = scripts/rename.csx + resharper.full.ps1 = scripts/resharper.full.ps1 + switcher.nsext.json = scripts/switcher.nsext.json + switcher.ps1 = scripts/switcher.ps1 + sync.sln.files.csx = scripts/sync.sln.files.csx + EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NSExt", "src\NSExt\NSExt.csproj", "{BA0982BE-6E57-4AAF-9778-F9B2EB46F505}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{1129FE25-466B-4F4F-85FC-3752664245E1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{3C6F049E-3EE8-4D66-9AFF-E8A369032487}" + ProjectSection(SolutionItems) = preProject + ci.yml = .github/workflows/ci.yml + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{8E4C93BA-9493-4892-80C4-5E174C504829}" + ProjectSection(SolutionItems) = preProject + code.quality.props = build/code.quality.props + copy.pkg.xml.comment.files.targets = build/copy.pkg.xml.comment.files.targets + minver.targets = build/minver.targets + prebuild.targets = build/prebuild.targets + stylecop.analyzers.ruleset = build/stylecop.analyzers.ruleset + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NSExt", "src\backend\NSExt\NSExt.csproj", "{1E62C322-EE42-4699-A6F1-791C53EFA62D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NSExt.Tests", "src\backend\NSExt.Tests\NSExt.Tests.csproj", "{00604162-C444-478B-B773-3AB23C856CA7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -45,13 +73,19 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {557FBEF6-E6D5-4531-86DF-D772A10E2261}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {557FBEF6-E6D5-4531-86DF-D772A10E2261}.Debug|Any CPU.Build.0 = Debug|Any CPU - {557FBEF6-E6D5-4531-86DF-D772A10E2261}.Release|Any CPU.ActiveCfg = Release|Any CPU - {557FBEF6-E6D5-4531-86DF-D772A10E2261}.Release|Any CPU.Build.0 = Release|Any CPU - {BA0982BE-6E57-4AAF-9778-F9B2EB46F505}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BA0982BE-6E57-4AAF-9778-F9B2EB46F505}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BA0982BE-6E57-4AAF-9778-F9B2EB46F505}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BA0982BE-6E57-4AAF-9778-F9B2EB46F505}.Release|Any CPU.Build.0 = Release|Any CPU + {1E62C322-EE42-4699-A6F1-791C53EFA62D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E62C322-EE42-4699-A6F1-791C53EFA62D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E62C322-EE42-4699-A6F1-791C53EFA62D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E62C322-EE42-4699-A6F1-791C53EFA62D}.Release|Any CPU.Build.0 = Release|Any CPU + {00604162-C444-478B-B773-3AB23C856CA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00604162-C444-478B-B773-3AB23C856CA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00604162-C444-478B-B773-3AB23C856CA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00604162-C444-478B-B773-3AB23C856CA7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {4DAF9366-855F-46BB-AE4C-660C92FA0697} = {C84EB5A0-37AD-4B17-A51E-E36888C4441E} + {3C6F049E-3EE8-4D66-9AFF-E8A369032487} = {1129FE25-466B-4F4F-85FC-3752664245E1} + {1E62C322-EE42-4699-A6F1-791C53EFA62D} = {4DAF9366-855F-46BB-AE4C-660C92FA0697} + {00604162-C444-478B-B773-3AB23C856CA7} = {4DAF9366-855F-46BB-AE4C-660C92FA0697} EndGlobalSection EndGlobal \ No newline at end of file diff --git a/NSExt.sln.DotSettings b/NSExt.sln.DotSettings index 30a9cb5..ea9fc25 100644 --- a/NSExt.sln.DotSettings +++ b/NSExt.sln.DotSettings @@ -1,34 +1,57 @@ - + Inherit - True - DO_NOT_SHOW - DO_NOT_SHOW - DO_NOT_SHOW - NEVER - NEVER + True + True + DO_NOT_SHOW + HINT + DO_NOT_SHOW + DO_NOT_SHOW + NEVER + NEVER NEVER - NEVER + NEVER ID IOS IP - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /> + UI + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /> - True - True - True - True + True + True + True + True True 1 - 1 + 1 OFF - HINT + HINT Required - Required - Required + Required + Required Required <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> <Policy Inspect="True" Prefix="_" Suffix="" Style="AA_BB" /> - <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <?xml version="1.0" encoding="utf-16"?> <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> @@ -80,7 +103,6 @@ True True True - True True True True diff --git a/README.md b/README.md index 0e53b79..610911e 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,96 @@ -# ns-ext +# dot [中](README.zh-CN.md) | **En** -The **ns-ext** is a .NET extension function library, containing the following types of extension modules: -| Features | File name | -|------------------------------------------|------------------------------------| -| Byte type extension | ByteExtensions.cs | -| Character Type Extensions | CharExtensions.cs | -| Date Type Extensions | DateTimeExtensions.cs | -| Database command type extension | DbCommandExtensions.cs | -| Decimal Number Type extension | DecimalExtensions.cs | -| Enumable type extension | EnumerableExtensions.cs | -| Enumeration type extension | EnumExtensions.cs | -| General type extension | GenericExtensions.cs | -| Integer type extension | IntExtensions.cs | -| Json Serialization option type extension | JsonSerializerOptionsExtensions.cs | -| Log type extension | LoggerExtensions.cs | -| Long integer extension | LongExtensions.cs | -| Object type extension | ObjectExtensions.cs | -| Stream type extension | StreamExtensions.cs | -| String type extension | StringExtensions.cs | -| Prototype type extension | TypeExtensions.cs | -| Resource locator type extension | UriExtensions.cs | +Cross-platform, all-around utility set with a beautiful character interface-the Swiss Army knife -## Quick start +### Brief introduction -### Install +The dot is the one based on the one. NET 7, a cross-platform command-line tool, integrates more than 10 utilities that +program developers often use in their daily work, and is constantly increasing. + +``` +USAGE: + dot [OPTIONS] + +OPTIONS: + -h, --help Prints help information + -v, --version Prints version information + +COMMANDS: + git Git batch operation tool + color Screen coordinate color selection tool + tran Translation tools + guid GUID tool + ip IP tools + json Json tool + pwd Random password generator + rbom Remove the uf8 bom of the file + trim Remove line breaks and spaces at the end of the file + text Text encoding tool + time Time synchronization tool + tolf Convert newline characters to LF + get Multithreaded download tool -```shell -dotnet add package NSExt --prerelease ``` -### Example +### Some functional examples -```c# -using NSExt.Extensions; +- ##### Git batch management -internal static class Program -{ - private class Person - { - public string Name { get; set; } - public int Age { get; set; } - } - public static void Main(string[] args) - { - var person = - """ -{ - "Name": "Jason", - "Age": "30" -} -""".Object(); +When you have a clone and a lot of git repositories, use this command to pull their latest code all at once: - Console.WriteLine(person.Json()); - } -} +``` +dot git -a "pull" d:\repos ``` -### Output +![20221212212417](./assets/snapshots/20221212212417.png) -```json -{"name":"Jason","age":30} -``` \ No newline at end of file +Similarly, you can execute any git commands on a bunch of git repositories in bulk: + +``` +dot git -a "config --get http.proxy" d:\repos +``` + +![20221212213957](./assets/snapshots/20221212213957.png) + +- ##### High-precision time-clock synchronization + +Supports parallel requests from multiple NTP clock servers, while removing the network communication duration to set the +precise synchronization of the native clocks with the NTP standard time: + +``` +dot time -k +``` + +![20221212214514](./assets/snapshots/20221212214514.png) + +- ##### Text codec + +Copy you need to view various codec text in the clipboard, and then enter the following command to view + +``` +dot text +``` + +![20221212214904](./assets/snapshots/20221212214904.png) + +- ##### Multi-threading download tool + +Support setting the block size, number of threads to replace the single thread wget tool: + +``` +dot get https://github.com/nsnail/dot/releases/download/v1.1.1/dot-v1.1.1-win-x64.7z +``` + +![20221212215259](./assets/snapshots/20221212215259.png) + +- ##### Remove the blank at the end of the file + +Remove excess spaces and line breaks in the tail of all files in the specified directory: + +``` +dot trim d:\repos +``` + +![20221212215853](./assets/snapshots/20221212215853.png) \ No newline at end of file diff --git a/README.zh-CN.md b/README.zh-CN.md index 127d239..0cd4786 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,65 +1,94 @@ -# ns-ext +# dot + [En](README.md) | **中** -**ns-ext** 是一个.NET扩展函数库,包含以下类型扩展模块: +跨平台的、具有美观字符界面的全能实用工具集 - 程序员的瑞士军刀 -| 功能 | 文件名 | -| -------- | ---------------------------------- | -| 字节类型扩展 | ByteExtensions.cs | -| 字符类型扩展 | CharExtensions.cs | -| 日期类型扩展 | DateTimeExtensions.cs | -| 数据库命令类型扩展 | DbCommandExtensions.cs | -| 十进制数类型扩展 | DecimalExtensions.cs | -| 可枚举类型扩展 | EnumerableExtensions.cs | -| 枚举类型扩展 | EnumExtensions.cs | -| 泛型类型扩展 | GenericExtensions.cs | -| 整数型扩展 | IntExtensions.cs | -| Json序列化选项类型扩展 | JsonSerializerOptionsExtensions.cs | -| 日志类型扩展 | LoggerExtensions.cs | -| 长整型扩展 | LongExtensions.cs | -| 对象类型扩展 | ObjectExtensions.cs | -| 流类型扩展 | StreamExtensions.cs | -| 字符串类型扩展 | StringExtensions.cs | -| 原型类型扩展 | TypeExtensions.cs | -| 资源定位符类型扩展 | UriExtensions.cs | +### 简介 -## 快速开始 +dot 是一款基于.NET7,跨平台的命令行工具,集成10多种程序开发人员在日常工作常常用到的实用功能,并且还在不断增加。 -### 安装 +``` +USAGE: + dot [OPTIONS] + +OPTIONS: + -h, --help Prints help information + -v, --version Prints version information + +COMMANDS: + git Git批量操作工具 + color 屏幕坐标颜色选取工具 + tran 翻译工具 + guid GUID工具 + ip IP工具 + json Json工具 + pwd 随机密码生成器 + rbom 移除文件的uf8 bom + trim 移除文件尾部换行和空格 + text 文本编码工具 + time 时间同步工具 + tolf 转换换行符为LF + get 多线程下载工具 -```shell -dotnet add package NSExt --prerelease ``` -### 示例 +### 部分功能示例 -```c# -using NSExt.Extensions; +- ##### Git批量管理 -internal static class Program -{ - private class Person - { - public string Name { get; set; } - public int Age { get; set; } - } - public static void Main(string[] args) - { - var person = - """ -{ - "Name": "Jason", - "Age": "30" -} -""".Object(); +当你clone了大量的git仓库, 使用这条命令可以一次性拉取它们的最新代码: - Console.WriteLine(person.Json()); - } -} +``` +dot git -a "pull" d:\repos ``` -### 输出 +![20221212212417](./assets/snapshots/20221212212417.png) -```json -{"name":"Jason","age":30} -``` \ No newline at end of file +类似地,你可以批量对一堆git仓库执行任何git命令: + +``` +dot git -a "config --get http.proxy" d:\repos +``` + +![20221212213957](./assets/snapshots/20221212213957.png) + +- ##### 高精度时钟同步 + +支持多个NTP时钟服务器并行请求,同时除去网络通信时长以设置本机时钟与NTP标准时间精确同步: + +``` +dot time -k +``` + +![20221212214514](./assets/snapshots/20221212214514.png) + +- ##### 文本编解码 + +复制你需要查看各种编解码的文本在剪贴板中,然后输入如下命令,即可查看 + +``` +dot text +``` + +![20221212214904](./assets/snapshots/20221212214904.png) + +- ##### 多线程下载工具 + +支持设置分块大小,线程数量,用以替代单线程的wget工具: + +``` +dot get https://github.com/nsnail/dot/releases/download/v1.1.1/dot-v1.1.1-win-x64.7z +``` + +![20221212215259](./assets/snapshots/20221212215259.png) + +- ##### 移除文件末尾空白 + +移除指定目录下所有文件尾部多余的空格和换行符: + +``` +dot trim d:\repos +``` + +![20221212215853](./assets/snapshots/20221212215853.png) \ No newline at end of file diff --git a/build.cake b/build.cake deleted file mode 100644 index 2fb6a2b..0000000 --- a/build.cake +++ /dev/null @@ -1,117 +0,0 @@ -var target = Argument("target", "Default"); -var configuration = Argument("configuration", "Release"); -var framework = Argument("framework", "net7.0"); - -//////////////////////////////////////////////////////////////// -// Tasks - -Task("Clean") - .Does(context => -{ - context.CleanDirectory("./dist"); -}); - -Task("Build") - .IsDependentOn("Clean") - .Does(context => -{ - DotNetPublish("./src/NSExt/NSExt.csproj", new DotNetPublishSettings { - Configuration = configuration, - Framework = framework, - }); -}); - - -// Task("Test") -// .IsDependentOn("Build") -// .Does(context => -// { -// DotNetTest("./test/Spectre.Console.Tests/Spectre.Console.Tests.csproj", new DotNetTestSettings { -// Configuration = configuration, -// NoRestore = true, -// NoBuild = true, -// }); -// -// DotNetTest("./test/Spectre.Console.Cli.Tests/Spectre.Console.Cli.Tests.csproj", new DotNetTestSettings { -// Configuration = configuration, -// NoRestore = true, -// NoBuild = true, -// }); -// -// DotNetTest("./test/Spectre.Console.Analyzer.Tests/Spectre.Console.Analyzer.Tests.csproj", new DotNetTestSettings { -// Configuration = configuration, -// NoRestore = true, -// NoBuild = true, -// }); -// }); - - -// Task("Publish-GitHub") -// .WithCriteria(ctx => BuildSystem.IsRunningOnGitHubActions, "Not running on GitHub Actions") -// //.IsDependentOn("Package") -// .Does(context => -// { -// var apiKey = Argument("github-key", null); -// if(string.IsNullOrWhiteSpace(apiKey)) { -// throw new CakeException("No GitHub API key was provided."); -// } -// -// // Publish to GitHub Packages -// var exitCode = 0; -// foreach(var file in context.GetFiles("./.artifacts/*.nupkg")) -// { -// context.Information("Publishing {0}...", file.GetFilename().FullPath); -// exitCode += StartProcess("dotnet", -// new ProcessSettings { -// Arguments = new ProcessArgumentBuilder() -// .Append("gpr") -// .Append("push") -// .AppendQuoted(file.FullPath) -// .AppendSwitchSecret("-k", " ", apiKey) -// } -// ); -// } -// -// if(exitCode != 0) -// { -// throw new CakeException("Could not push GitHub packages."); -// } -// }); - -Task("Publish-NuGet") - //.WithCriteria(ctx => BuildSystem.IsRunningOnGitHubActions, "Not running on GitHub Actions") - .IsDependentOn("Build") - .Does(context => -{ - var apiKey = Argument("nuget-key", null); - if(string.IsNullOrWhiteSpace(apiKey)) { - throw new CakeException("No NuGet API key was provided."); - } - - // Publish to GitHub Packages - foreach(var file in context.GetFiles("./dist/NSExt/bin/Release/*.*")) - { - context.Information("Publishing {0}...", file.GetFilename().FullPath); - DotNetNuGetPush(file.FullPath, new DotNetNuGetPushSettings - { - Source = "https://api.nuget.org/v3/index.json", - ApiKey = apiKey, - SkipDuplicate = true - }); - } -}); - -//////////////////////////////////////////////////////////////// -// Targets - -Task("Publish") -// .IsDependentOn("Publish-GitHub") - .IsDependentOn("Publish-NuGet"); - -Task("Default") - .IsDependentOn("Build"); - -//////////////////////////////////////////////////////////////// -// Execution - -RunTarget(target) \ No newline at end of file diff --git a/code.cleanup.full.ps1 b/code.cleanup.full.ps1 deleted file mode 100644 index 5b5c370..0000000 --- a/code.cleanup.full.ps1 +++ /dev/null @@ -1 +0,0 @@ -dotnet jb cleanupcode --no-build ./NSExt.sln \ No newline at end of file diff --git a/code.quality.props b/code.quality.props deleted file mode 100644 index 7e4518a..0000000 --- a/code.quality.props +++ /dev/null @@ -1,43 +0,0 @@ - - - $(SolutionDir)/stylecop.analyzers.ruleset - - - true - true - true - true - true - true - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - \ No newline at end of file diff --git a/dot.clean.cmd b/dot.clean.cmd deleted file mode 100644 index 3eec6ef..0000000 --- a/dot.clean.cmd +++ /dev/null @@ -1,3 +0,0 @@ -dot rbom -w -e refs -e .git -e node_modules -dot trim -w -e refs -e .git -e node_modules -dot tolf -w -e refs -e .git -e node_modules \ No newline at end of file diff --git a/dotnet-tools.json b/dotnet-tools.json index d2c1b28..d36cef7 100644 --- a/dotnet-tools.json +++ b/dotnet-tools.json @@ -2,23 +2,29 @@ "version": 1, "isRoot": true, "tools": { - "cake.tool": { - "version": "3.1.0", + "dotnet-t4": { + "version": "2.3.1", "commands": [ - "dotnet-cake" + "t4" ] }, "dotnet-script": { - "version": "1.4.0", + "version": "1.5.0", "commands": [ "dotnet-script" ] }, "jetbrains.resharper.globaltools": { - "version": "2023.2.0", + "version": "2023.3.0", "commands": [ "jb" ] + }, + "dnt": { + "version": "1.8.3", + "commands": [ + "dnt" + ] } } } \ No newline at end of file diff --git a/git.pr.ps1 b/git.pr.ps1 deleted file mode 100644 index 2b68a89..0000000 --- a/git.pr.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -$types = @{ - '1' = @('FEA', '新增特性') - '2' = @('REF', '项目重构') - '3' = @('FIX', '缺陷修复') - '4' = @('PER', '性能优化') - '5' = @('RVT', '还原变更') - '6' = @('FMT', '格式整理') - '7' = @('DOC', '文档变更') - '8' = @('TST', '单元测试') - '9' = @('BLD', '工程构建') -} -git add ./ -$prefix = '' -while ($null -eq $types[$prefix]) -{ - $prefix = Read-Host "请选择提交类型`n" $( & { param($i) $i | ForEach-Object { "$_ : $( $types[$_][0] )($( $types[$_][1] ))`n" } } $types.Keys | Sort-Object ) -} -git commit -m "[$($types[$prefix][0])] $(($(Read-Host '是否跳过自动构建?(Y/n)') -eq 'n') ? '': '[SKIP CI] ')$(Read-Host '请输入提交消息')" -$branch = $(git branch --show-current) -& './dot.clean.cmd' -git add ./ -git commit --amend --no-edit -git pull -git push --set-upstream origin $branch -Start-Process -FilePath "https://github.com/nsnail/NSExt/compare/main...$branch" -Pause \ No newline at end of file diff --git a/git.rc.ps1 b/git.rc.ps1 deleted file mode 100644 index b72db93..0000000 --- a/git.rc.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -$branch = $(git branch --show-current) -git checkout main -git pull -git branch -D $branch -git branch $branch -git checkout $branch \ No newline at end of file diff --git a/global.json b/global.json index 8947643..ad64c8c 100644 --- a/global.json +++ b/global.json @@ -1,10 +1,10 @@ { "sdk": { - "version": "7.0.0", + "version": "8.0.0", "rollForward": "latestMajor", "allowPrerelease": true }, "tools": { - "dotnet": "7.0.0" + "dotnet": "8.0.0" } } \ No newline at end of file diff --git a/image.optimize.csx b/image.optimize.csx deleted file mode 100644 index e43a4d4..0000000 --- a/image.optimize.csx +++ /dev/null @@ -1,65 +0,0 @@ -/* - for %%i in (*.png) do pngquant %%i --force --output %%i --skip-if-larger - for %%i in (*.jpg) do jpegtran -copy none -optimize -perfect %%i %%i - * - */ - - -var files = Directory - .EnumerateFiles( - "./", - "*.png", - new EnumerationOptions - { - RecurseSubdirectories = true, - AttributesToSkip = FileAttributes.ReparsePoint, - IgnoreInaccessible = true - } - ) - .ToArray(); - -Parallel.ForEach( - files, - file => - { - var startInfo = new ProcessStartInfo - { - FileName = "pngquant", - Arguments = $"\"{file}\" --force --output \"{file}\" --skip-if-larger" - }; - using var p = Process.Start(startInfo); - p.WaitForExit(); - Console.WriteLine($"{file}: {p.ExitCode}"); - } -); - -files = new[] { "*.jpg", "*.jpeg" } - .SelectMany( - x => - Directory.EnumerateFiles( - "./", - x, - new EnumerationOptions - { - RecurseSubdirectories = true, - AttributesToSkip = FileAttributes.ReparsePoint, - IgnoreInaccessible = true - } - ) - ) - .ToArray(); - -Parallel.ForEach( - files, - file => - { - var startInfo = new ProcessStartInfo - { - FileName = "jpegtran", - Arguments = $"-copy none -optimize -perfect \"{file}\" \"{file}\"" - }; - using var p = Process.Start(startInfo); - p.WaitForExit(); - Console.WriteLine($"{file}: {p.ExitCode}"); - } -); \ No newline at end of file diff --git a/key.snk b/key.snk deleted file mode 100644 index aac3fbe..0000000 Binary files a/key.snk and /dev/null differ diff --git a/logo.png b/logo.png deleted file mode 100644 index 77638c1..0000000 Binary files a/logo.png and /dev/null differ diff --git a/nuget.config b/nuget.config index eb8bbca..0066ce1 100644 --- a/nuget.config +++ b/nuget.config @@ -2,7 +2,7 @@ - - + + \ No newline at end of file diff --git a/packable.props b/packable.props deleted file mode 100644 index ef69428..0000000 --- a/packable.props +++ /dev/null @@ -1,18 +0,0 @@ - - - ../../key.snk - false - true - true - true - true - true - logo.png - MIT - https://github.com/nsnail/NSExt.git - extensions - true - true - snupkg - - \ No newline at end of file diff --git a/publish.ps1 b/publish.ps1 deleted file mode 100644 index a890466..0000000 --- a/publish.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -Remove-Item ./dist -Recurse -Force -Confirm:$false -dotnet build -c Release -$apikey = Read-Host -Prompt "nuget apikey" -foreach ($file in Get-ChildItem -Path ./dist/NSExt/bin/Release | Where-Object { $_.Name -match "nupkg" }) { - dotnet nuget push $file --skip-duplicate --api-key $apikey --source https://api.nuget.org/v3/index.json -} \ No newline at end of file diff --git a/src/NSExt.Tests/NSExt.Tests.csproj b/src/NSExt.Tests/NSExt.Tests.csproj deleted file mode 100644 index f770abf..0000000 --- a/src/NSExt.Tests/NSExt.Tests.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/NSExt.Tests/TestCase.cs b/src/NSExt.Tests/TestCase.cs deleted file mode 100644 index 3164751..0000000 --- a/src/NSExt.Tests/TestCase.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace NSExt.Tests; - -/// -/// 测试用例 -/// -public class TestCase -{ - // private readonly ITestOutputHelper _testOutputHelper; - // - // public TestCase(ITestOutputHelper testOutputHelper) - // { - // _testOutputHelper = testOutputHelper; - // } - // - // public enum MyEnum1 - // { - // [ResourceDescription(nameof(Description))] - // Online = 1 - // - // , Offline = 2 - // } - // - // public static string Description { get; set; } = "123"; - // - // /// - // /// Case1 - // /// - // [Fact] - // public void Case1() - // { - // var test = MyEnum1.Online.ResDesc(); - // - // _testOutputHelper.WriteLine(test); - // Assert.True(test is not null); - // } -} \ No newline at end of file diff --git a/src/NSExt/Attributes/LocalizationAttribute.cs b/src/NSExt/Attributes/LocalizationAttribute.cs deleted file mode 100644 index 4c157a8..0000000 --- a/src/NSExt/Attributes/LocalizationAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace NSExt.Attributes; - -/// -/// 指定本地化资源类型 -/// -[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Field)] -public sealed class LocalizationAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - #pragma warning disable IDE0290 - public LocalizationAttribute(Type resourceClass) - #pragma warning restore IDE0290 - { - ResourceClass = resourceClass; - } - - /// - /// Gets or sets 资源类型 - /// - /// - /// 资源类型 - /// - public Type ResourceClass { get; set; } -} \ No newline at end of file diff --git a/src/NSExt/Attributes/ResourceDescriptionAttribute.cs b/src/NSExt/Attributes/ResourceDescriptionAttribute.cs deleted file mode 100644 index c2e4386..0000000 --- a/src/NSExt/Attributes/ResourceDescriptionAttribute.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NSExt.Attributes; - -/// -/// 本地化资源描述特性 -/// -[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Field)] -public sealed class ResourceDescriptionAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - #pragma warning disable IDE0290 - public ResourceDescriptionAttribute(string resourceName) - #pragma warning restore IDE0290 - { - ResourceName = resourceName; - } - - /// - /// 资源名称 - /// - public string ResourceName { get; set; } - - /// - /// 资源对象 - /// - public T ResourceObject { get; set; } -} \ No newline at end of file diff --git a/src/NSExt/Constant/Regexes.cs b/src/NSExt/Constant/Regexes.cs deleted file mode 100644 index 873927a..0000000 --- a/src/NSExt/Constant/Regexes.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace NSExt.Constant; -#pragma warning disable SYSLIB1045 - -/// -/// 使用 RegexGenerator 新特性会生成重复key值的xmlComment导致出错 -/// -internal static class Regexes -{ - public static readonly Regex RegexBacksLantUnicode - = new(@"\\u([a-fA-F0-9]{4})", RegexOptions.Compiled | RegexOptions.IgnoreCase); - - public static readonly Regex RegexHtmlTag = new("<[^>]*>", RegexOptions.Compiled | RegexOptions.IgnoreCase); - - public static readonly Regex RegexMobile - = new(@"^(\d{3})\d{4}(\d{4})$", RegexOptions.Compiled | RegexOptions.IgnoreCase); - - public static readonly Regex RegexPercentUnicode - = new(@"\\u([a-fA-F0-9]{4})", RegexOptions.Compiled | RegexOptions.IgnoreCase); - - public static readonly Regex RegexUpLetter = new("([A-Z])", RegexOptions.Compiled | RegexOptions.IgnoreCase); -} \ No newline at end of file diff --git a/src/NSExt/Extensions/ByteExtensions.cs b/src/NSExt/Extensions/ByteExtensions.cs deleted file mode 100644 index 5c810e0..0000000 --- a/src/NSExt/Extensions/ByteExtensions.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// ByteExtensions -/// -public static class ByteExtensions -{ - /// - /// base64编码 - /// - /// me - /// 编码后的base64字符串 - public static string Base64(this byte[] me) - { - return Convert.ToBase64String(me); - } - - /// - /// 将字节数组解码成字符串 - /// - /// me - /// 字符串使用的编码方式 - /// 解码后的原始字符串 - public static string HexDe(this byte[] me, Encoding e) - { - return e.GetString(me); - } - - /// - /// 将字节数组解码成字符串 - /// - /// me - /// 解码后的原始字符串 - public static string HexDe(this byte[] me) - { - return me.HexDe(Encoding.UTF8); - } - - /// - /// 将字节数组转换成16进制字符串 - /// - /// me - /// 是否大写 - /// 字节间分隔符 - /// 分隔符跳跃字节数 - public static string Str(this IEnumerable me, bool upperCase = true, string splitShar = "" - , int splitInterval = 1) - { - var sb = new StringBuilder(); - var i = 0; - foreach (var c in me.Select(x => x.ToString(upperCase ? "X2" : "x2", CultureInfo.InvariantCulture))) { - if (i++ % splitInterval == 0) { - _ = sb.Append(splitShar); - } - - _ = sb.Append(c); - } - - return sb.ToString(); - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/CharExtensions.cs b/src/NSExt/Extensions/CharExtensions.cs deleted file mode 100644 index 3d5438a..0000000 --- a/src/NSExt/Extensions/CharExtensions.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// CharExtensions -/// -public static class CharExtensions -{ - /// - /// 是否数字或大小写字母 - /// - public static bool IsAsciiLetterOrDigit(this char me) - { - return (((uint)me - 'A') & ~0x20) < 26 || (uint)me - '0' < 10; - } - - /// - /// 是否base64字符 - /// - public static bool IsBase64Character(this char me) - { - return IsAsciiLetterOrDigit(me) || me is '+' or '/' or '='; - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/DateTimeExtensions.cs b/src/NSExt/Extensions/DateTimeExtensions.cs deleted file mode 100644 index 1d486e8..0000000 --- a/src/NSExt/Extensions/DateTimeExtensions.cs +++ /dev/null @@ -1,110 +0,0 @@ -// ReSharper disable InconsistentNaming -// ReSharper disable UnusedMember.Global - -#pragma warning disable SA1300, IDE1006 -namespace NSExt.Extensions; - -/// -/// DateTimeExtensions -/// -public static class DateTimeExtensions -{ - /// - /// 指定时间的世界协调时的unix时间戳形式 - /// - /// me - /// unix时间戳 - public static long TimeUnixUtc(this DateTime me) - { - return (me.ToUniversalTime().Ticks - 621355968000000000) / 10000000; - } - - /// - /// 指定时间的世界协调时的unix时间戳形式(毫秒) - /// - public static long TimeUnixUtcMs(this DateTime me) - { - return (me.ToUniversalTime().Ticks - 621355968000000000) / 10000; - } - - /// - /// ToString 的 Invariant 版本 - /// - public static string ToInvString(this DateTime me) - { - return me.ToString(CultureInfo.InvariantCulture); - } - - /// - /// 将一个过去时间对象与当前时间相减转换成“xx以前”的字符串, 如2秒以前, 3天以前 - /// - /// me - /// 字符串 - public static string UtcTimeAgo(this DateTime me) - { - var ts = DateTime.UtcNow - me; - return ts.Days switch { - > 0 => ts.Days + "天前" - , _ => ts.Hours switch { - > 0 => ts.Hours + "小时前" - , _ => ts.Minutes switch { > 0 => ts.Minutes + "分钟前", _ => ts.Seconds + "秒前" } - } - }; - } - - /// - /// yyyy_MM - /// - public static string yyyy_MM(this DateTime me) - { - return me.ToString("yyyy-MM", CultureInfo.InvariantCulture); - } - - /// - /// yyyy_MM_dd - /// - public static string yyyy_MM_dd(this DateTime me) - { - return me.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); - } - - /// - /// yyyy_MM_dd_HH_mm - /// - public static string yyyy_MM_dd_HH_mm(this DateTime me) - { - return me.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture); - } - - /// - /// yyyy_MM_dd_HH_mm_ss - /// - public static string yyyy_MM_dd_HH_mm_ss(this DateTime me) - { - return me.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); - } - - /// - /// yyyy_MM_dd_HH_mm_ss_fff - /// - public static string yyyy_MM_dd_HH_mm_ss_fff(this DateTime me) - { - return me.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture); - } - - /// - /// yyyyMM - /// - public static string yyyyMM(this DateTime me) - { - return me.ToString("yyyyMM", CultureInfo.InvariantCulture); - } - - /// - /// yyyyMMdd - /// - public static string yyyyMMdd(this DateTime me) - { - return me.ToString("yyyyMMdd", CultureInfo.InvariantCulture); - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/DbCommandExtensions.cs b/src/NSExt/Extensions/DbCommandExtensions.cs deleted file mode 100644 index 62b4521..0000000 --- a/src/NSExt/Extensions/DbCommandExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// DbCommandExtensions -/// -public static class DbCommandExtensions -{ - /// - /// 格式化参数拼接成完整的SQL语句 - /// - public static string ParameterFormat(this DbCommand me) - { - var sql = me.CommandText; - - // 应逆向替换,否则由于 多个表的过滤器问题导致替换不完整 如 @TenantId1 @TenantId10 - for (var i = me.Parameters.Count - 1; i >= 0; i--) { - #pragma warning disable IDE0072 - sql = me.Parameters[i].DbType switch { - #pragma warning restore IDE0072 - DbType.String or DbType.DateTime or DbType.Date or DbType.Time or DbType.DateTime2 - or DbType.DateTimeOffset or DbType.Guid or DbType.VarNumeric or DbType.AnsiStringFixedLength - or DbType.AnsiString or DbType.StringFixedLength => sql.Replace( // - me.Parameters[i].ParameterName, "'" + me.Parameters[i].Value + "'") - , DbType.Boolean => sql.Replace( // - me.Parameters[i].ParameterName - , me.Parameters[i].Value != DBNull.Value && - Convert.ToBoolean(me.Parameters[i].Value, CultureInfo.InvariantCulture) - ? "1" - : "0") - , _ => sql.Replace(me.Parameters[i].ParameterName, me.Parameters[i].Value?.ToString()) - }; - } - - return sql; - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/DecimalExtensions.cs b/src/NSExt/Extensions/DecimalExtensions.cs deleted file mode 100644 index 7f6f46e..0000000 --- a/src/NSExt/Extensions/DecimalExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// DecimalExtensions -/// -public static class DecimalExtensions -{ - /// - /// 四舍五入后的近似值 - /// - /// me - /// 小数点位数 - /// 处理后的值 - public static decimal Round(this decimal me, int place) - { - return Math.Round(me, place); - } - - /// - /// ToString 的 Invariant 版本 - /// - public static string ToInvString(this decimal me) - { - return me.ToString(CultureInfo.InvariantCulture); - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/EnumExtensions.cs b/src/NSExt/Extensions/EnumExtensions.cs deleted file mode 100644 index b40f675..0000000 --- a/src/NSExt/Extensions/EnumExtensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.Reflection; -using NSExt.Attributes; - -namespace NSExt.Extensions; - -/// -/// EnumExtensions -/// -public static class EnumExtensions -{ - /// - /// 获取显示特性 - /// - public static DisplayAttribute GetDisplay(this Enum me) - { - return me.GetAttributeOfType(); - } - - /// - /// 获取枚举的本地化资源描述 - /// - public static string ResDesc(this Enum e) - { - var typeOfEnum = e.GetType(); - var typeOfField = typeOfEnum.GetField(Enum.GetName(typeOfEnum, e)!); - var resDescAttr = typeOfField!.GetCustomAttribute>(true); - return resDescAttr is null - ? Enum.GetName(typeOfEnum, e) - : typeof(T).GetProperty(resDescAttr.ResourceName)?.GetValue(default) as string; - } - - /// - /// 通过类泛型类型获取特性 - /// - private static T GetAttributeOfType(this Enum me) - where T : Attribute - { - return me.GetType().GetMember(me.ToString())[0].GetCustomAttributes(false).FirstOrDefault(); - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/EnumerableExtensions.cs b/src/NSExt/Extensions/EnumerableExtensions.cs deleted file mode 100644 index 08eef9f..0000000 --- a/src/NSExt/Extensions/EnumerableExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// EnumerableExtensions -/// -public static class EnumerableExtensions -{ - /// - /// 将列表转成分隔符分隔的字符串 - /// - public static string Join(this IEnumerable me, string separator) - { - return string.Join(separator, me); - } - - /// - /// 判断对象是否为null或不存在子元素(如果为集合对象) - /// - /// 对象类型 - /// me - /// 空则返回true - public static bool NullOrEmpty(this IEnumerable me) - { - return me?.Any() != true; - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/GenericExtensions.cs b/src/NSExt/Extensions/GenericExtensions.cs deleted file mode 100644 index 8015c1c..0000000 --- a/src/NSExt/Extensions/GenericExtensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// GenericExtensions -/// -public static class GenericExtensions -{ - /// - /// 从指定的对象拷贝属性 - /// - /// 对象类型 - /// me - /// 拷贝来源 - /// 需要处理的属性名 - /// True包含,false排除 - public static void CopyFrom(this T me, T copyObj, IList propNameList = null - , bool isIncludeOrExclude = false) - { - foreach (var p in me.GetType().GetProperties()) { - if (!p.CanWrite) { - continue; - } - - var isSet = isIncludeOrExclude - ? propNameList?.Contains(p.Name) ?? false - : !propNameList?.Contains(p.Name) ?? true; - if (isSet) { - p.SetValue(me, copyObj.GetType().GetProperty(p.Name)?.GetValue(copyObj, null), null); - } - } - } - - /// - /// 判断是否与某对象相等 - /// - public static T Is(this T me, T compare, T ret) - where T : struct - { - return me.Equals(compare) ? ret : me; - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/IntExtensions.cs b/src/NSExt/Extensions/IntExtensions.cs deleted file mode 100644 index ecf2270..0000000 --- a/src/NSExt/Extensions/IntExtensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// IntExtensions -/// -public static class IntExtensions -{ - /// - /// 判断枚举是否包含某个位 - /// - public static bool HasFlag(this int me, T flag) - where T : Enum - { - return ((long)me).HasFlag(flag); - } - - /// - /// 生成随机数 - /// - /// me - public static int Rand(this int[] me) - { - return new Random(Guid.NewGuid().GetHashCode()).Next(me[0], me[1]); - } - - /// - /// ToString 的 Invariant 版本 - /// - public static string ToInvString(this int me) - { - return me.ToString(CultureInfo.InvariantCulture); - } - - /// - /// 转换成ipv4 - /// - public static string ToIpV4(this int me) - { - return string.Join(".", BitConverter.GetBytes(me).Reverse()); - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/LoggerExtensions.cs b/src/NSExt/Extensions/LoggerExtensions.cs deleted file mode 100644 index 084710a..0000000 --- a/src/NSExt/Extensions/LoggerExtensions.cs +++ /dev/null @@ -1,83 +0,0 @@ -// ReSharper disable TemplateIsNotCompileTimeConstantProblem - -namespace NSExt.Extensions; - -/// -/// LoggerExtensions -/// -public static class LoggerExtensions -{ - private const string _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER - = "{Message} "; - - private static readonly Action _logDebug - = LoggerMessage.Define(LogLevel.Debug, default - , _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER); - - private static readonly Action _logError - = LoggerMessage.Define(LogLevel.Error, default - , _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER); - - private static readonly Action _logFatal - = LoggerMessage.Define(LogLevel.Critical, default - , _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER); - - private static readonly Action _logInfo - = LoggerMessage.Define(LogLevel.Information, default - , _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER); - - private static readonly Action _logWarn - = LoggerMessage.Define(LogLevel.Warning, default - , _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER); - - /// - /// Debug - /// - public static void Debug(this ILogger me, object message, [CallerMemberName] string callerName = null - , [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) - { - _logDebug(me, message.ToString(), callerName, Path.GetFileName(callerFilePath) - , callerLineNumber.ToString(CultureInfo.InvariantCulture), null); - } - - /// - /// Error - /// - public static void Error(this ILogger me, object message, [CallerMemberName] string callerName = null - , [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) - { - _logError(me, message.ToString(), callerName, Path.GetFileName(callerFilePath) - , callerLineNumber.ToString(CultureInfo.InvariantCulture), null); - } - - /// - /// Fatal - /// - public static void Fatal(this ILogger me, object message, Exception ex = null - , [CallerMemberName] string callerName = null, [CallerFilePath] string callerFilePath = null - , [CallerLineNumber] int callerLineNumber = 0) - { - _logFatal(me, message.ToString(), callerName, Path.GetFileName(callerFilePath) - , callerLineNumber.ToString(CultureInfo.InvariantCulture), ex); - } - - /// - /// Info - /// - public static void Info(this ILogger me, object message, [CallerMemberName] string callerName = null - , [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) - { - _logInfo(me, message.ToString(), callerName, Path.GetFileName(callerFilePath) - , callerLineNumber.ToString(CultureInfo.InvariantCulture), null); - } - - /// - /// Warn - /// - public static void Warn(this ILogger me, object message, [CallerMemberName] string callerName = null - , [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) - { - _logWarn(me, message.ToString(), callerName, Path.GetFileName(callerFilePath) - , callerLineNumber.ToString(CultureInfo.InvariantCulture), null); - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/LongExtensions.cs b/src/NSExt/Extensions/LongExtensions.cs deleted file mode 100644 index 6ea66b9..0000000 --- a/src/NSExt/Extensions/LongExtensions.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// LongExtensions -/// -public static class LongExtensions -{ - /// - /// 判断枚举是否包含某个位 - /// - public static bool HasFlag(this long me, T flag) - where T : Enum - { - var val = (long)(object)flag; - return (me & val) == val; - } - - /// - /// 生成随机数 - /// - /// me - public static long Rand(this long[] me) - { - return new Random(Guid.NewGuid().GetHashCode()).NextInt64(me[0], me[1]); - } - - /// - /// 1970毫秒数转换成日期对象 - /// - public static DateTime Time(this long msFrom1970) - { - return DateTime.UnixEpoch.AddMilliseconds(msFrom1970).ToLocalTime(); - } - - /// - /// ToString 的 Invariant 版本 - /// - public static string ToInvString(this long me) - { - return me.ToString(CultureInfo.InvariantCulture); - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/ObjectExtensions.cs b/src/NSExt/Extensions/ObjectExtensions.cs deleted file mode 100644 index 99c5dcc..0000000 --- a/src/NSExt/Extensions/ObjectExtensions.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Text.Json; - -namespace NSExt.Extensions; - -/// -/// ObjectExtensions -/// -public static class ObjectExtensions -{ - /// - /// 将一个对象序列化成json文本 - /// - /// me - /// json文本 - public static string Json(this object me) - { - return JsonSerializer.Serialize(me); - } - - /// - /// 将一个对象序列化成json文本 - /// - /// me - /// 序列化选项 - /// json文本 - public static string Json(this object me, JsonSerializerOptions options) - { - return JsonSerializer.Serialize(me, options); - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/StreamExtensions.cs b/src/NSExt/Extensions/StreamExtensions.cs deleted file mode 100644 index 0c8e61e..0000000 --- a/src/NSExt/Extensions/StreamExtensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// StreamExtensions -/// -public static class StreamExtensions -{ - /// - /// FirstByteIndex - /// - public static long FirstByteIndex(this Stream me, byte[] findBytes) - { - int data; - while ((data = me.ReadByte()) != -1) { - if (findBytes.Contains((byte)data)) { - return me.Position; - } - } - - return -1; - } - - /// - /// IsTextStream - /// - public static bool IsTextStream(this Stream me) - { - #pragma warning disable IDE0300 - return me.FirstByteIndex(new byte[] { 0x00, 0xff }) < 0; - #pragma warning restore IDE0300 - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/StringExtensions.cs b/src/NSExt/Extensions/StringExtensions.cs deleted file mode 100644 index ceeed7a..0000000 --- a/src/NSExt/Extensions/StringExtensions.cs +++ /dev/null @@ -1,591 +0,0 @@ -// ReSharper disable UnusedMember.Global -// ReSharper disable MemberCanBePrivate.Global - -#pragma warning disable CA1720 -using System.Security.Cryptography; -using System.Text.Json; -using NSExt.Constant; - -namespace NSExt.Extensions; - -/// -/// StringExtensions -/// -#pragma warning disable CodeLinesAnalyzer -public static class StringExtensions -{ - /// - /// aes加密 - /// - /// me - /// 密钥 - public static string Aes(this string me, string key) - { - using var aes = System.Security.Cryptography.Aes.Create(); - aes.Padding = PaddingMode.PKCS7; - aes.Mode = CipherMode.ECB; - aes.Key = key.Hex(); - using var encryptor = aes.CreateEncryptor(); - var bytes = me.Hex(); - var decrypted = encryptor.TransformFinalBlock(bytes, 0, bytes.Length); - return decrypted.Base64(); - } - - /// - /// aes解密 - /// - /// me - /// 密钥 - public static string AesDe(this string me, string key) - { - using var aes = System.Security.Cryptography.Aes.Create(); - aes.Padding = PaddingMode.PKCS7; - aes.Mode = CipherMode.ECB; - aes.Key = key.Hex(); - using var encryptor = aes.CreateDecryptor(); - var bytes = me.Base64De(); - var decrypted = encryptor.TransformFinalBlock(bytes, 0, bytes.Length); - return decrypted.HexDe(); - } - - /// - /// base64编码 - /// - /// me - /// 字符串的编码方式 - /// 编码后的base64字符串 - public static string Base64(this string me, Encoding e) - { - return e.GetBytes(me).Base64(); - } - - /// - /// base64解码 - /// - /// me - /// 解码后的原始字节数组 - public static byte[] Base64De(this string me) - { - return Convert.FromBase64String(me); - } - - /// - /// base64解码 - /// - /// me - /// 字符串的编码方式 - /// 解码后的原始字符串 - public static string Base64De(this string me, Encoding e) - { - return e.GetString(me.Base64De()); - } - - /// - /// 将易于web传输的base64web字符串转换为原生base64 - /// - /// 原生base64 - public static string Base64Sys(this string me) - { - return me.Replace("-", "+").Replace("_", "/").Replace(".", "="); - } - - /// - /// 将原生base64字符串转换成易于web传输的字符串 - /// - /// 易于web传输的字符串 - public static string Base64Web(this string me) - { - return me.Replace("+", "-").Replace("/", "_").Replace("=", "."); - } - - /// - /// 将字符串转换成日期对象 - /// - /// me - /// 转换后的日期对象 - public static DateTime DateTime(this string me) - { - return System.DateTime.Parse(me, CultureInfo.CurrentCulture); - } - - /// - /// 将字符串转换成日期对象 - /// - /// me - /// 日期格式 - /// 转换后的日期对象 - public static DateTime DateTimeExact(this string me, string format) - { - return System.DateTime.ParseExact(me, format, CultureInfo.CurrentCulture); - } - - /// - /// 将字符串转换成日期对象 - /// - /// me - /// 日期格式 - /// 转换失败时返回的日期对象 - /// 转换后的日期对象 - public static DateTime DateTimeExactTry(this string me, string format, DateTime def) - { - return !System.DateTime.TryParseExact(me, format, CultureInfo.CurrentCulture, DateTimeStyles.None, out var ret) - ? def - : ret; - } - - /// - /// 将字符串转换成日期对象 - /// - /// me - /// 转换失败时返回的日期对象 - /// 转换后的日期对象 - public static DateTime DateTimeTry(this string me, DateTime def) - { - return !System.DateTime.TryParse(me, CultureInfo.InvariantCulture, out var ret) ? def : ret; - } - - /// - /// string to decimal - /// - /// me - /// decimal - public static decimal Dec(this string me) - { - return decimal.Parse(me, CultureInfo.CurrentCulture); - } - - /// - /// 尝试将字符串转为decimal - /// - /// me - /// 转换失败后返回的默认值 - /// 转换后的decimal - public static decimal DecTry(this string me, decimal def) - { - return !decimal.TryParse(me, out var ret) ? def : ret; - } - - /// - /// string to double - /// - /// me - /// Int32 - public static double Double(this string me) - { - return double.Parse(me, CultureInfo.CurrentCulture); - } - - /// - /// 将字符串转换成枚举对象 - /// - public static T Enum(this string name) - where T : Enum - { - return (T)System.Enum.Parse(typeof(T), name, true); - } - - /// - /// 将字符串转换成枚举对象 - /// - public static T EnumTry(this string name, T def) - where T : Enum - { - return !System.Enum.TryParse(typeof(T), name, out var ret) ? def : (T)ret; - } - - /// - /// string to float - /// - /// me - /// Int32 - public static float Float(this string me) - { - return float.Parse(me, CultureInfo.CurrentCulture); - } - - /// - /// 将字符串转为guid - /// - /// me - public static Guid Guid(this string me) - { - return System.Guid.Parse(me); - } - - /// - /// 将字符串转换成guid - /// - /// me - /// 转换失败的返回值 - public static Guid Guid(this string me, Guid def) - { - return System.Guid.TryParse(me, out var ret) ? ret : def; - } - - /// - /// 将字符串转换成字节数组形式 - /// - /// me - /// 字符串使用的编码 - /// 字节数组 - public static byte[] Hex(this string me, Encoding e) - { - return e.GetBytes(me); - } - - /// - /// 将字符串转换成字节数组形式 - /// - /// me - /// 字节数组 - public static byte[] Hex(this string me) - { - return me.Hex(Encoding.UTF8); - } - - /// - /// 对一个字符串进行sha1 hash运算 - /// - /// me - /// 密钥 - /// 使用的编码 - /// hash摘要的16进制文本形式(无连字符小写) - public static string HmacSha1(this string me, string secret, Encoding e) - { - #pragma warning disable CA5350 - using var hmacSha1 = new HMACSHA1(e.GetBytes(secret)); - #pragma warning restore CA5350 - - return BitConverter.ToString(hmacSha1.ComputeHash(e.GetBytes(me))) - .Replace("-", string.Empty) - .ToLower(CultureInfo.CurrentCulture); - } - - /// - /// html编码 - /// - public static string Html(this string me) - { - return HttpUtility.HtmlEncode(me); - } - - /// - /// 解码html编码 - /// - /// me - /// 解码后的原始字符串 - public static string HtmlDe(this string me) - { - return HttpUtility.HtmlDecode(me); - } - - /// - /// string to Int32 - /// - /// me - /// Int32 - public static int Int32(this string me) - { - return int.Parse(me, CultureInfo.CurrentCulture); - } - - /// - /// 尝试将字符串转为int32 - /// - /// me - /// 转换失败后返回的默认值 - /// 转换后的int32 - public static int Int32Try(this string me, int def) - { - return !int.TryParse(me, out var ret) ? def : ret; - } - - /// - /// string to Int64 - /// - /// me - /// Int64 - public static long Int64(this string me) - { - return long.Parse(me, CultureInfo.CurrentCulture); - } - - /// - /// 尝试将字符串转为int64 - /// - /// me - /// 转换失败后返回的默认值 - /// 转换后的int64 - public static long Int64Try(this string me, long def) - { - return !long.TryParse(me, out var ret) ? def : ret; - } - - /// - /// ipv4格式转int32格式 - /// - public static int IpV4ToInt32(this string me) - { - return BitConverter.ToInt32(me.Split('.').Select(byte.Parse).Reverse().ToArray(), 0); - } - - /// - /// 是否base64字符串 - /// - /// me - public static bool IsBase64String(this string me) - { - // 一个合法的Base64,有着以下特征: - // 字符串的长度为4的整数倍。 - // 字符串的符号取值只能在A -Z, a -z, 0 -9, +, /, =共计65个字符中,且 = 如果出现就必须在结尾出现。 - if (!me.All(x => x.IsBase64Character())) { - return false; - } - - if (me.Length % 4 != 0) { - return false; - } - - var firstEqualSignPos = me.IndexOf('='); - if (firstEqualSignPos < 0) { - return true; - } - - var lastEqualSignPos = me.LastIndexOf('='); - return lastEqualSignPos == me.Length - 1 && me[firstEqualSignPos..lastEqualSignPos].All(x => x == '='); - } - - /// - /// 中文姓名打马赛克 - /// - public static string MaskChineseName(this string me) - { - return me.Length == 2 ? "*" + me[1..] : me[..1] + "*" + me[^1..]; - } - - /// - /// 对一个手机号进行掩码处理 - /// - /// me - /// 掩码后的手机号 - public static string MaskMobile(this string me) - { - return Regexes.RegexMobile.Replace(me, "$1****$2"); - } - - /// - /// 对一个字符串进行md5hash运算 - /// - /// me - /// 字符串使用的编码 - /// hash摘要的16进制文本形式(无连字符小写) - public static string Md5(this string me, Encoding e) - { - #pragma warning disable CA5351 - return BitConverter.ToString(MD5.HashData(e.GetBytes(me))) - #pragma warning restore CA5351 - .Replace("-", string.Empty) - .ToLower(CultureInfo.CurrentCulture); - } - - /// - /// 判断字符串是否为null或不存在子元素(如果为集合对象);如果为空,返回指定的默认值,否则返回字符串本身 - /// - /// me - /// 指定的默认值 - /// 如果为空,返回指定的默认值,否则返回字符串本身 - public static string NullOrEmpty(this string me, string defVal) - { - return me.AsEnumerable().NullOrEmpty() ? defVal : me; - } - - /// - /// null或空白字符 - /// - public static bool NullOrWhiteSpace(this string me) - { - return string.IsNullOrWhiteSpace(me); - } - - /// - /// 反序列化一个文件获得指定类型的数据对象 - /// - /// me - /// 序列化选项 - /// 反序列化后生成的对象 - public static T Object(this string me, JsonSerializerOptions options = null) - { - return JsonSerializer.Deserialize(me, options); - } - - /// - /// 反序列化一个文件获得指定类型的数据对象 - /// - /// me - /// 实际类型 - /// 序列化选项 - /// 反序列化后生成的对象 - public static object Object(this string me, Type type, JsonSerializerOptions options = null) - { - return JsonSerializer.Deserialize(me, type, options); - } - - /// - /// 生成密码 - /// - /// me - /// 密文 - public static string Pwd(this string me) - { - return me.Md5Hmac(me.Md5(Encoding.UTF8), Encoding.UTF8); - } - - /// - /// 移除字符串中的html标签 - /// - /// me - /// 处理之后的字符串 - public static string RemoveHtmlTag(this string me) - { - return Regexes.RegexHtmlTag.Replace(me, string.Empty); - } - - /// - /// 删除换行符 - /// - public static string RemoveWrapped(this string me) - { - return me.Replace("\r", string.Empty).Replace("\n", string.Empty); - } - - /// - /// 对一个字符串进行sha1 hash运算 - /// - /// me - /// 字符串使用的编码 - /// hash摘要的16进制文本形式(无连字符小写) - public static string Sha1(this string me, Encoding e) - { - #pragma warning disable CA5350 - return BitConverter.ToString(SHA1.HashData(e.GetBytes(me))) - #pragma warning restore CA5350 - .Replace("-", string.Empty) - .ToLower(CultureInfo.CurrentCulture); - } - - /// - /// 蛇形命名 - /// - public static string SnakeCase(this string me) - { - return Regexes.RegexUpLetter.Replace(me, "-$1").ToLower(CultureInfo.InvariantCulture).TrimStart('-'); - } - - /// - /// 截取指定长度的字符串,代替substring - /// - public static string Sub(this string me, int startIndex, int length) - { - if (startIndex + length > me.Length) { - length = me.Length - startIndex; - } - - return me.Substring(startIndex, length); - } - - /// - /// 纯文本字符串转html - /// - public static string Text2Html(this string me) - { - return $"
{me}
"; - } - - /// - /// 首字母小写 - /// - public static string ToLowerCamelCase(this string me) - { - return string.IsNullOrWhiteSpace(me) - ? me - : string.Concat( // - me[0].ToString(CultureInfo.InvariantCulture).ToLowerInvariant(), me.AsSpan(1)); - } - - /// - /// 首字母大写 - /// - public static string ToUpperCamelCase(this string me) - { - return string.IsNullOrWhiteSpace(me) ? me : string.Concat(me[0].ToString().ToUpperInvariant(), me.AsSpan(1)); - } - - /// - /// 将连续多个空格替换成一个空格 - /// - public static string TrimSpaces(this string me) - { - var ret = me.Replace(" ", " "); - - // ReSharper disable once TailRecursiveCall - return ret == me ? ret : ret.TrimSpaces(); - } - - /// - /// 将\ux0000 、 %u0000 、 &#x0000; 编码转换成可读字符串 - /// - public static string UnicodeDe(this string me) - { - const string replacement = "&#x$1;"; - if (me.Contains(@"\u")) { - return Regexes.RegexBacksLantUnicode.Replace(me, replacement).HtmlDe(); - } - - // ReSharper disable once ConvertIfStatementToReturnStatement - #pragma warning disable IDE0046 - if (me.Contains("%u")) { - #pragma warning restore IDE0046 - return Regexes.RegexPercentUnicode.Replace(me, replacement).HtmlDe(); - } - - return me.HtmlDe(); - } - - /// - /// url编码 - /// - /// me - /// url编码后的字符串 - public static string Url(this string me) - { - return Uri.EscapeDataString(me); - } - - /// - /// 解码url编码 - /// - /// me - /// 解码后的原始字符串 - public static string UrlDe(this string me) - { - return Uri.UnescapeDataString(me); - } - - /// - /// MD5 hmac编码 - /// - /// me - /// 密钥 - /// 字符串使用的编码 - /// hash摘要的16进制文本形式(无连字符小写) - private static string Md5Hmac(this string me, string key, Encoding e) - { - #pragma warning disable CA5351 - using var md5Hmac = new HMACMD5(e.GetBytes(key)); - #pragma warning restore CA5351 - return BitConverter.ToString(md5Hmac.ComputeHash(e.GetBytes(me))) - .Replace("-", string.Empty) - .ToLower(CultureInfo.CurrentCulture); - } -} -#pragma warning restore CodeLinesAnalyzer \ No newline at end of file diff --git a/src/NSExt/Extensions/TypeExtensions.cs b/src/NSExt/Extensions/TypeExtensions.cs deleted file mode 100644 index ea897bc..0000000 --- a/src/NSExt/Extensions/TypeExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// TypeExtensions -/// -public static class TypeExtensions -{ - /// - /// 搜索此成员的继承链以查找自定义属性,接口也会被搜索。 - /// - public static IEnumerable GetCustomAttributesIncludingBaseInterfaces(this Type me) - { - var attributeType = typeof(T); - return me.GetCustomAttributes(attributeType, true) - .Union(me.GetInterfaces() - .SelectMany(interfaceType => interfaceType.GetCustomAttributes(attributeType, true))) - .Cast(); - } -} \ No newline at end of file diff --git a/src/NSExt/Extensions/UriExtensions.cs b/src/NSExt/Extensions/UriExtensions.cs deleted file mode 100644 index 6f9377a..0000000 --- a/src/NSExt/Extensions/UriExtensions.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace NSExt.Extensions; - -/// -/// UriExtensions -/// -public static class UriExtensions -{ - /// - /// 移除url的Scheme - /// - public static string RemoveScheme(this Uri me) - { - return "//" + me.Authority + me.PathAndQuery; - } -} \ No newline at end of file diff --git a/src/NSExt/GlobalUsings.cs b/src/NSExt/GlobalUsings.cs deleted file mode 100644 index ce9e85d..0000000 --- a/src/NSExt/GlobalUsings.cs +++ /dev/null @@ -1,8 +0,0 @@ -global using System.Data; -global using System.Data.Common; -global using System.Globalization; -global using System.Runtime.CompilerServices; -global using System.Text; -global using System.Text.RegularExpressions; -global using System.Web; -global using Microsoft.Extensions.Logging; \ No newline at end of file diff --git a/src/NSExt/NSExt.csproj b/src/NSExt/NSExt.csproj deleted file mode 100644 index 22c816d..0000000 --- a/src/NSExt/NSExt.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/NSExt/README.md b/src/NSExt/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/stylecop.analyzers.ruleset b/stylecop.analyzers.ruleset deleted file mode 100644 index b8faaff..0000000 --- a/stylecop.analyzers.ruleset +++ /dev/null @@ -1,243 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/stylecop.json b/stylecop.json deleted file mode 100644 index ae79eec..0000000 --- a/stylecop.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", - "settings": { - "indentation": { - "useTabs": false, - "indentationSize": 4 - } - } -} \ No newline at end of file diff --git a/sync.metafiles.csx b/sync.metafiles.csx deleted file mode 100644 index 312d601..0000000 --- a/sync.metafiles.csx +++ /dev/null @@ -1,20 +0,0 @@ -using System.Text.RegularExpressions; - -var slnFile = Directory.GetFiles(@"./", "*.sln").First(); -var content = File.ReadAllText(slnFile); - -content = Regex.Replace( - content, - "Project\\(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\"\\) = \"meta\", \"meta\", \"{5198A03D-0CAC-4828-A807-34A693F73859}\"(?:.|\n)*?EndProject", - $$""" -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{5198A03D-0CAC-4828-A807-34A693F73859}" -{{'\t'}}ProjectSection(SolutionItems) = preProject -{{string.Join('\n', - Directory.GetFiles(@"./", "*").Where(x => !x.EndsWith(".sln") && !x.EndsWith(".user")) - .Select(x=>$"\t\t{Path.GetFileName(x)} = {Path.GetFileName(x)}") - )}} -{{'\t'}}EndProject -""" -); -Console.WriteLine(content); -File.WriteAllText(slnFile, content); \ No newline at end of file