build: 10.11.105

feat: json添加AllowNamedFloatingPointLiterals
This commit is contained in:
2248356998 qq.com
2025-10-15 11:16:18 +08:00
parent 8a95f48f5a
commit c0337e2b19
10 changed files with 38 additions and 17 deletions

View File

@@ -251,11 +251,13 @@ public class RequestAuditFilter : IAsyncActionFilter, IOrderedFilter
if (exception == null) if (exception == null)
{ {
logger.Log(LogLevel.Information, $"{logData.Method}:{logData.Path}-{logData.Operation}"); if (logger.IsEnabled(LogLevel.Information))
logger.Log(LogLevel.Information, $"{logData.Method}:{logData.Path}-{logData.Operation}");
} }
else else
{ {
logger.Log(LogLevel.Warning, $"{logData.Method}:{logData.Path}-{logData.Operation}{Environment.NewLine}{logData.Exception?.ToSystemTextJsonString()}{Environment.NewLine}{logData.Validation?.ToSystemTextJsonString()}"); if (logger.IsEnabled(LogLevel.Warning))
logger.Log(LogLevel.Warning, $"{logData.Method}:{logData.Path}-{logData.Operation}{Environment.NewLine}{logData.Exception?.ToSystemTextJsonString()}{Environment.NewLine}{logData.Validation?.ToSystemTextJsonString()}");
} }
} }

View File

@@ -66,7 +66,8 @@ internal class JsonStringLocalizer(Assembly assembly, string typeName, string ba
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogError(ex, "{JsonStringLocalizerName} searched for '{Name}' in '{typeName}' with culture '{CultureName}' throw exception.", nameof(JsonStringLocalizer), name, typeName, CultureInfo.CurrentUICulture.Name); if (Logger?.IsEnabled(LogLevel.Error) == true)
Logger.LogError(ex, "{JsonStringLocalizerName} searched for '{Name}' in '{typeName}' with culture '{CultureName}' throw exception.", nameof(JsonStringLocalizer), name, typeName, CultureInfo.CurrentUICulture.Name);
} }
return ret; return ret;
} }
@@ -176,7 +177,8 @@ internal class JsonStringLocalizer(Assembly assembly, string typeName, string ba
localizationMissingItemHandler.HandleMissingItem(name, typeName, CultureInfo.CurrentUICulture.Name); localizationMissingItemHandler.HandleMissingItem(name, typeName, CultureInfo.CurrentUICulture.Name);
if (jsonLocalizationOptions.IgnoreLocalizerMissing == false) if (jsonLocalizationOptions.IgnoreLocalizerMissing == false)
{ {
Logger.LogInformation("{JsonStringLocalizerName} searched for '{Name}' in '{TypeName}' with culture '{CultureName}' not found.", nameof(JsonStringLocalizer), name, typeName, CultureInfo.CurrentUICulture.Name); if (Logger?.IsEnabled(LogLevel.Information) == true)
Logger.LogInformation("{JsonStringLocalizerName} searched for '{Name}' in '{TypeName}' with culture '{CultureName}' not found.", nameof(JsonStringLocalizer), name, typeName, CultureInfo.CurrentUICulture.Name);
} }
_missingManifestCache.TryAdd($"name={name}&culture={CultureInfo.CurrentUICulture.Name}"); _missingManifestCache.TryAdd($"name={name}&culture={CultureInfo.CurrentUICulture.Name}");
} }

View File

@@ -295,7 +295,8 @@ internal sealed class EventBusHostedService : BackgroundService
, retryAction: (total, times) => , retryAction: (total, times) =>
{ {
// 输出重试日志 // 输出重试日志
_logger.LogWarning("Retrying {times}/{total} times for {EventId}", times, total, eventSource.EventId); if (_logger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Warning) == true)
_logger.LogWarning("Retrying {times}/{total} times for {EventId}", times, total, eventSource.EventId);
}).ConfigureAwait(false); }).ConfigureAwait(false);
} }
else else

View File

@@ -369,11 +369,13 @@ internal sealed class ScheduleHostedService : BackgroundService
// 写入作业执行详细日志 // 写入作业执行详细日志
if (executionException == null) if (executionException == null)
{ {
jobLogger?.LogInformation("{jobExecutingContext}", jobExecutingContext); if (jobLogger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Information) == true)
jobLogger?.LogInformation("{jobExecutingContext}", jobExecutingContext);
} }
else else
{ {
jobLogger?.LogError(executionException, "{jobExecutingContext}", jobExecutingContext); if (jobLogger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Error) == true)
jobLogger?.LogError(executionException, "{jobExecutingContext}", jobExecutingContext);
} }
// 记录作业触发器运行信息 // 记录作业触发器运行信息

