Revert "fix(sac): 修复预览页序列化 SacInfo 时 TypeId 触发 IsGenericParameter 异常"

This reverts commit ca74095e0c.
This commit is contained in:
张名锐
2026-07-31 10:49:18 +08:00
parent 5d580960d8
commit dfac28f54a
2 changed files with 13 additions and 10 deletions
@@ -117,12 +117,6 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
public class SacDescriptionAttribute : Attribute
{
// Attribute.TypeId 本质是 System.TypeNewtonsoft 序列化会触发
// "Method may only be called on a Type for which Type.IsGenericParameter is true."
// 预览页用 ToJson() 序列化 SacInfo/List<SacInfo> 时崩溃,故显式跳过该成员。
// 13.0.1 安全版对 Type 成员序列化行为变更后暴露此问题)
public bool ShouldSerializeTypeId() => false;
/// <summary>
/// 字段名
/// </summary>
+13 -4
View File
@@ -37,15 +37,13 @@ namespace YLErp.Web.App
try
{
// 暴露完整异常(类型 + 所有内层 message + 堆栈),不再只取最内层 message,
// 便于定位根因(如 SacInfo 序列化 TypeId 触发的 IsGenericParameter 反射异常)。
message = exception.ToString();
message = GetInnerExceptionMessage(exception);
if (serviceExpcetion == null || serviceExpcetion.IsFaultError)
{
var result = await request.BodyReader.ReadAsync();
var reqBody = ConvertBufferToString(result.Buffer);
LogFactory.GetLogger(context.Request.Path.Value).Error(serviceExpcetion ?? exception, $"[query]:{request.QueryString.Value};[body]:{reqBody}\r\n{message}");
LogFactory.GetLogger(context.Request.Path.Value).Error(serviceExpcetion ?? exception, $"[query]:{request.QueryString.Value};[body]:{reqBody}");
}
}
catch (Exception ex)
@@ -79,5 +77,16 @@ namespace YLErp.Web.App
ReadOnlySpan<byte> span = readOnlySequence.IsSingleSegment ? readOnlySequence.First.Span : readOnlySequence.ToArray().AsSpan();
return System.Text.Encoding.UTF8.GetString(span);
}
private static string GetInnerExceptionMessage(Exception ex)
{
var exceptionStr = ex.Message;
while (ex.InnerException != null)
{
exceptionStr = ex.InnerException.Message;
ex = ex.InnerException;
}
return exceptionStr;
}
}
}