From d9aae8fe956644f63fac6f1201285a8a5a8573c9 Mon Sep 17 00:00:00 2001 From: nsnail Date: Sun, 4 Dec 2022 22:22:35 +0800 Subject: [PATCH] --- .editorconfig | 45 + .gitignore | 816 +++++++++++++++++- .tgitconfig | 6 +- Directory.Build.props | 14 + LICENSE | 21 + NSExt.sln | 22 + code-format.cmd | 6 +- ...Ext.sln.DotSettings => dot.sln.DotSettings | 19 +- global.json | 10 + src/.editorconfig | 89 -- src/Directory.Build.props | 18 - src/{NSExt => }/Extensions/ByteExtensions.cs | 0 src/{NSExt => }/Extensions/CharExtensions.cs | 0 .../Extensions/DateTimeExtensions.cs | 0 .../Extensions/DbCommandExtensions.cs | 10 +- .../Extensions/DecimalExtensions.cs | 0 src/{NSExt => }/Extensions/EnumExtensions.cs | 0 .../Extensions/EnumerableExtensions.cs | 0 .../Extensions/GenericExtensions.cs | 6 +- src/{NSExt => }/Extensions/IntExtensions.cs | 0 .../JsonSerializerOptionsExtensions.cs | 23 + src/Extensions/LoggerExtensions.cs | 49 ++ src/{NSExt => }/Extensions/LongExtensions.cs | 0 .../Extensions/ObjectExtensions.cs | 7 +- .../Extensions/StreamExtensions.cs | 5 +- .../Extensions/StringExtensions.cs | 20 +- src/{NSExt => }/Extensions/TypeExtensions.cs | 0 src/{NSExt => }/Extensions/UriExtensions.cs | 0 src/{NSExt => }/GlobalUsings.cs | 0 src/{NSExt => }/NSExt.csproj | 2 +- src/NSExt.sln | 16 - .../JsonSerializerOptionsExtensions.cs | 21 - src/NSExt/Extensions/LoggerExtensions.cs | 66 -- 33 files changed, 1020 insertions(+), 271 deletions(-) create mode 100644 .editorconfig create mode 100644 LICENSE create mode 100644 NSExt.sln rename src/NSExt.sln.DotSettings => dot.sln.DotSettings (62%) create mode 100644 global.json delete mode 100644 src/.editorconfig delete mode 100644 src/Directory.Build.props rename src/{NSExt => }/Extensions/ByteExtensions.cs (100%) rename src/{NSExt => }/Extensions/CharExtensions.cs (100%) rename src/{NSExt => }/Extensions/DateTimeExtensions.cs (100%) rename src/{NSExt => }/Extensions/DbCommandExtensions.cs (67%) rename src/{NSExt => }/Extensions/DecimalExtensions.cs (100%) rename src/{NSExt => }/Extensions/EnumExtensions.cs (100%) rename src/{NSExt => }/Extensions/EnumerableExtensions.cs (100%) rename src/{NSExt => }/Extensions/GenericExtensions.cs (82%) rename src/{NSExt => }/Extensions/IntExtensions.cs (100%) create mode 100644 src/Extensions/JsonSerializerOptionsExtensions.cs create mode 100644 src/Extensions/LoggerExtensions.cs rename src/{NSExt => }/Extensions/LongExtensions.cs (100%) rename src/{NSExt => }/Extensions/ObjectExtensions.cs (54%) rename src/{NSExt => }/Extensions/StreamExtensions.cs (79%) rename src/{NSExt => }/Extensions/StringExtensions.cs (96%) rename src/{NSExt => }/Extensions/TypeExtensions.cs (100%) rename src/{NSExt => }/Extensions/UriExtensions.cs (100%) rename src/{NSExt => }/GlobalUsings.cs (100%) rename src/{NSExt => }/NSExt.csproj (90%) delete mode 100644 src/NSExt.sln delete mode 100644 src/NSExt/Extensions/JsonSerializerOptionsExtensions.cs delete mode 100644 src/NSExt/Extensions/LoggerExtensions.cs diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8c3845c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,45 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true + + +# ReSharper properties +resharper_align_linq_query = true +resharper_align_multiline_argument = true +resharper_align_multiline_array_and_object_initializer = true +resharper_align_multiline_binary_patterns = true +resharper_align_multiline_calls_chain = true +resharper_align_multiline_extends_list = true +resharper_align_multiline_parameter = true +resharper_align_multiline_property_pattern = true +resharper_align_multiline_switch_expression = true +resharper_align_multiple_declaration = true +resharper_align_multline_type_parameter_constrains = true +resharper_align_multline_type_parameter_list = true +resharper_align_tuple_components = true +resharper_allow_comment_after_lbrace = true +resharper_csharp_empty_block_style = together_same_line +resharper_csharp_outdent_commas = true +resharper_csharp_stick_comment = false +resharper_csharp_wrap_before_comma = true +resharper_indent_nested_foreach_stmt = true +resharper_indent_nested_for_stmt = true +resharper_indent_nested_while_stmt = true +resharper_indent_preprocessor_if = usual_indent +resharper_indent_preprocessor_other = usual_indent +resharper_int_align = true +resharper_keep_existing_arrangement = false +resharper_place_linq_into_on_new_line = false +resharper_place_simple_switch_expression_on_single_line = true +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 8d5a8e9..3b36b84 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,805 @@ -pkg -build -bin -obj -packages -Migrations -_gsdata_ -_ReSharper* -TestResults -app_data +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser *.suo *.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj *.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted *.pubxml -*.publish.xml -.svn -.vs +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ *.dbmdl +*.dbproj.schemaview *.jfm -*.exe -.idea -node_modules -dist \ No newline at end of file +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea/ + +# User define + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea/ + +# User Define +build/ +nuget.config \ No newline at end of file diff --git a/.tgitconfig b/.tgitconfig index c98b9ad..380a28a 100644 --- a/.tgitconfig +++ b/.tgitconfig @@ -1,4 +1,4 @@ [hook "startcommit"] - cmdline = code-format.cmd - wait = true - show = true \ No newline at end of file + cmdline = code-format.cmd + wait = true + show = true \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index 371971c..d336885 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,5 +3,19 @@ ../build/temp/bin ../build/temp/obj ../build/temp/obj + nsnail + NSExt + © 2006-2022 nsnail + https://github.com/nsnail/ns-ext.git + true + true + true + Git + true + true + snupkg + MIT + https://github.com/nsnail/ns-ext.git + ../build/nupkgs \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d1bcdea --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/NSExt.sln b/NSExt.sln new file mode 100644 index 0000000..e03403c --- /dev/null +++ b/NSExt.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NSExt", "src\NSExt.csproj", "{70DD1C27-7ACB-4BE0-A9CD-D781E4050DE5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {70DD1C27-7ACB-4BE0-A9CD-D781E4050DE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70DD1C27-7ACB-4BE0-A9CD-D781E4050DE5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70DD1C27-7ACB-4BE0-A9CD-D781E4050DE5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70DD1C27-7ACB-4BE0-A9CD-D781E4050DE5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/code-format.cmd b/code-format.cmd index 51fa0a1..253fbb5 100644 --- a/code-format.cmd +++ b/code-format.cmd @@ -1,3 +1,3 @@ -do.exe trim-utf8-bom -do.exe remove-whitespace -do.exe convert-lf \ No newline at end of file +dot rm-bom +dot rm-blank +dot tolf \ No newline at end of file diff --git a/src/NSExt.sln.DotSettings b/dot.sln.DotSettings similarity index 62% rename from src/NSExt.sln.DotSettings rename to dot.sln.DotSettings index f7cba85..205c3ab 100644 --- a/src/NSExt.sln.DotSettings +++ b/dot.sln.DotSettings @@ -1,4 +1,6 @@ - + <?xml version="1.0" encoding="utf-16"?> <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> <TypePattern> @@ -8,6 +10,7 @@ <Kind.Order> <DeclarationKind>Interface</DeclarationKind> <DeclarationKind>Class</DeclarationKind> + <DeclarationKind>Record</DeclarationKind> <DeclarationKind>Enum</DeclarationKind> <DeclarationKind>Struct</DeclarationKind> <DeclarationKind>Delegate</DeclarationKind> @@ -36,10 +39,12 @@ </Entry> </TypePattern> </Patterns> - <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" /> - False - HINT + <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" /> + False + HINT \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 0000000..0e46db0 --- /dev/null +++ b/global.json @@ -0,0 +1,10 @@ +{ + "sdk": { + "version": "7.0.100", + "allowPrerelease": true, + "rollForward": "major" + }, + "tools": { + "dotnet": "7.0.100" + } +} \ No newline at end of file diff --git a/src/.editorconfig b/src/.editorconfig deleted file mode 100644 index bf1a983..0000000 --- a/src/.editorconfig +++ /dev/null @@ -1,89 +0,0 @@ -[*.{appxmanifest,asax,ascx,aspx,axaml,axml,build,config,cs,cshtml,csproj,css,dbml,discomap,dtd,htm,html,js,json,jsproj,jsx,lsproj,master,njsproj,nuspec,paml,proj,props,proto,razor,resjson,resw,resx,skin,StyleCop,targets,tasks,ts,tsx,vb,vbproj,xaml,xamlx,xml,xoml,xsd}] -indent_style = space -indent_size = space -tab_width = 4 - -[*] - -# Microsoft .NET properties -csharp_indent_braces = false -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_open_brace = local_functions, methods, types -csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion -csharp_style_var_elsewhere = true:suggestion -csharp_style_var_for_built_in_types = true:suggestion -csharp_style_var_when_type_is_apparent = true:suggestion -dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none -dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none -dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none -dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion -dotnet_style_predefined_type_for_member_access = true:suggestion -dotnet_style_qualification_for_event = false:suggestion -dotnet_style_qualification_for_field = false:suggestion -dotnet_style_qualification_for_method = false:suggestion -dotnet_style_qualification_for_property = false:suggestion -dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion - -# ReSharper inspection severities -resharper_arrange_redundant_parentheses_highlighting = hint -resharper_arrange_this_qualifier_highlighting = hint -resharper_arrange_type_member_modifiers_highlighting = hint -resharper_arrange_type_modifiers_highlighting = hint -resharper_built_in_type_reference_style_for_member_access_highlighting = hint -resharper_built_in_type_reference_style_highlighting = hint -resharper_redundant_base_qualifier_highlighting = warning -resharper_suggest_var_or_type_built_in_types_highlighting = hint -resharper_suggest_var_or_type_elsewhere_highlighting = hint -resharper_suggest_var_or_type_simple_types_highlighting = hint - -# ReSharper properties -resharper_align_first_arg_by_paren = true -resharper_align_linq_query = true -resharper_align_multiline_argument = true -resharper_align_multiline_array_and_object_initializer = false -resharper_align_multiline_calls_chain = true -resharper_align_multiline_expression = true -resharper_align_multiline_extends_list = true -resharper_align_multiline_for_stmt = true -resharper_align_multiline_property_pattern = true -resharper_align_multiline_switch_expression = true -resharper_align_multline_type_parameter_constrains = true -resharper_align_multline_type_parameter_list = true -resharper_align_tuple_components = true -resharper_csharp_align_multiline_parameter = true -resharper_csharp_align_multiple_declaration = true -resharper_csharp_empty_block_style = together -resharper_csharp_indent_size = 4 -resharper_csharp_indent_style = space -resharper_csharp_insert_final_newline = true -resharper_csharp_max_line_length = 120 -resharper_csharp_stick_comment = false -resharper_csharp_tab_width = 4 -resharper_csharp_wrap_arguments_style = chop_if_long -resharper_csharp_wrap_before_comma = false -resharper_csharp_wrap_chained_method_calls = chop_if_long -resharper_csharp_wrap_extends_list_style = chop_if_long -resharper_csharp_wrap_parameters_style = chop_if_long -resharper_indent_anonymous_method_block = true -resharper_indent_nested_fixed_stmt = true -resharper_indent_nested_foreach_stmt = true -resharper_indent_nested_for_stmt = true -resharper_indent_nested_lock_stmt = true -resharper_indent_nested_usings_stmt = true -resharper_indent_nested_while_stmt = true -resharper_indent_preprocessor_if = usual_indent -resharper_indent_preprocessor_other = usual_indent -resharper_int_align = true -resharper_keep_existing_arrangement = false -resharper_keep_existing_linebreaks = false -resharper_max_initializer_elements_on_line = 1 -resharper_outdent_commas = true -resharper_outdent_dots = true -resharper_wrap_array_initializer_style = chop_always -resharper_wrap_before_comma = false -resharper_wrap_object_and_collection_initializer_style = chop_always - -[*.cs] -indent_style = space -indent_size = 4 -tab_width = 4 \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props deleted file mode 100644 index 2a19419..0000000 --- a/src/Directory.Build.props +++ /dev/null @@ -1,18 +0,0 @@ - - - nsnail - NSExt - © 2006-2022 nsnail - https://github.com/nsnail/ns-ext.git - true - true - true - Git - true - true - snupkg - MIT - https://github.com/nsnail/ns-ext.git - ../../build/nupkgs - - \ No newline at end of file diff --git a/src/NSExt/Extensions/ByteExtensions.cs b/src/Extensions/ByteExtensions.cs similarity index 100% rename from src/NSExt/Extensions/ByteExtensions.cs rename to src/Extensions/ByteExtensions.cs diff --git a/src/NSExt/Extensions/CharExtensions.cs b/src/Extensions/CharExtensions.cs similarity index 100% rename from src/NSExt/Extensions/CharExtensions.cs rename to src/Extensions/CharExtensions.cs diff --git a/src/NSExt/Extensions/DateTimeExtensions.cs b/src/Extensions/DateTimeExtensions.cs similarity index 100% rename from src/NSExt/Extensions/DateTimeExtensions.cs rename to src/Extensions/DateTimeExtensions.cs diff --git a/src/NSExt/Extensions/DbCommandExtensions.cs b/src/Extensions/DbCommandExtensions.cs similarity index 67% rename from src/NSExt/Extensions/DbCommandExtensions.cs rename to src/Extensions/DbCommandExtensions.cs index c7cc4c8..caaf214 100644 --- a/src/NSExt/Extensions/DbCommandExtensions.cs +++ b/src/Extensions/DbCommandExtensions.cs @@ -17,11 +17,11 @@ public static class DbCommandExtensions 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, - Convert.ToBoolean(me.Parameters[i].Value) ? "1" : "0"), - _ => sql.Replace(me.Parameters[i].ParameterName, me.Parameters[i].Value?.ToString()) + or DbType.StringFixedLength => + sql.Replace(me.Parameters[i].ParameterName, "'" + me.Parameters[i].Value + "'") + , DbType.Boolean => sql.Replace(me.Parameters[i].ParameterName + , Convert.ToBoolean(me.Parameters[i].Value) ? "1" : "0") + , _ => sql.Replace(me.Parameters[i].ParameterName, me.Parameters[i].Value?.ToString()) }; return sql; diff --git a/src/NSExt/Extensions/DecimalExtensions.cs b/src/Extensions/DecimalExtensions.cs similarity index 100% rename from src/NSExt/Extensions/DecimalExtensions.cs rename to src/Extensions/DecimalExtensions.cs diff --git a/src/NSExt/Extensions/EnumExtensions.cs b/src/Extensions/EnumExtensions.cs similarity index 100% rename from src/NSExt/Extensions/EnumExtensions.cs rename to src/Extensions/EnumExtensions.cs diff --git a/src/NSExt/Extensions/EnumerableExtensions.cs b/src/Extensions/EnumerableExtensions.cs similarity index 100% rename from src/NSExt/Extensions/EnumerableExtensions.cs rename to src/Extensions/EnumerableExtensions.cs diff --git a/src/NSExt/Extensions/GenericExtensions.cs b/src/Extensions/GenericExtensions.cs similarity index 82% rename from src/NSExt/Extensions/GenericExtensions.cs rename to src/Extensions/GenericExtensions.cs index e378ef1..1cf4cd2 100644 --- a/src/NSExt/Extensions/GenericExtensions.cs +++ b/src/Extensions/GenericExtensions.cs @@ -10,10 +10,8 @@ public static class GenericExtensions /// 拷贝来源 /// 需要处理的属性名 /// True包含,false排除 - public static void CopyFrom(this T me, - T copyObj, - IList propNameList = null, - bool isIncludeOrExclude = 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; diff --git a/src/NSExt/Extensions/IntExtensions.cs b/src/Extensions/IntExtensions.cs similarity index 100% rename from src/NSExt/Extensions/IntExtensions.cs rename to src/Extensions/IntExtensions.cs diff --git a/src/Extensions/JsonSerializerOptionsExtensions.cs b/src/Extensions/JsonSerializerOptionsExtensions.cs new file mode 100644 index 0000000..beae6e8 --- /dev/null +++ b/src/Extensions/JsonSerializerOptionsExtensions.cs @@ -0,0 +1,23 @@ +using System.Text.Encodings.Web; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace NSExt.Extensions; + +public static class JsonSerializerOptionsExtensions +{ + public static JsonSerializerOptions NewJsonSerializerOptions(this JsonSerializerOptions me) + { + return new JsonSerializerOptions { + ReadCommentHandling = JsonCommentHandling.Skip + , AllowTrailingCommas = true + , DictionaryKeyPolicy = JsonNamingPolicy.CamelCase + , PropertyNamingPolicy = JsonNamingPolicy.CamelCase + , Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping + , NumberHandling + = JsonNumberHandling.AllowReadingFromString | + JsonNumberHandling.WriteAsString + , PropertyNameCaseInsensitive = true + }; + } +} \ No newline at end of file diff --git a/src/Extensions/LoggerExtensions.cs b/src/Extensions/LoggerExtensions.cs new file mode 100644 index 0000000..4b9cd7f --- /dev/null +++ b/src/Extensions/LoggerExtensions.cs @@ -0,0 +1,49 @@ +// ReSharper disable TemplateIsNotCompileTimeConstantProblem + +namespace NSExt.Extensions; + +public static class LoggerExtensions +{ + private static string CallerInfoMessage(object message, string callerName, string callerFilePath + , int callerLineNumber) + { + return + $"{message} "; + } + + public static void Debug(this ILogger me, object message, [CallerMemberName] string callerName = null + , [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) + { + me.LogDebug(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber)); + } + + + public static void Error(this ILogger me, object message, [CallerMemberName] string callerName = null + , [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) + { + me.LogError(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber)); + } + + public static void Fatal(this ILogger me, object message, Exception ex = null + , [CallerMemberName] string callerName = null, [CallerFilePath] string callerFilePath = null + , [CallerLineNumber] int callerLineNumber = 0) + { + if (ex is null) + me.LogCritical(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber)); + else + me.LogCritical(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber), ex); + } + + + public static void Info(this ILogger me, object message, [CallerMemberName] string callerName = null + , [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) + { + me.LogInformation(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber)); + } + + public static void Warn(this ILogger me, object message, [CallerMemberName] string callerName = null + , [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) + { + me.LogWarning(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber)); + } +} \ No newline at end of file diff --git a/src/NSExt/Extensions/LongExtensions.cs b/src/Extensions/LongExtensions.cs similarity index 100% rename from src/NSExt/Extensions/LongExtensions.cs rename to src/Extensions/LongExtensions.cs diff --git a/src/NSExt/Extensions/ObjectExtensions.cs b/src/Extensions/ObjectExtensions.cs similarity index 54% rename from src/NSExt/Extensions/ObjectExtensions.cs rename to src/Extensions/ObjectExtensions.cs index ce3a187..007e792 100644 --- a/src/NSExt/Extensions/ObjectExtensions.cs +++ b/src/Extensions/ObjectExtensions.cs @@ -12,10 +12,7 @@ public static class ObjectExtensions /// json文本 public static string Json(this object me, bool format = false) { - return JsonSerializer.Serialize(me, - new JsonSerializerOptions { - WriteIndented = format, - PropertyNamingPolicy = JsonNamingPolicy.CamelCase - }); + return JsonSerializer.Serialize( + me, new JsonSerializerOptions { WriteIndented = format, PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); } } \ No newline at end of file diff --git a/src/NSExt/Extensions/StreamExtensions.cs b/src/Extensions/StreamExtensions.cs similarity index 79% rename from src/NSExt/Extensions/StreamExtensions.cs rename to src/Extensions/StreamExtensions.cs index 21dfd6e..4f898ba 100644 --- a/src/NSExt/Extensions/StreamExtensions.cs +++ b/src/Extensions/StreamExtensions.cs @@ -14,9 +14,6 @@ public static class StreamExtensions public static bool IsTextStream(this Stream me) { - return me.FirstByteIndex(new byte[] { - 0x00, - 0xff - }) < 0; + return me.FirstByteIndex(new byte[] { 0x00, 0xff }) < 0; } } \ No newline at end of file diff --git a/src/NSExt/Extensions/StringExtensions.cs b/src/Extensions/StringExtensions.cs similarity index 96% rename from src/NSExt/Extensions/StringExtensions.cs rename to src/Extensions/StringExtensions.cs index 55ba47d..8d37b6b 100644 --- a/src/NSExt/Extensions/StringExtensions.cs +++ b/src/Extensions/StringExtensions.cs @@ -8,8 +8,8 @@ namespace NSExt.Extensions; public static class StringExtensions { - private static readonly JsonSerializerOptions _defaultJsonSerializerOptions = - default(JsonSerializerOptions).NewJsonSerializerOptions(); + private static readonly JsonSerializerOptions _defaultJsonSerializerOptions + = default(JsonSerializerOptions).NewJsonSerializerOptions(); /// /// MD5 hmac编码 @@ -34,10 +34,8 @@ public static class StringExtensions /// 指定要用于加密的块密码模式。 /// 指定在消息数据块短于加密操作所需的完整字节数时要应用的填充类型。 /// - public static string Aes(this string me, - string key, - CipherMode cipherMode = CipherMode.ECB, - PaddingMode paddingMode = PaddingMode.PKCS7) + public static string Aes(this string me, string key, CipherMode cipherMode = CipherMode.ECB + , PaddingMode paddingMode = PaddingMode.PKCS7) { using var aes = System.Security.Cryptography.Aes.Create(); aes.Padding = PaddingMode.PKCS7; @@ -58,10 +56,8 @@ public static class StringExtensions /// 指定要用于加密的块密码模式。 /// 指定在消息数据块短于加密操作所需的完整字节数时要应用的填充类型。 /// - public static string AesDe(this string me, - string key, - CipherMode cipherMode = CipherMode.ECB, - PaddingMode paddingMode = PaddingMode.PKCS7) + public static string AesDe(this string me, string key, CipherMode cipherMode = CipherMode.ECB + , PaddingMode paddingMode = PaddingMode.PKCS7) { using var aes = System.Security.Cryptography.Aes.Create(); aes.Padding = PaddingMode.PKCS7; @@ -156,8 +152,8 @@ public static class StringExtensions 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; + ? def + : ret; } diff --git a/src/NSExt/Extensions/TypeExtensions.cs b/src/Extensions/TypeExtensions.cs similarity index 100% rename from src/NSExt/Extensions/TypeExtensions.cs rename to src/Extensions/TypeExtensions.cs diff --git a/src/NSExt/Extensions/UriExtensions.cs b/src/Extensions/UriExtensions.cs similarity index 100% rename from src/NSExt/Extensions/UriExtensions.cs rename to src/Extensions/UriExtensions.cs diff --git a/src/NSExt/GlobalUsings.cs b/src/GlobalUsings.cs similarity index 100% rename from src/NSExt/GlobalUsings.cs rename to src/GlobalUsings.cs diff --git a/src/NSExt/NSExt.csproj b/src/NSExt.csproj similarity index 90% rename from src/NSExt/NSExt.csproj rename to src/NSExt.csproj index 117fe67..c535a5e 100644 --- a/src/NSExt/NSExt.csproj +++ b/src/NSExt.csproj @@ -3,7 +3,7 @@ net6.0;net7.0 enable - 1.0.6 + 1.0.7 diff --git a/src/NSExt.sln b/src/NSExt.sln deleted file mode 100644 index fcf94ce..0000000 --- a/src/NSExt.sln +++ /dev/null @@ -1,16 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NSExt", "NSExt\NSExt.csproj", "{54814D1B-C587-4D90-A7BE-4BE1E170D5FC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {54814D1B-C587-4D90-A7BE-4BE1E170D5FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {54814D1B-C587-4D90-A7BE-4BE1E170D5FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {54814D1B-C587-4D90-A7BE-4BE1E170D5FC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {54814D1B-C587-4D90-A7BE-4BE1E170D5FC}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal \ No newline at end of file diff --git a/src/NSExt/Extensions/JsonSerializerOptionsExtensions.cs b/src/NSExt/Extensions/JsonSerializerOptionsExtensions.cs deleted file mode 100644 index 7649079..0000000 --- a/src/NSExt/Extensions/JsonSerializerOptionsExtensions.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Text.Encodings.Web; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace NSExt.Extensions; - -public static class JsonSerializerOptionsExtensions -{ - public static JsonSerializerOptions NewJsonSerializerOptions(this JsonSerializerOptions me) - { - return new JsonSerializerOptions { - ReadCommentHandling = JsonCommentHandling.Skip, - AllowTrailingCommas = true, - DictionaryKeyPolicy = JsonNamingPolicy.CamelCase, - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, - NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString, - PropertyNameCaseInsensitive = true - }; - } -} \ 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 ef63a7f..0000000 --- a/src/NSExt/Extensions/LoggerExtensions.cs +++ /dev/null @@ -1,66 +0,0 @@ -// ReSharper disable TemplateIsNotCompileTimeConstantProblem - -namespace NSExt.Extensions; - -public static class LoggerExtensions -{ - private static string CallerInfoMessage(object message, - string callerName, - string callerFilePath, - int callerLineNumber) - { - return - $"{message} "; - } - - public static void Debug(this ILogger me, - object message, - [CallerMemberName] string callerName = null, - [CallerFilePath] string callerFilePath = null, - [CallerLineNumber] int callerLineNumber = 0) - { - me.LogDebug(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber)); - } - - - public static void Error(this ILogger me, - object message, - [CallerMemberName] string callerName = null, - [CallerFilePath] string callerFilePath = null, - [CallerLineNumber] int callerLineNumber = 0) - { - me.LogError(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber)); - } - - public static void Fatal(this ILogger me, - object message, - Exception ex = null, - [CallerMemberName] string callerName = null, - [CallerFilePath] string callerFilePath = null, - [CallerLineNumber] int callerLineNumber = 0) - { - if (ex is null) - me.LogCritical(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber)); - else - me.LogCritical(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber), ex); - } - - - public static void Info(this ILogger me, - object message, - [CallerMemberName] string callerName = null, - [CallerFilePath] string callerFilePath = null, - [CallerLineNumber] int callerLineNumber = 0) - { - me.LogInformation(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber)); - } - - public static void Warn(this ILogger me, - object message, - [CallerMemberName] string callerName = null, - [CallerFilePath] string callerFilePath = null, - [CallerLineNumber] int callerLineNumber = 0) - { - me.LogWarning(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber)); - } -} \ No newline at end of file