Compare commits

...

2 Commits

Author SHA1 Message Date
2248356998 qq.com
c0337e2b19 build: 10.11.105
feat: json添加AllowNamedFloatingPointLiterals
2025-10-15 11:16:18 +08:00
2248356998 qq.com
8a95f48f5a 适配 net10 rc2 2025-10-15 10:02:11 +08:00
11 changed files with 43 additions and 23 deletions

View File

@@ -251,10 +251,12 @@ public class RequestAuditFilter : IAsyncActionFilter, IOrderedFilter
if (exception == null)
{
if (logger.IsEnabled(LogLevel.Information))
logger.Log(LogLevel.Information, $"{logData.Method}:{logData.Path}-{logData.Operation}");
}
else
{
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,6 +66,7 @@ internal class JsonStringLocalizer(Assembly assembly, string typeName, string ba
}
catch (Exception ex)
{
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;
@@ -176,6 +177,7 @@ internal class JsonStringLocalizer(Assembly assembly, string typeName, string ba
localizationMissingItemHandler.HandleMissingItem(name, typeName, CultureInfo.CurrentUICulture.Name);
if (jsonLocalizationOptions.IgnoreLocalizerMissing == false)
{
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}");

View File

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

View File

@@ -369,10 +369,12 @@ internal sealed class ScheduleHostedService : BackgroundService
// 写入作业执行详细日志
if (executionException == null)
{
if (jobLogger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Information) == true)
jobLogger?.LogInformation("{jobExecutingContext}", jobExecutingContext);
}
else
{
if (jobLogger?.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Error) == true)
jobLogger?.LogError(executionException, "{jobExecutingContext}", jobExecutingContext);
}

View File

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

View File

@@ -4,7 +4,7 @@
<Import Project="..\..\PackNuget.props" />
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;net6.0;net6.0-windows;net8.0;$(OtherTargetFrameworks);net8.0-windows;</TargetFrameworks>
<TargetFrameworks>net47;netstandard2.0;net6.0;net6.0-windows;net8.0;$(OtherTargetFrameworks);net8.0-windows;</TargetFrameworks>
<AssemblyName>ThingsGateway.NewLife.X</AssemblyName>
<RootNamespace>ThingsGateway.NewLife</RootNamespace>
<AssemblyTitle>工具核心库</AssemblyTitle>
@@ -35,12 +35,11 @@
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<PackageReference Include="System.Memory" Version="4.6.3" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<ItemGroup Condition="'$(TargetFramework)'=='net47'">
<PackageReference Include="System.Memory" Version="4.6.3" />
<PackageReference Include="System.ValueTuple" Version="4.6.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<ItemGroup Condition="'$(TargetFramework)'=='net47'">
<Using Include="System.Net.Http" />
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System.Management" />

View File

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

View File

@@ -1,13 +1,13 @@
<Project>
<PropertyGroup>
<PluginVersion>10.11.102</PluginVersion>
<ProPluginVersion>10.11.102</ProPluginVersion>
<DefaultVersion>10.11.102</DefaultVersion>
<PluginVersion>10.11.105</PluginVersion>
<ProPluginVersion>10.11.105</ProPluginVersion>
<DefaultVersion>10.11.105</DefaultVersion>
<AuthenticationVersion>10.11.6</AuthenticationVersion>
<SourceGeneratorVersion>10.11.6</SourceGeneratorVersion>
<NET8Version>8.0.20</NET8Version>
<NET10Version>10.0.0-rc.1.25451.107</NET10Version>
<NET8Version>8.0.21</NET8Version>
<NET10Version>10.0.0-rc.2.25502.107</NET10Version>
<SatelliteResourceLanguages>zh-Hans;en-US</SatelliteResourceLanguages>
<IsTrimmable>false</IsTrimmable>
<ManagementProPluginVersion>10.11.87</ManagementProPluginVersion>

View File

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

View File

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

View File

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