diff --git a/.editorconfig b/.editorconfig
index 8c3845c..2127d46 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,12 +1,28 @@
root = true
[*]
-indent_style = space
-indent_size = 4
-end_of_line = lf
charset = utf-8
+end_of_line = lf
+ij_xml_attribute_wrap = off
+ij_xml_text_wrap = off
+indent_size = 4
+indent_style = space
+insert_final_newline = false
trim_trailing_whitespace = true
+[*.cs]
+dotnet_analyzer_diagnostic.severity = warning
+dotnet_diagnostic.CA1707.severity = none
+dotnet_diagnostic.CA1720.severity = none
+dotnet_diagnostic.CA5350.severity = none
+dotnet_diagnostic.CA5351.severity = none
+dotnet_diagnostic.IDE0008.severity = none
+dotnet_diagnostic.IDE0017.severity = none
+dotnet_diagnostic.IDE0048.severity = none
+dotnet_diagnostic.IDE0055.severity = none
+dotnet_diagnostic.IDE0058.severity = none
+dotnet_diagnostic.IDE0160.severity = none
+
# ReSharper properties
resharper_align_linq_query = true
@@ -23,23 +39,27 @@ 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_blank_lines_before_single_line_comment = 1
resharper_csharp_empty_block_style = together_same_line
resharper_csharp_outdent_commas = true
+resharper_csharp_place_type_constraints_on_same_line = false
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_foreach_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_embedded_statement_on_same_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/add-meta-files-to-sln.csx b/AddMetaFilesToSln.csx
similarity index 100%
rename from add-meta-files-to-sln.csx
rename to AddMetaFilesToSln.csx
diff --git a/code-cleanup-on-save.csx b/CodeCleanupOnSave.csx
similarity index 100%
rename from code-cleanup-on-save.csx
rename to CodeCleanupOnSave.csx
diff --git a/CodeQuality.props b/CodeQuality.props
new file mode 100644
index 0000000..df0775d
--- /dev/null
+++ b/CodeQuality.props
@@ -0,0 +1,17 @@
+
+
+ ../StyleCopAnalyzers.ruleset
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
\ No newline at end of file
diff --git a/Directory.Build.props b/Directory.Build.props
index f6fcf75..11cee10 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,9 +1,11 @@
enable
- ../build/$(MSBuildProjectName)/bin
- ../build/$(MSBuildProjectName)/obj
- $(BaseIntermediateOutputPath)
+ ../dist
+ ../dist
+ $(BaseOutputPath)/$(MSBuildProjectName)/bin
+ $(BaseIntermediateOutputPath)/$(MSBuildProjectName)/obj
+ $(BaseIntermediateOutputPath)/$(MSBuildProjectName)/obj
nsnail
NSExt
© 2006-2022 nsnail
diff --git a/ImageOptimize.csx b/ImageOptimize.csx
new file mode 100644
index 0000000..8e6aca7
--- /dev/null
+++ b/ImageOptimize.csx
@@ -0,0 +1,45 @@
+/*
+ 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 4e16c72..d4e6c45 100644
--- a/NSExt.sln
+++ b/NSExt.sln
@@ -11,17 +11,22 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{85E669CB-F
.gitattributes = .gitattributes
.gitignore = .gitignore
.tgitconfig = .tgitconfig
- add-meta-files-to-sln.csx = add-meta-files-to-sln.csx
- code-cleanup-on-save.csx = code-cleanup-on-save.csx
+ AddMetaFilesToSln.csx = AddMetaFilesToSln.csx
+ build.cake = build.cake
code-format.cmd = code-format.cmd
+ CodeCleanupOnSave.csx = CodeCleanupOnSave.csx
+ CodeQuality.props = CodeQuality.props
Directory.Build.props = Directory.Build.props
dot.sln.DotSettings = dot.sln.DotSettings
dotnet-tools.json = dotnet-tools.json
- git-clean.ps1 = git-clean.ps1
+ git-clean.cmd = git-clean.cmd
global.json = global.json
+ ImageOptimize.csx = ImageOptimize.csx
LICENSE = LICENSE
push2nuget.ps1 = push2nuget.ps1
README.md = README.md
+ stylecop.json = stylecop.json
+ StyleCopAnalyzers.ruleset = StyleCopAnalyzers.ruleset
EndProjectSection
EndProject
Global
diff --git a/dot.sln.DotSettings b/NSExt.sln.DotSettings
similarity index 68%
rename from dot.sln.DotSettings
rename to NSExt.sln.DotSettings
index 205c3ab..aebd72b 100644
--- a/dot.sln.DotSettings
+++ b/NSExt.sln.DotSettings
@@ -1,6 +1,18 @@
-
+
+ False
+ 1
+ 1
+ OFF
+ HINT
+ 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" />
+
<?xml version="1.0" encoding="utf-16"?>
<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
<TypePattern>
@@ -8,43 +20,38 @@
<Entry.SortBy>
<Kind>
<Kind.Order>
- <DeclarationKind>Interface</DeclarationKind>
- <DeclarationKind>Class</DeclarationKind>
- <DeclarationKind>Record</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>Delegate</DeclarationKind>
+ <DeclarationKind>Event</DeclarationKind>
+ <DeclarationKind>Enum</DeclarationKind>
+ <DeclarationKind>Interface</DeclarationKind>
+ <DeclarationKind>Property</DeclarationKind>
<DeclarationKind>Indexer</DeclarationKind>
<DeclarationKind>Method</DeclarationKind>
+ <DeclarationKind>Struct</DeclarationKind>
+ <DeclarationKind>Record</DeclarationKind>
+ <DeclarationKind>Class</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>
+ <AccessModifier>Internal</AccessModifier>
+ <AccessModifier>ProtectedInternal</AccessModifier>
+ <AccessModifier>Protected</AccessModifier>
+ <AccessModifier>PrivateProtected</AccessModifier>
+ <AccessModifier>Private</AccessModifier>
</Access.Order>
</Access>
+ <Static />
+ <Readonly />
<Name />
</Entry.SortBy>
</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
+
\ No newline at end of file
diff --git a/StyleCopAnalyzers.ruleset b/StyleCopAnalyzers.ruleset
new file mode 100644
index 0000000..f76edfe
--- /dev/null
+++ b/StyleCopAnalyzers.ruleset
@@ -0,0 +1,221 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build.cake b/build.cake
index ca99a64..1c37c0b 100644
--- a/build.cake
+++ b/build.cake
@@ -1,6 +1,6 @@
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
-var pkgOutPath = $"./build/NSExt/pkg/{configuration}";
+var pkgOutPath = $"./dist/NSExt/pkg/{configuration}";
////////////////////////////////////////////////////////////////
// Tasks
@@ -13,7 +13,7 @@ Task("Clean")
Task("Build")
.IsDependentOn("Clean")
- .Does(context =>
+ .Does(context =>
{
DotNetBuild("./NSExt.sln", new DotNetBuildSettings {
Configuration = configuration,
@@ -26,7 +26,7 @@ Task("Build")
Task("Test")
.IsDependentOn("Build")
- .Does(context =>
+ .Does(context =>
{
DotNetTest("./test/Spectre.Console.Tests/Spectre.Console.Tests.csproj", new DotNetTestSettings {
Configuration = configuration,
@@ -49,7 +49,7 @@ Task("Test")
Task("Package")
.IsDependentOn("Build")
- .Does(context =>
+ .Does(context =>
{
context.DotNetPack("./NSExt.sln", new DotNetPackSettings {
Configuration = configuration,
@@ -64,7 +64,7 @@ Task("Package")
Task("Publish-GitHub")
.WithCriteria(ctx => BuildSystem.IsRunningOnGitHubActions, "Not running on GitHub Actions")
.IsDependentOn("Package")
- .Does(context =>
+ .Does(context =>
{
var apiKey = Argument("github-key", null);
if(string.IsNullOrWhiteSpace(apiKey)) {
@@ -73,10 +73,10 @@ Task("Publish-GitHub")
// Publish to GitHub Packages
var exitCode = 0;
- foreach(var file in context.GetFiles("./.artifacts/*.nupkg"))
+ foreach(var file in context.GetFiles("./.artifacts/*.nupkg"))
{
context.Information("Publishing {0}...", file.GetFilename().FullPath);
- exitCode += StartProcess("dotnet",
+ exitCode += StartProcess("dotnet",
new ProcessSettings {
Arguments = new ProcessArgumentBuilder()
.Append("gpr")
@@ -87,7 +87,7 @@ Task("Publish-GitHub")
);
}
- if(exitCode != 0)
+ if(exitCode != 0)
{
throw new CakeException("Could not push GitHub packages.");
}
@@ -96,7 +96,7 @@ Task("Publish-GitHub")
Task("Publish-NuGet")
// .WithCriteria(ctx => BuildSystem.IsRunningOnGitHubActions, "Not running on GitHub Actions")
.IsDependentOn("Package")
- .Does(context =>
+ .Does(context =>
{
var apiKey = Argument("nuget-key", null);
if(string.IsNullOrWhiteSpace(apiKey)) {
@@ -104,7 +104,7 @@ Task("Publish-NuGet")
}
// Publish to GitHub Packages
- foreach(var file in context.GetFiles($"{pkgOutPath}/*.*nupkg"))
+ foreach(var file in context.GetFiles($"{pkgOutPath}/*.*nupkg"))
{
context.Information("Publishing {0}...", file.GetFilename().FullPath);
DotNetNuGetPush(file.FullPath, new DotNetNuGetPushSettings
diff --git a/dotnet-tools.json b/dotnet-tools.json
index 55de44c..1158904 100644
--- a/dotnet-tools.json
+++ b/dotnet-tools.json
@@ -2,6 +2,5 @@
"version": 1,
"isRoot": true,
"tools": {
-
}
}
\ No newline at end of file
diff --git a/git-clean.ps1 b/git-clean.cmd
similarity index 100%
rename from git-clean.ps1
rename to git-clean.cmd
diff --git a/push2nuget.ps1 b/push2nuget.ps1
index 13df55a..24d0798 100644
--- a/push2nuget.ps1
+++ b/push2nuget.ps1
@@ -1,5 +1,5 @@
Param(
- # Nuget APIKey
+# Nuget APIKey
[string] $apikey
)
@@ -12,13 +12,13 @@ if ($apikey -eq $null -or $apikey -eq "")
rm -r ./build/nupkgs
dotnet build -c Release
$files = Get-ChildItem -Path ./build/nupkgs/ -Filter *.nupkg
-foreach($file in $files)
+foreach ($file in $files)
{
dotnet nuget push $file.fullName --skip-duplicate --api-key $apikey --source https://api.nuget.org/v3/index.json
nuget add $file.fullName -source d:\nuget-pkg
}
$files = Get-ChildItem -Path ./build/nupkgs/ -Filter *.snupkg
-foreach($file in $files)
+foreach ($file in $files)
{
dotnet nuget push $file.fullName --skip-duplicate --api-key $apikey --source https://api.nuget.org/v3/index.json
nuget add $file.fullName -source d:\nuget-pkg
diff --git a/src/Extensions/ByteExtensions.cs b/src/Extensions/ByteExtensions.cs
index b443098..46cb98c 100644
--- a/src/Extensions/ByteExtensions.cs
+++ b/src/Extensions/ByteExtensions.cs
@@ -1,5 +1,8 @@
namespace NSExt.Extensions;
+///
+/// ByteExtensions
+///
public static class ByteExtensions
{
///
@@ -12,7 +15,6 @@ public static class ByteExtensions
return Convert.ToBase64String(me);
}
-
///
/// 将字节数组解码成字符串
///
@@ -24,7 +26,6 @@ public static class ByteExtensions
return e.GetString(me);
}
-
///
/// 将字节数组解码成字符串
///
@@ -38,15 +39,20 @@ public static class ByteExtensions
///
/// 将字节数组转换成16进制字符串
///
- ///
+ /// me
/// 是否大写
/// 字节间分隔符
- ///
public static string String(this byte[] me, bool upperCase = true, string splitShar = null)
{
- var ret = BitConverter.ToString(me);
- if (!upperCase) ret = ret.ToLower();
- if (splitShar != "-") ret = ret.Replace("-", splitShar ?? string.Empty);
+ var ret = BitConverter.ToString(me);
+ if (!upperCase) {
+ ret = ret.ToLower(CultureInfo.InvariantCulture);
+ }
+
+ if (splitShar != "-") {
+ ret = ret.Replace("-", splitShar ?? string.Empty);
+ }
+
return ret;
}
}
\ No newline at end of file
diff --git a/src/Extensions/CharExtensions.cs b/src/Extensions/CharExtensions.cs
index 319cf91..3d5438a 100644
--- a/src/Extensions/CharExtensions.cs
+++ b/src/Extensions/CharExtensions.cs
@@ -1,12 +1,13 @@
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;
@@ -15,8 +16,6 @@ public static class CharExtensions
///
/// 是否base64字符
///
- ///
- ///
public static bool IsBase64Character(this char me)
{
return IsAsciiLetterOrDigit(me) || me is '+' or '/' or '=';
diff --git a/src/Extensions/DateTimeExtensions.cs b/src/Extensions/DateTimeExtensions.cs
index 2e904b2..ac8cb43 100644
--- a/src/Extensions/DateTimeExtensions.cs
+++ b/src/Extensions/DateTimeExtensions.cs
@@ -1,27 +1,28 @@
+// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
+#pragma warning disable SA1300
+#pragma warning disable IDE1006
namespace NSExt.Extensions;
+///
+/// DateTimeExtensions
+///
public static class DateTimeExtensions
{
///
- /// 将一个过去时间对象与当前时间相减转换成“xx以前”的字符串,如2秒以前,3天以前
+ /// 将一个过去时间对象与当前时间相减转换成“xx以前”的字符串, 如2秒以前, 3天以前
///
/// 时间对象
/// 字符串
public static string TimeAgo(this DateTime me)
{
var ts = DateTime.Now - me;
- if (ts.Days > 0) return ts.Days + "天前";
-
- if (ts.Hours > 0) return ts.Hours + "小时前";
-
- if (ts.Minutes > 0) return ts.Minutes + "分钟前";
-
- return ts.Seconds + "秒前";
+ return ts.Days > 0 ? ts.Days + "天前" :
+ ts.Hours > 0 ? ts.Hours + "小时前" :
+ ts.Minutes > 0 ? ts.Minutes + "分钟前" : ts.Seconds + "秒前";
}
-
///
/// 指定时间的世界协调时的unix时间戳形式
///
@@ -35,55 +36,64 @@ public static class DateTimeExtensions
///
/// 指定时间的世界协调时的unix时间戳形式(毫秒)
///
- ///
- ///
public static long TimeUnixUtcMs(this DateTime me)
{
return (me.ToUniversalTime().Ticks - 621355968000000000) / 10000;
}
-
- // ReSharper disable once InconsistentNaming
+ ///
+ /// yyyy_MM
+ ///
public static string yyyy_MM(this DateTime me)
{
- return me.ToString("yyyy-MM");
+ return me.ToString("yyyy-MM", CultureInfo.InvariantCulture);
}
- // ReSharper disable once InconsistentNaming
+ ///
+ /// yyyy_MM_dd
+ ///
public static string yyyy_MM_dd(this DateTime me)
{
- return me.ToString("yyyy-MM-dd");
+ return me.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
}
- // ReSharper disable once InconsistentNaming
+ ///
+ /// yyyy_MM_dd_HH_mm
+ ///
public static string yyyy_MM_dd_HH_mm(this DateTime me)
{
- return me.ToString("yyyy-MM-dd HH:mm");
+ return me.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
}
-
- // ReSharper disable once InconsistentNaming
+ ///
+ /// 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");
+ return me.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
}
- // ReSharper disable once InconsistentNaming
+ ///
+ /// 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");
+ return me.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture);
}
-
- // ReSharper disable once InconsistentNaming
+ ///
+ /// yyyyMM
+ ///
public static string yyyyMM(this DateTime me)
{
- return me.ToString("yyyyMM");
+ return me.ToString("yyyyMM", CultureInfo.InvariantCulture);
}
- // ReSharper disable once InconsistentNaming
+ ///
+ /// yyyyMMdd
+ ///
public static string yyyyMMdd(this DateTime me)
{
- return me.ToString("yyyyMMdd");
+ return me.ToString("yyyyMMdd", CultureInfo.InvariantCulture);
}
}
\ No newline at end of file
diff --git a/src/Extensions/DbCommandExtensions.cs b/src/Extensions/DbCommandExtensions.cs
index caaf214..d1a4e75 100644
--- a/src/Extensions/DbCommandExtensions.cs
+++ b/src/Extensions/DbCommandExtensions.cs
@@ -1,28 +1,46 @@
namespace NSExt.Extensions;
+///
+/// DbCommandExtensions
+///
public static class DbCommandExtensions
{
///
/// 格式化参数拼接成完整的SQL语句
///
- ///
public static string ParameterFormat(this DbCommand me)
{
//var aa = pars.ToDictionary(it => it.ParameterName, it => it.Value);
var sql = me.CommandText;
//应逆向替换,否则由于 多个表的过滤器问题导致替换不完整 如 @TenantId1 @TenantId10
- for (var i = me.Parameters.Count - 1; i >= 0; i--)
+ for (var i = me.Parameters.Count - 1; i >= 0; i--) {
sql = me.Parameters[i].DbType switch {
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.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, CultureInfo.InvariantCulture) ? "1" : "0")
+ , DbType.Binary => throw new NotImplementedException()
+ , DbType.Byte => throw new NotImplementedException()
+ , DbType.Currency => throw new NotImplementedException()
+ , DbType.Decimal => throw new NotImplementedException()
+ , DbType.Double => throw new NotImplementedException()
+ , DbType.Int16 => throw new NotImplementedException()
+ , DbType.Int32 => throw new NotImplementedException()
+ , DbType.Int64 => throw new NotImplementedException()
+ , DbType.Object => throw new NotImplementedException()
+ , DbType.SByte => throw new NotImplementedException()
+ , DbType.Single => throw new NotImplementedException()
+ , DbType.UInt16 => throw new NotImplementedException()
+ , DbType.UInt32 => throw new NotImplementedException()
+ , DbType.UInt64 => throw new NotImplementedException()
+ , DbType.Xml => throw new NotImplementedException()
+ , _ => sql.Replace(me.Parameters[i].ParameterName, me.Parameters[i].Value?.ToString())
};
+ }
return sql;
}
diff --git a/src/Extensions/DecimalExtensions.cs b/src/Extensions/DecimalExtensions.cs
index 3695204..6dfd32a 100644
--- a/src/Extensions/DecimalExtensions.cs
+++ b/src/Extensions/DecimalExtensions.cs
@@ -1,5 +1,8 @@
namespace NSExt.Extensions;
+///
+/// DecimalExtensions
+///
public static class DecimalExtensions
{
///
diff --git a/src/Extensions/EnumExtensions.cs b/src/Extensions/EnumExtensions.cs
index a7e5827..80ae7bd 100644
--- a/src/Extensions/EnumExtensions.cs
+++ b/src/Extensions/EnumExtensions.cs
@@ -1,5 +1,8 @@
namespace NSExt.Extensions;
+///
+/// EnumExtensions
+///
public static class EnumExtensions
{
///
@@ -12,6 +15,6 @@ public static class EnumExtensions
var t = e.GetType();
var fi = t.GetField(Enum.GetName(t, e)!);
var attrs = (DescriptionAttribute[])fi!.GetCustomAttributes(typeof(DescriptionAttribute), false);
- return (attrs.Length != 0 ? attrs[0].Description : Enum.GetName(t, e)) ?? "";
+ return (attrs.Length != 0 ? attrs[0].Description : Enum.GetName(t, e)) ?? string.Empty;
}
}
\ No newline at end of file
diff --git a/src/Extensions/EnumerableExtensions.cs b/src/Extensions/EnumerableExtensions.cs
index 067f057..ebebe01 100644
--- a/src/Extensions/EnumerableExtensions.cs
+++ b/src/Extensions/EnumerableExtensions.cs
@@ -1,13 +1,13 @@
namespace NSExt.Extensions;
+///
+/// EnumerableExtensions
+///
public static class EnumerableExtensions
{
///
/// 将列表转成分隔符分隔的字符串
///
- ///
- ///
- ///
public static string Join(this IEnumerable