From ec380add5ffe1316a939d455b7564b208325d6f5 Mon Sep 17 00:00:00 2001 From: tk Date: Thu, 28 Sep 2023 09:36:35 +0800 Subject: [PATCH] [BLD] [SKIP CI] --- .gitignore | 5 +- .tgitconfig | 2 +- AddMetaFilesToSln.csx | 14 -- CodeCleanupOnSave.csx | 27 --- Directory.Build.props | 15 +- ImageOptimize.csx | 45 ----- NSExt.sln | 16 +- NSExt.sln.DotSettings | 49 ++++- StyleCopAnalyzers.ruleset | 221 ----------------------- code-format.cmd | 3 - code.cleanup.full.ps1 | 1 + code.quality.props | 12 +- dot.clean.cmd | 3 + dotnet-tools.json | 24 ++- git-clean.cmd | 2 - git.pr.ps1 | 26 +++ git.rc.ps1 | 6 + global.json | 16 +- image.optimize.csx | 65 +++++++ nuget.config | 8 + packable.props | 18 ++ src/NSExt.Tests/NSExt.Tests.csproj | 4 +- src/NSExt.Tests/TestCase.cs | 61 +++---- src/NSExt/Constant/Regexes.cs | 8 +- src/NSExt/Extensions/LoggerExtensions.cs | 12 +- src/NSExt/Extensions/StringExtensions.cs | 2 +- src/NSExt/NSExt.csproj | 29 +-- sync.metafiles.csx | 20 ++ 28 files changed, 301 insertions(+), 413 deletions(-) delete mode 100644 AddMetaFilesToSln.csx delete mode 100644 CodeCleanupOnSave.csx delete mode 100644 ImageOptimize.csx delete mode 100644 StyleCopAnalyzers.ruleset delete mode 100644 code-format.cmd create mode 100644 code.cleanup.full.ps1 create mode 100644 dot.clean.cmd delete mode 100644 git-clean.cmd create mode 100644 git.pr.ps1 create mode 100644 git.rc.ps1 create mode 100644 image.optimize.csx create mode 100644 nuget.config create mode 100644 packable.props create mode 100644 sync.metafiles.csx diff --git a/.gitignore b/.gitignore index 9865879..acde096 100644 --- a/.gitignore +++ b/.gitignore @@ -400,5 +400,6 @@ FodyWeavers.xsd # User Define dist/ -nuget.config -*.[Dd]esigner.cs \ No newline at end of file +refs/ +*.[Dd]esigner.cs +*.db diff --git a/.tgitconfig b/.tgitconfig index 380a28a..cea19aa 100644 --- a/.tgitconfig +++ b/.tgitconfig @@ -1,4 +1,4 @@ [hook "startcommit"] - cmdline = code-format.cmd + cmdline = dot.clean.cmd wait = true show = true \ No newline at end of file diff --git a/AddMetaFilesToSln.csx b/AddMetaFilesToSln.csx deleted file mode 100644 index b378f00..0000000 --- a/AddMetaFilesToSln.csx +++ /dev/null @@ -1,14 +0,0 @@ -using System.Text.RegularExpressions; - -var slnFile = Directory.GetFiles(@".", "*.sln").First(); - var content = File.ReadAllText(slnFile); - content = Regex.Replace(content,@"ProjectSection\(SolutionItems\) = preProject(?:.|\n)*?EndProjectSection", - $""" -ProjectSection(SolutionItems) = preProject -{string.Join('\n', - Directory.GetFiles(@".", "*").Where(x => !x.EndsWith(".sln")) - .Select(x=>$"\t\t{Path.GetFileName(x)} = {Path.GetFileName(x)}"))} -{'\t'}EndProjectSection -"""); - Console.WriteLine(content); - File.WriteAllText(slnFile, content); \ No newline at end of file diff --git a/CodeCleanupOnSave.csx b/CodeCleanupOnSave.csx deleted file mode 100644 index 7dcefb9..0000000 --- a/CodeCleanupOnSave.csx +++ /dev/null @@ -1,27 +0,0 @@ -#r "nuget: Newtonsoft.Json, 13.0.0" - -using System.Xml; -using System.IO; -using Newtonsoft.Json.Linq; - -var path = Directory.GetFiles(@".idea", "workspace.xml", SearchOption.AllDirectories).First(); -XmlDocument xdoc = new XmlDocument(); -using(var fs = File.Open(path, FileMode.Open)){ - xdoc.Load(fs); - fs.Seek(0, SeekOrigin.Begin); - var propertiesComponent = xdoc.SelectSingleNode("""//component[@name="PropertiesComponent"]"""); - var jsonStr = propertiesComponent.InnerText; - var jsonObj = JObject.Parse(jsonStr); - var keyToStringObj = jsonObj["keyToString"] as JObject; - if (keyToStringObj.ContainsKey("rider.code.cleanup.on.save")) return; - - keyToStringObj.Add(new JProperty("rider.code.cleanup.on.save", "true")); - var newNode = xdoc.CreateCDataSection(jsonObj.ToString()); - propertiesComponent.InnerText=string.Empty; - propertiesComponent.AppendChild(newNode); - var settings = new XmlWriterSettings { Indent = true }; - using(var writer = XmlWriter.Create(fs, settings)){ - xdoc.WriteTo(writer); - } - -} \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index dbb8fe9..6a86153 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,8 +6,21 @@ $(SolutionDir)/dist/$(MSBuildProjectName)/obj $(SolutionDir)/dist/$(MSBuildProjectName)/bin © 2006-2023 nsnail + A .NET extension function library false + true enable - net7.0 + beta + NSExt + git + https://github.com/nsnail/NSExt.git + net7.0;net8.0 + $(AssemblyName) + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + \ No newline at end of file diff --git a/ImageOptimize.csx b/ImageOptimize.csx deleted file mode 100644 index 8e6aca7..0000000 --- a/ImageOptimize.csx +++ /dev/null @@ -1,45 +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/NSExt.sln b/NSExt.sln index 45e3c42..5897daf 100644 --- a/NSExt.sln +++ b/NSExt.sln @@ -3,31 +3,33 @@ 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}") = "meta", "meta", "{85E669CB-FC0A-4C1D-92DE-38D0662C257D}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{5198A03D-0CAC-4828-A807-34A693F73859}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitattributes = .gitattributes .gitignore = .gitignore .tgitconfig = .tgitconfig - AddMetaFilesToSln.csx = AddMetaFilesToSln.csx build.cake = build.cake - code-format.cmd = code-format.cmd + code.cleanup.full.ps1 = code.cleanup.full.ps1 code.quality.props = code.quality.props - CodeCleanupOnSave.csx = CodeCleanupOnSave.csx Directory.Build.props = Directory.Build.props + dot.clean.cmd = dot.clean.cmd dotnet-tools.json = dotnet-tools.json - git-clean.cmd = git-clean.cmd + git.pr.ps1 = git.pr.ps1 + git.rc.ps1 = git.rc.ps1 global.json = global.json - ImageOptimize.csx = ImageOptimize.csx + image.optimize.csx = image.optimize.csx key.snk = key.snk LICENSE = LICENSE logo.png = logo.png NSExt.sln.DotSettings = NSExt.sln.DotSettings - NSExt.sln.DotSettings.user = NSExt.sln.DotSettings.user + nuget.config = nuget.config + packable.props = packable.props 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}" diff --git a/NSExt.sln.DotSettings b/NSExt.sln.DotSettings index 7c44752..30a9cb5 100644 --- a/NSExt.sln.DotSettings +++ b/NSExt.sln.DotSettings @@ -1,8 +1,23 @@ + Inherit + True + DO_NOT_SHOW DO_NOT_SHOW DO_NOT_SHOW + NEVER + NEVER NEVER - False + NEVER + ID + IOS + IP + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /> + + True + True + True + True + True 1 1 OFF @@ -55,5 +70,37 @@ </Entry> </TypePattern> </Patterns> + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True \ No newline at end of file diff --git a/StyleCopAnalyzers.ruleset b/StyleCopAnalyzers.ruleset deleted file mode 100644 index d318627..0000000 --- a/StyleCopAnalyzers.ruleset +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/code-format.cmd b/code-format.cmd deleted file mode 100644 index dd2fd79..0000000 --- a/code-format.cmd +++ /dev/null @@ -1,3 +0,0 @@ -dot rbom -w -dot trim -w -dot tolf -w \ No newline at end of file diff --git a/code.cleanup.full.ps1 b/code.cleanup.full.ps1 new file mode 100644 index 0000000..5b5c370 --- /dev/null +++ b/code.cleanup.full.ps1 @@ -0,0 +1 @@ +dotnet jb cleanupcode --no-build ./NSExt.sln \ No newline at end of file diff --git a/code.quality.props b/code.quality.props index b9f7446..7e4518a 100644 --- a/code.quality.props +++ b/code.quality.props @@ -1,6 +1,8 @@ $(SolutionDir)/stylecop.analyzers.ruleset + + true true true @@ -17,7 +19,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -33,9 +35,9 @@ 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 new file mode 100644 index 0000000..3eec6ef --- /dev/null +++ b/dot.clean.cmd @@ -0,0 +1,3 @@ +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 1158904..d2c1b28 100644 --- a/dotnet-tools.json +++ b/dotnet-tools.json @@ -1,6 +1,24 @@ { - "version": 1, - "isRoot": true, - "tools": { + "version": 1, + "isRoot": true, + "tools": { + "cake.tool": { + "version": "3.1.0", + "commands": [ + "dotnet-cake" + ] + }, + "dotnet-script": { + "version": "1.4.0", + "commands": [ + "dotnet-script" + ] + }, + "jetbrains.resharper.globaltools": { + "version": "2023.2.0", + "commands": [ + "jb" + ] } + } } \ No newline at end of file diff --git a/git-clean.cmd b/git-clean.cmd deleted file mode 100644 index 07b006c..0000000 --- a/git-clean.cmd +++ /dev/null @@ -1,2 +0,0 @@ -git reset --hard -git clean -d -fx . \ No newline at end of file diff --git a/git.pr.ps1 b/git.pr.ps1 new file mode 100644 index 0000000..2b68a89 --- /dev/null +++ b/git.pr.ps1 @@ -0,0 +1,26 @@ +$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 new file mode 100644 index 0000000..b72db93 --- /dev/null +++ b/git.rc.ps1 @@ -0,0 +1,6 @@ +$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 0e46db0..8947643 100644 --- a/global.json +++ b/global.json @@ -1,10 +1,10 @@ { - "sdk": { - "version": "7.0.100", - "allowPrerelease": true, - "rollForward": "major" - }, - "tools": { - "dotnet": "7.0.100" - } + "sdk": { + "version": "7.0.0", + "rollForward": "latestMajor", + "allowPrerelease": true + }, + "tools": { + "dotnet": "7.0.0" + } } \ No newline at end of file diff --git a/image.optimize.csx b/image.optimize.csx new file mode 100644 index 0000000..e43a4d4 --- /dev/null +++ b/image.optimize.csx @@ -0,0 +1,65 @@ +/* + 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/nuget.config b/nuget.config new file mode 100644 index 0000000..eb8bbca --- /dev/null +++ b/nuget.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/packable.props b/packable.props new file mode 100644 index 0000000..ef69428 --- /dev/null +++ b/packable.props @@ -0,0 +1,18 @@ + + + ../../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/src/NSExt.Tests/NSExt.Tests.csproj b/src/NSExt.Tests/NSExt.Tests.csproj index 18c41ba..f770abf 100644 --- a/src/NSExt.Tests/NSExt.Tests.csproj +++ b/src/NSExt.Tests/NSExt.Tests.csproj @@ -1,7 +1,7 @@ - - + + diff --git a/src/NSExt.Tests/TestCase.cs b/src/NSExt.Tests/TestCase.cs index dadfcdc..3164751 100644 --- a/src/NSExt.Tests/TestCase.cs +++ b/src/NSExt.Tests/TestCase.cs @@ -1,8 +1,3 @@ -using NSExt.Attributes; -using NSExt.Extensions; -using Xunit; -using Xunit.Abstractions; - namespace NSExt.Tests; /// @@ -10,32 +5,32 @@ 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); - } + // 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/Constant/Regexes.cs b/src/NSExt/Constant/Regexes.cs index 588297e..873927a 100644 --- a/src/NSExt/Constant/Regexes.cs +++ b/src/NSExt/Constant/Regexes.cs @@ -2,20 +2,20 @@ namespace NSExt.Constant; #pragma warning disable SYSLIB1045 /// -/// 使用 RegexGenerator 新特性会生成重复key值的xmlcomment导致出错 +/// 使用 RegexGenerator 新特性会生成重复key值的xmlComment导致出错 /// internal static class Regexes { public static readonly Regex RegexBacksLantUnicode - = new("\\\\u([a-fA-F0-9]{4})", RegexOptions.Compiled | RegexOptions.IgnoreCase); + = 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); + = 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); + = 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/LoggerExtensions.cs b/src/NSExt/Extensions/LoggerExtensions.cs index c323e99..084710a 100644 --- a/src/NSExt/Extensions/LoggerExtensions.cs +++ b/src/NSExt/Extensions/LoggerExtensions.cs @@ -7,28 +7,28 @@ namespace NSExt.Extensions; /// public static class LoggerExtensions { - private const string _MESSAGE_S_THREADID_CALLERNAME_CALLERFILEPATH_CALLERLINENUMBER + 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_THREADID_CALLERNAME_CALLERFILEPATH_CALLERLINENUMBER); + , _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER); private static readonly Action _logError = LoggerMessage.Define(LogLevel.Error, default - , _MESSAGE_S_THREADID_CALLERNAME_CALLERFILEPATH_CALLERLINENUMBER); + , _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER); private static readonly Action _logFatal = LoggerMessage.Define(LogLevel.Critical, default - , _MESSAGE_S_THREADID_CALLERNAME_CALLERFILEPATH_CALLERLINENUMBER); + , _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER); private static readonly Action _logInfo = LoggerMessage.Define(LogLevel.Information, default - , _MESSAGE_S_THREADID_CALLERNAME_CALLERFILEPATH_CALLERLINENUMBER); + , _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER); private static readonly Action _logWarn = LoggerMessage.Define(LogLevel.Warning, default - , _MESSAGE_S_THREADID_CALLERNAME_CALLERFILEPATH_CALLERLINENUMBER); + , _MESSAGE_S_THREAD_ID_CALLER_NAME_CALLER_FILE_PATH_CALLER_LINE_NUMBER); /// /// Debug diff --git a/src/NSExt/Extensions/StringExtensions.cs b/src/NSExt/Extensions/StringExtensions.cs index 17e37dc..ceeed7a 100644 --- a/src/NSExt/Extensions/StringExtensions.cs +++ b/src/NSExt/Extensions/StringExtensions.cs @@ -476,7 +476,7 @@ public static class StringExtensions /// /// 蛇形命名 /// - public static string Snakecase(this string me) + public static string SnakeCase(this string me) { return Regexes.RegexUpLetter.Replace(me, "-$1").ToLower(CultureInfo.InvariantCulture).TrimStart('-'); } diff --git a/src/NSExt/NSExt.csproj b/src/NSExt/NSExt.csproj index 250cd45..51325b9 100644 --- a/src/NSExt/NSExt.csproj +++ b/src/NSExt/NSExt.csproj @@ -1,33 +1,8 @@ - - ../../key.snk - false - A .NET extension function library - true - true - true - true - true - true - logo.png - MIT - https://github.com/nsnail/ns-ext.git - extensions - NSExt - true - git - https://github.com/nsnail/ns-ext.git - true - snupkg - $(AssemblyName) - + - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/sync.metafiles.csx b/sync.metafiles.csx new file mode 100644 index 0000000..312d601 --- /dev/null +++ b/sync.metafiles.csx @@ -0,0 +1,20 @@ +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