From 41208a5d7f63ad595ec985d3616fbce2c9bdc4d0 Mon Sep 17 00:00:00 2001 From: tk Date: Tue, 2 Jul 2024 11:02:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E2=9C=A8=20=E6=96=B0=E5=A2=9Estrin?= =?UTF-8?q?g=E6=89=A9=E5=B1=95=E5=87=BD=E6=95=B0=20IsJsonString?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Directory.Build.props | 2 +- NSExt.sln.DotSettings | 131 +++++++----------- build/code.quality.props | 6 +- src/backend/NSExt.Tests/AllTests.cs | 19 +++ src/backend/NSExt.Tests/NSExt.Tests.csproj | 7 +- .../NSExt/Extensions/StringExtensions.cs | 20 +++ 6 files changed, 95 insertions(+), 90 deletions(-) create mode 100644 src/backend/NSExt.Tests/AllTests.cs diff --git a/Directory.Build.props b/Directory.Build.props index b2ad2a4..5d1b5a8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -26,7 +26,7 @@ $(AssemblyName) - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/NSExt.sln.DotSettings b/NSExt.sln.DotSettings index ea9fc25..0913323 100644 --- a/NSExt.sln.DotSettings +++ b/NSExt.sln.DotSettings @@ -1,58 +1,38 @@ - - Inherit - True - True - DO_NOT_SHOW - HINT - DO_NOT_SHOW - DO_NOT_SHOW - NEVER - NEVER - NEVER - NEVER - ID - IOS - IP - UI - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /> - - True - True - True - True - True - 1 - 1 + + + True + Inherit + + + True OFF - HINT + DO_NOT_SHOW + DO_NOT_SHOW + DO_NOT_SHOW + DO_NOT_SHOW + DO_NOT_SHOW + DO_NOT_SHOW + HINT + DO_NOT_SHOW + DO_NOT_SHOW + + + 1 + 1 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" /> + NEVER + NEVER + NEVER + NEVER + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="AA_BB" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Constant fields (not private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Types and namespaces"><ElementKinds><Kind Name="NAMESPACE" /><Kind Name="CLASS" /><Kind Name="STRUCT" /><Kind Name="ENUM" /><Kind Name="DELEGATE" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> + <?xml version="1.0" encoding="utf-16"?> <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> <TypePattern> @@ -93,36 +73,21 @@ </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 + True + True + True + True + + + True + + + True + True + True + True \ No newline at end of file diff --git a/build/code.quality.props b/build/code.quality.props index c9025f2..5e41197 100644 --- a/build/code.quality.props +++ b/build/code.quality.props @@ -15,15 +15,15 @@ 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 diff --git a/src/backend/NSExt.Tests/AllTests.cs b/src/backend/NSExt.Tests/AllTests.cs new file mode 100644 index 0000000..eeddbeb --- /dev/null +++ b/src/backend/NSExt.Tests/AllTests.cs @@ -0,0 +1,19 @@ +using NSExt.Extensions; +using Xunit; + +namespace NSExt; + +/// +/// 所有测试用例 +/// +public class AllTests +{ + /// + /// IsJsonString + /// + [Fact] + public void IsJsonString() + { + Assert.True("{\"a\":\"b\"}".IsJsonString()); + } +} \ No newline at end of file diff --git a/src/backend/NSExt.Tests/NSExt.Tests.csproj b/src/backend/NSExt.Tests/NSExt.Tests.csproj index 571955e..b14ac29 100644 --- a/src/backend/NSExt.Tests/NSExt.Tests.csproj +++ b/src/backend/NSExt.Tests/NSExt.Tests.csproj @@ -1,11 +1,12 @@ - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/backend/NSExt/Extensions/StringExtensions.cs b/src/backend/NSExt/Extensions/StringExtensions.cs index 80c49fe..1b3a3c9 100644 --- a/src/backend/NSExt/Extensions/StringExtensions.cs +++ b/src/backend/NSExt/Extensions/StringExtensions.cs @@ -358,6 +358,26 @@ public static class StringExtensions return lastEqualSignPos == me.Length - 1 && me[firstEqualSignPos..lastEqualSignPos].All(x => x == '='); } + /// + /// 是否json字符串 + /// + /// me + public static bool IsJsonString(this string me) + { + if (me.NullOrEmpty()) { + return false; + } + + try { + _ = JsonDocument.Parse(me); + } + catch { + return false; + } + + return true; + } + /// /// 中文姓名打马赛克 /// From 44c30a21479b59effcb3518c43804f0d3df05b9f Mon Sep 17 00:00:00 2001 From: tk Date: Tue, 2 Jul 2024 11:03:17 +0800 Subject: [PATCH 2/2] chore(release): 2.2.0 --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b940c29..bd91e93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ 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.2.0](https://github.com/nsnail/NSExt/compare/v2.1.0...v2.2.0) (2024-07-02) + + +### Features + +* ✨ 新增string扩展函数 IsJsonString ([41208a5](https://github.com/nsnail/NSExt/commit/41208a5d7f63ad595ec985d3616fbce2c9bdc4d0)) +* ✨ 新增string扩展函数 IsJsonString ([#19](https://github.com/nsnail/NSExt/issues/19)) ([32b7bdf](https://github.com/nsnail/NSExt/commit/32b7bdf700f694fec7f5dcef43dc05244dcd02d5)) +* ✨ 异步累加器函数 ([#17](https://github.com/nsnail/NSExt/issues/17)) ([3de9d3b](https://github.com/nsnail/NSExt/commit/3de9d3b8d06143c93c9acad43df22eb09242ac29)) + ## [2.1.0](https://github.com/nsnail/NSExt/compare/v2.0.11...v2.1.0) (2024-03-01) diff --git a/package.json b/package.json index 3702896..950910a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "2.1.0", + "version": "2.2.0", "devDependencies": { "cz-git": "^1.7.1", "commitizen": "^4.3.0",