diff --git a/.gitattributes b/.gitattributes index 1ff0c42..a1e1e97 100644 --- a/.gitattributes +++ b/.gitattributes @@ -60,4 +60,4 @@ #*.pdf diff=astextplain #*.PDF diff=astextplain #*.rtf diff=astextplain -#*.RTF diff=astextplain +#*.RTF diff=astextplain \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7c237c8..8d5a8e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ +pkg build bin obj -bin\log packages +Migrations _gsdata_ _ReSharper* TestResults diff --git a/.tgitconfig b/.tgitconfig new file mode 100644 index 0000000..c98b9ad --- /dev/null +++ b/.tgitconfig @@ -0,0 +1,4 @@ +[hook "startcommit"] + cmdline = code-format.cmd + wait = true + show = true \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..371971c --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,7 @@ + + + ../build/temp/bin + ../build/temp/obj + ../build/temp/obj + + \ No newline at end of file diff --git a/code-format.cmd b/code-format.cmd new file mode 100644 index 0000000..51fa0a1 --- /dev/null +++ b/code-format.cmd @@ -0,0 +1,3 @@ +do.exe trim-utf8-bom +do.exe remove-whitespace +do.exe convert-lf \ No newline at end of file diff --git a/doc/README.md b/doc/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/git-clean.ps1 b/git-clean.ps1 new file mode 100644 index 0000000..5f7b39a --- /dev/null +++ b/git-clean.ps1 @@ -0,0 +1 @@ +git reset --hard | git clean -d -fx . \ No newline at end of file diff --git a/lib/README.md b/lib/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/script/build-and-push.ps1 b/push2nuget.ps1 similarity index 63% rename from script/build-and-push.ps1 rename to push2nuget.ps1 index 5cd5b3d..68808a9 100644 --- a/script/build-and-push.ps1 +++ b/push2nuget.ps1 @@ -1,4 +1,3 @@ -# 定义参数 Param( # Nuget APIKey [string] $apikey @@ -6,18 +5,18 @@ Param( if ($apikey -eq $null -or $apikey -eq "") { - Write-Error "必须指定apiKey"; + Write-Error "require apiKey"; return; } -rm -r ../build/nupkgs/ -dotnet build -c Release ../src/NSExt.sln -$files = Get-ChildItem -Path ../build/nupkgs/ -Filter *.nupkg +rm -r ./build/nupkgs +dotnet build -c Release ./src/NSExt.sln +$files = Get-ChildItem -Path ./build/nupkgs/ -Filter *.nupkg foreach($file in $files) { dotnet nuget push $file.fullName --skip-duplicate --api-key $apikey --source https://api.nuget.org/v3/index.json } -$files = Get-ChildItem -Path ../build/nupkgs/ -Filter *.snupkg +$files = Get-ChildItem -Path ./build/nupkgs/ -Filter *.snupkg foreach($file in $files) { dotnet nuget push $file.fullName --skip-duplicate --api-key $apikey --source https://api.nuget.org/v3/index.json diff --git a/res/README.md b/res/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/script/README.md b/script/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/NSExt.sln.DotSettings b/src/NSExt.sln.DotSettings index e09be4f..f7cba85 100644 --- a/src/NSExt.sln.DotSettings +++ b/src/NSExt.sln.DotSettings @@ -1,95 +1,45 @@ - DO_NOT_SHOW - DO_NOT_SHOW - <?xml version="1.0" encoding="utf-16"?><Profile name="Built-in: Full Cleanup With File Header"><AspOptimizeRegisterDirectives>True</AspOptimizeRegisterDirectives><CppAddTypenameTemplateKeywords>True</CppAddTypenameTemplateKeywords><CppRemoveCastDescriptor>True</CppRemoveCastDescriptor><CppRemoveElseKeyword>True</CppRemoveElseKeyword><CppShortenQualifiedName>True</CppShortenQualifiedName><CppDeleteRedundantSpecifier>True</CppDeleteRedundantSpecifier><CppRemoveStatement>True</CppRemoveStatement><CppDeleteRedundantTypenameTemplateKeywords>True</CppDeleteRedundantTypenameTemplateKeywords><CppCStyleToStaticCastDescriptor>True</CppCStyleToStaticCastDescriptor><CppReplaceExpressionWithBooleanConst>True</CppReplaceExpressionWithBooleanConst><CppMakeIfConstexpr>True</CppMakeIfConstexpr><CppMakePostfixOperatorPrefix>True</CppMakePostfixOperatorPrefix><CppChangeSmartPointerToMakeFunction>True</CppChangeSmartPointerToMakeFunction><CppReplaceThrowWithRethrowFix>True</CppReplaceThrowWithRethrowFix><CppTypeTraitAliasDescriptor>True</CppTypeTraitAliasDescriptor><CppReplaceExpressionWithNullptr>True</CppReplaceExpressionWithNullptr><CppReplaceTieWithStructuredBindingDescriptor>True</CppReplaceTieWithStructuredBindingDescriptor><CppUseAssociativeContainsDescriptor>True</CppUseAssociativeContainsDescriptor><CppUseEraseAlgorithmDescriptor>True</CppUseEraseAlgorithmDescriptor><CppCodeStyleCleanupDescriptor ArrangeBraces="True" ArrangeAuto="True" ArrangeFunctionDeclarations="True" ArrangeNestedNamespaces="True" ArrangeTypeAliases="True" ArrangeCVQualifiers="True" ArrangeSlashesInIncludeDirectives="True" ArrangeOverridingFunctions="True" SortIncludeDirectives="True" SortMemberInitializers="True" /><CppReformatCode>True</CppReformatCode><CSReorderTypeMembers>True</CSReorderTypeMembers><CSCodeStyleAttributes ArrangeVarStyle="True" ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" ArrangeArgumentsStyle="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeCodeBodyStyle="True" ArrangeTrailingCommas="True" ArrangeObjectCreation="True" ArrangeDefaultValue="True" ArrangeNamespaces="True" /><RemoveCodeRedundanciesVB>True</RemoveCodeRedundanciesVB><Xaml.RedundantFreezeAttribute>True</Xaml.RedundantFreezeAttribute><Xaml.RemoveRedundantModifiersAttribute>True</Xaml.RemoveRedundantModifiersAttribute><Xaml.RemoveRedundantNameAttribute>True</Xaml.RemoveRedundantNameAttribute><Xaml.RemoveRedundantResource>True</Xaml.RemoveRedundantResource><Xaml.RemoveRedundantCollectionProperty>True</Xaml.RemoveRedundantCollectionProperty><Xaml.RemoveRedundantAttachedPropertySetter>True</Xaml.RemoveRedundantAttachedPropertySetter><Xaml.RemoveRedundantStyledValue>True</Xaml.RemoveRedundantStyledValue><Xaml.RemoveRedundantNamespaceAlias>True</Xaml.RemoveRedundantNamespaceAlias><Xaml.RemoveForbiddenResourceName>True</Xaml.RemoveForbiddenResourceName><Xaml.RemoveRedundantGridDefinitionsAttribute>True</Xaml.RemoveRedundantGridDefinitionsAttribute><Xaml.RemoveRedundantUpdateSourceTriggerAttribute>True</Xaml.RemoveRedundantUpdateSourceTriggerAttribute><Xaml.RemoveRedundantBindingModeAttribute>True</Xaml.RemoveRedundantBindingModeAttribute><Xaml.RemoveRedundantGridSpanAttribut>True</Xaml.RemoveRedundantGridSpanAttribut><XMLReformatCode>True</XMLReformatCode><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><CSArrangeQualifiers>True</CSArrangeQualifiers><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><HtmlReformatCode>True</HtmlReformatCode><VBOptimizeImports>True</VBOptimizeImports><VBShortenReferences>True</VBShortenReferences><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><VBReformatCode>True</VBReformatCode><VBFormatDocComments>True</VBFormatDocComments><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><FormatAttributeQuoteDescriptor>True</FormatAttributeQuoteDescriptor><IDEA_SETTINGS>&lt;profile version="1.0"&gt; - &lt;option name="myName" value="Built-in: Full Cleanup With File Header" /&gt; -&lt;/profile&gt;</IDEA_SETTINGS><RIDER_SETTINGS>&lt;profile&gt; - &lt;Language id="CSS"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;Rearrange&gt;true&lt;/Rearrange&gt; - &lt;/Language&gt; - &lt;Language id="EditorConfig"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; - &lt;Language id="HTML"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;Rearrange&gt;true&lt;/Rearrange&gt; - &lt;OptimizeImports&gt;true&lt;/OptimizeImports&gt; - &lt;/Language&gt; - &lt;Language id="HTTP Request"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; - &lt;Language id="Handlebars"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; - &lt;Language id="Ini"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; - &lt;Language id="JSON"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; - &lt;Language id="Jade"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; - &lt;Language id="JavaScript"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;Rearrange&gt;true&lt;/Rearrange&gt; - &lt;OptimizeImports&gt;true&lt;/OptimizeImports&gt; - &lt;/Language&gt; - &lt;Language id="Markdown"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; - &lt;Language id="Properties"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; - &lt;Language id="RELAX-NG"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; - &lt;Language id="SQL"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; - &lt;Language id="XML"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;Rearrange&gt;true&lt;/Rearrange&gt; - &lt;OptimizeImports&gt;true&lt;/OptimizeImports&gt; - &lt;/Language&gt; - &lt;Language id="yaml"&gt; - &lt;Reformat&gt;true&lt;/Reformat&gt; - &lt;/Language&gt; -&lt;/profile&gt;</RIDER_SETTINGS><CSUpdateFileHeader>True</CSUpdateFileHeader><CppUpdateFileHeader>True</CppUpdateFileHeader></Profile> - <?xml version="1.0" encoding="utf-16"?> -<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> - <TypePattern DisplayName="Type Pattern"> - <Entry DisplayName="Entry"> - <Entry.Match> - <Kind Is="Property" /> - </Entry.Match> - <Entry.SortBy> - <Name /> - </Entry.SortBy> - </Entry> - </TypePattern> + <?xml version="1.0" encoding="utf-16"?> +<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> + <TypePattern> + <Entry> + <Entry.SortBy> + <Kind> + <Kind.Order> + <DeclarationKind>Interface</DeclarationKind> + <DeclarationKind>Class</DeclarationKind> + <DeclarationKind>Enum</DeclarationKind> + <DeclarationKind>Struct</DeclarationKind> + <DeclarationKind>Delegate</DeclarationKind> + <DeclarationKind>Event</DeclarationKind> + <DeclarationKind>Constant</DeclarationKind> + <DeclarationKind>Field</DeclarationKind> + <DeclarationKind>Property</DeclarationKind> + <DeclarationKind>Constructor</DeclarationKind> + <DeclarationKind>Destructor</DeclarationKind> + <DeclarationKind>Indexer</DeclarationKind> + <DeclarationKind>Method</DeclarationKind> + </Kind.Order> + </Kind> + <Access> + <Access.Order> + <AccessModifier>Private</AccessModifier> + <AccessModifier>PrivateProtected</AccessModifier> + <AccessModifier>Protected</AccessModifier> + <AccessModifier>ProtectedInternal</AccessModifier> + <AccessModifier>Internal</AccessModifier> + <AccessModifier>Public</AccessModifier> + </Access.Order> + </Access> + <Name /> + </Entry.SortBy> + </Entry> + </TypePattern> </Patterns> - DI - DO - IV <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> + <Policy Inspect="True" Prefix="_" Suffix="" Style="AA_BB" /> <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> - True - @program: $PROJECT$ -@file: $FILENAME$ -@author: tao ke -@mailto: taokeu@gmail.com -@created: $CREATED_MONTH$/$CREATED_DAY$/$CREATED_YEAR$ $CREATED_TIME$ - - True - True - True - True - True - True - True - True - True - True \ No newline at end of file + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + False + HINT + \ No newline at end of file diff --git a/src/NSExt/Extensions/LoggerExtensions.cs b/src/NSExt/Extensions/LoggerExtensions.cs index a74b89b..ef63a7f 100644 --- a/src/NSExt/Extensions/LoggerExtensions.cs +++ b/src/NSExt/Extensions/LoggerExtensions.cs @@ -10,7 +10,7 @@ public static class LoggerExtensions int callerLineNumber) { return - $"{message} "; + $"{message} "; } public static void Debug(this ILogger me, diff --git a/src/NSExt/Extensions/StringExtensions.cs b/src/NSExt/Extensions/StringExtensions.cs index 2d6de9f..55ba47d 100644 --- a/src/NSExt/Extensions/StringExtensions.cs +++ b/src/NSExt/Extensions/StringExtensions.cs @@ -8,7 +8,7 @@ namespace NSExt.Extensions; public static class StringExtensions { - private static readonly JsonSerializerOptions _DEFAULT_JSON_SERIALIZER_OPTIONS = + private static readonly JsonSerializerOptions _defaultJsonSerializerOptions = default(JsonSerializerOptions).NewJsonSerializerOptions(); /// @@ -300,6 +300,16 @@ public static class StringExtensions .ToLower(CultureInfo.CurrentCulture); } + /// + /// html缂栫爜 + /// + /// + /// + public static string Html(this string me) + { + return HttpUtility.HtmlEncode(me); + } + /// /// 瑙g爜html缂栫爜 /// @@ -450,7 +460,7 @@ public static class StringExtensions /// 鍙嶅簭鍒楀寲鍚庣敓鎴愮殑瀵硅薄 public static T Object(this string me, JsonSerializerOptions options = null) { - return JsonSerializer.Deserialize(me, options ?? _DEFAULT_JSON_SERIALIZER_OPTIONS); + return JsonSerializer.Deserialize(me, options ?? _defaultJsonSerializerOptions); } @@ -463,7 +473,7 @@ public static class StringExtensions /// 鍙嶅簭鍒楀寲鍚庣敓鎴愮殑瀵硅薄 public static object Object(this string me, Type type, JsonSerializerOptions options = null) { - return JsonSerializer.Deserialize(me, type, options ?? _DEFAULT_JSON_SERIALIZER_OPTIONS); + return JsonSerializer.Deserialize(me, type, options ?? _defaultJsonSerializerOptions); } diff --git a/src/NSExt/NSExt.csproj b/src/NSExt/NSExt.csproj index ac83bf8..f120607 100644 --- a/src/NSExt/NSExt.csproj +++ b/src/NSExt/NSExt.csproj @@ -3,7 +3,7 @@ net6.0;net7.0 enable - 1.0.3 + 1.0.4