View File

@@ -251,7 +251,8 @@ public sealed class ProfilerDelegatingHandler(ILogger<Logging> logger, IOptions<
// 检查是否配置(注册)了日志程序 // 检查是否配置(注册)了日志程序
if (remoteOptions.IsLoggingRegistered) if (remoteOptions.IsLoggingRegistered)
{ {
logger.Log(remoteOptions.ProfilerLogLevel, "{message}", message); if (logger?.IsEnabled(remoteOptions.ProfilerLogLevel) == true)
logger.Log(remoteOptions.ProfilerLogLevel, "{message}", message);
} }
else else
{ {

View File

@@ -57,6 +57,7 @@ namespace ThingsGateway.SqlSugar
} }
}); });
_systemTextJsonSettings.NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals;
_systemTextJsonSettings.Converters.Add(new JTokenSystemTextJsonConverter()); _systemTextJsonSettings.Converters.Add(new JTokenSystemTextJsonConverter());
_systemTextJsonSettings.Converters.Add(new JValueSystemTextJsonConverter()); _systemTextJsonSettings.Converters.Add(new JValueSystemTextJsonConverter());
_systemTextJsonSettings.Converters.Add(new JObjectSystemTextJsonConverter()); _systemTextJsonSettings.Converters.Add(new JObjectSystemTextJsonConverter());

View File

@@ -1,9 +1,9 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<PluginVersion>10.11.104</PluginVersion> <PluginVersion>10.11.105</PluginVersion>
<ProPluginVersion>10.11.104</ProPluginVersion> <ProPluginVersion>10.11.105</ProPluginVersion>
<DefaultVersion>10.11.104</DefaultVersion> <DefaultVersion>10.11.105</DefaultVersion>
<AuthenticationVersion>10.11.6</AuthenticationVersion> <AuthenticationVersion>10.11.6</AuthenticationVersion>
<SourceGeneratorVersion>10.11.6</SourceGeneratorVersion> <SourceGeneratorVersion>10.11.6</SourceGeneratorVersion>
<NET8Version>8.0.21</NET8Version> <NET8Version>8.0.21</NET8Version>

View File

