From ccb6b5ad4283f4218a76103924389cfa41b42e78 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Thu, 9 Apr 2026 19:43:15 +0800 Subject: [PATCH] =?UTF-8?q?docs(agents):=20=E6=B7=BB=E5=8A=A0AI=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E8=A1=8C=E4=B8=BA=E5=87=86=E5=88=99=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 定义了环境能力清单和工具选择规则 - 规定了XML文档注释、内联注释和架构级注释要求 - 明确了代码风格包括命名规范、格式化和C#约定 - 设立了测试覆盖范围、组织结构和验证命令标准 - 制定了安全输入验证、依赖管理和权限控制规则 - 确立了文档更新、任务跟踪和审查完成标准 - 更新了浮点数比较算法中的容差计算方式 - 优化了数值精度验证逻辑以避免十进制步进误差 --- AGENTS.md | 4 ++++ GFramework.Game/Config/YamlConfigSchemaValidator.cs | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 311042dd..cb19f63c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -104,6 +104,10 @@ All generated or modified code MUST include clear and meaningful comments where - Keep `using` directives at the top of the file and sort them consistently. - Separate logical blocks with blank lines when it improves readability. - Prefer one primary type per file unless the surrounding project already uses a different local pattern. +- Unless there is a clear and documented reason to keep a file large, keep a single source file under roughly 800-1000 + lines. +- If a file grows beyond that range, contributors MUST stop and check whether responsibilities should be split before + continuing; treating oversized files as the default is considered a design smell. - Keep line length readable. Around 120 characters is the preferred upper bound. ### C# Conventions diff --git a/GFramework.Game/Config/YamlConfigSchemaValidator.cs b/GFramework.Game/Config/YamlConfigSchemaValidator.cs index d8c09f9f..f7dc74c4 100644 --- a/GFramework.Game/Config/YamlConfigSchemaValidator.cs +++ b/GFramework.Game/Config/YamlConfigSchemaValidator.cs @@ -1745,8 +1745,9 @@ internal static class YamlConfigSchemaValidator /// /// 判断数值是否满足 multipleOf。 - /// 双精度浮点比较会保留一个与商值量级相关的微小容差, - /// 以避免运行时与 JS 工具侧在 0.1 / 0.01 这类十进制步进上出现伪失败。 + /// 双精度浮点比较会保留一个与步进量级相关的微小容差, + /// 以避免运行时与 JS 工具侧在 0.1 / 0.01 这类十进制步进上出现伪失败, + /// 同时避免值越大就无限放宽合法余数范围。 /// /// 当前值。 /// 步进约束。 @@ -1755,8 +1756,8 @@ internal static class YamlConfigSchemaValidator { var quotient = value / divisor; var nearestInteger = Math.Round(quotient); - var tolerance = 1e-9 * Math.Max(1d, Math.Abs(quotient)); - return Math.Abs(quotient - nearestInteger) <= tolerance; + var tolerance = 1e-9 * Math.Max(1d, Math.Abs(divisor)); + return Math.Abs(value - (nearestInteger * divisor)) <= tolerance; } ///