@@ -117,6 +117,7 @@ public partial class ManagementTask : AsyncDisposableObject
{ {
b.UseSystemTextJson(json => b.UseSystemTextJson(json =>
{ {
json.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals;
json.Converters.Add(new ByteArrayToNumberArrayConverterSystemTextJson()); json.Converters.Add(new ByteArrayToNumberArrayConverterSystemTextJson());
json.Converters.Add(new JTokenSystemTextJsonConverter()); json.Converters.Add(new JTokenSystemTextJsonConverter());
json.Converters.Add(new JValueSystemTextJsonConverter()); json.Converters.Add(new JValueSystemTextJsonConverter());
@@ -180,6 +181,7 @@ public partial class ManagementTask : AsyncDisposableObject
{ {
b.UseSystemTextJson(json => b.UseSystemTextJson(json =>
{ {
json.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals;
json.Converters.Add(new ByteArrayToNumberArrayConverterSystemTextJson()); json.Converters.Add(new ByteArrayToNumberArrayConverterSystemTextJson());
json.Converters.Add(new JTokenSystemTextJsonConverter()); json.Converters.Add(new JTokenSystemTextJsonConverter());
json.Converters.Add(new JValueSystemTextJsonConverter()); json.Converters.Add(new JValueSystemTextJsonConverter());

View File

@@ -350,6 +350,7 @@ internal sealed class RedundancyTask : IRpcDriver, IAsyncDisposable
{ {
b.UseSystemTextJson(json => b.UseSystemTextJson(json =>
{ {
json.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals;
json.Converters.Add(new ByteArrayToNumberArrayConverterSystemTextJson()); json.Converters.Add(new ByteArrayToNumberArrayConverterSystemTextJson());
json.Converters.Add(new JTokenSystemTextJsonConverter()); json.Converters.Add(new JTokenSystemTextJsonConverter());
json.Converters.Add(new JValueSystemTextJsonConverter()); json.Converters.Add(new JValueSystemTextJsonConverter());
@@ -394,6 +395,9 @@ internal sealed class RedundancyTask : IRpcDriver, IAsyncDisposable
{ {
b.UseSystemTextJson(json => b.UseSystemTextJson(json =>
{ {
json.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals;
json.Converters.Add(new ByteArrayToNumberArrayConverterSystemTextJson()); json.Converters.Add(new ByteArrayToNumberArrayConverterSystemTextJson());
json.Converters.Add(new JTokenSystemTextJsonConverter()); json.Converters.Add(new JTokenSystemTextJsonConverter());
json.Converters.Add(new JValueSystemTextJsonConverter()); json.Converters.Add(new JValueSystemTextJsonConverter());

View File

@@ -136,7 +136,8 @@ internal sealed class PluginService : IPluginService
if (driverType != null) if (driverType != null)
{ {
var driver = (DriverBase)Activator.CreateInstance(driverType); var driver = (DriverBase)Activator.CreateInstance(driverType);
_logger?.LogInformation(string.Format(AppResource.LoadTypeSuccess, pluginName)); if (_logger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Information) == true)
_logger?.LogInformation(string.Format(AppResource.LoadTypeSuccess, pluginName));
_driverBaseDict.TryAdd(pluginName, driverType); _driverBaseDict.TryAdd(pluginName, driverType);
return driver; return driver;
} }
@@ -440,7 +441,8 @@ internal sealed class PluginService : IPluginService
catch (Exception ex) catch (Exception ex)
{ {
// 加载失败时记录警告信息 // 加载失败时记录警告信息
_logger?.LogWarning(ex, string.Format(AppResource.LoadOtherFileFail, item)); if (_logger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Warning) == true)
_logger?.LogWarning(ex, string.Format(AppResource.LoadOtherFileFail, item));
} }
} }
} }
@@ -679,7 +681,8 @@ internal sealed class PluginService : IPluginService
} }
//添加到全局对象 //添加到全局对象
_assemblyLoadContextDict.TryAdd(fileName, (assemblyLoadContext, assembly)); _assemblyLoadContextDict.TryAdd(fileName, (assemblyLoadContext, assembly));
_logger?.LogInformation(string.Format(AppResource.AddPluginFile, path)); if (_logger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Information) == true)
_logger?.LogInformation(string.Format(AppResource.AddPluginFile, path));
} }
return assembly; return assembly;
} }
@@ -728,7 +731,8 @@ internal sealed class PluginService : IPluginService
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger?.LogWarning(ex, string.Format(AppResource.LoadOtherFileFail, item)); if (_logger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Warning) == true)
_logger?.LogWarning(ex, string.Format(AppResource.LoadOtherFileFail, item));
} }
} }
} }
@@ -827,7 +831,8 @@ internal sealed class PluginService : IPluginService
{ {
//添加到字典 //添加到字典
_driverBaseDict.TryAdd($"{driverMainName}.{type.Name}", type); _driverBaseDict.TryAdd($"{driverMainName}.{type.Name}", type);
_logger?.LogInformation(string.Format(AppResource.LoadTypeSuccess, PluginInfoUtil.GetFullName(driverMainName, type.Name))); if (_logger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Information) == true)
_logger?.LogInformation(string.Format(AppResource.LoadTypeSuccess, PluginInfoUtil.GetFullName(driverMainName, type.Name)));
} }
var plugin = new PluginInfo() var plugin = new PluginInfo()
{ {
@@ -847,7 +852,8 @@ internal sealed class PluginService : IPluginService
catch (Exception ex) catch (Exception ex)
{ {
// 记录加载插件失败的日志 // 记录加载插件失败的日志
_logger?.LogWarning(ex, string.Format(AppResource.LoadPluginFail, Path.GetRelativePath(AppContext.BaseDirectory.CombinePathWithOs(tempDir), folderPath))); if (_logger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Warning) == true)
_logger?.LogWarning(ex, string.Format(AppResource.LoadPluginFail, Path.GetRelativePath(AppContext.BaseDirectory.CombinePathWithOs(tempDir), folderPath)));
} }
} }
return plugins.DistinctBy(a => a.FullName).OrderBy(a => a.EducationPlugin); return plugins.DistinctBy(a => a.FullName).OrderBy(a => a.EducationPlugin);