mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 17:21:16 +08:00
- 修复 YamlConfigAllowedValue 与 YamlConfigConstantValue 对空对象 const 或 enum 比较键的误判,同时继续拒绝非空纯空白输入 - 补充 YamlConfigModelContractTests 对空比较键与纯空白比较键的回归覆盖,并验证空对象 const 场景 - 更新 ai-plan 公共索引并归档 analyzer-warning-reduction 主题,保留最终 PR review 结论与验证记录
40 lines
1.7 KiB
C#
40 lines
1.7 KiB
C#
namespace GFramework.Game.Config;
|
|
|
|
/// <summary>
|
|
/// 表示一个节点上声明的单个 <c>enum</c> 候选值。
|
|
/// 该模型同时保留稳定比较键与原始 JSON 文本,分别供运行时匹配和诊断输出复用。
|
|
/// </summary>
|
|
internal sealed class YamlConfigAllowedValue
|
|
{
|
|
/// <summary>
|
|
/// 初始化一个枚举候选值模型。
|
|
/// </summary>
|
|
/// <param name="comparableValue">用于与 YAML 节点比较的稳定键。</param>
|
|
/// <param name="displayValue">用于诊断输出的原始 JSON 文本。</param>
|
|
/// <exception cref="ArgumentNullException">当 <paramref name="comparableValue"/> 或 <paramref name="displayValue"/> 为 <see langword="null" /> 时抛出。</exception>
|
|
/// <exception cref="ArgumentException">当 <paramref name="comparableValue"/> 虽然非空但仅包含空白字符,或 <paramref name="displayValue"/> 为空或仅包含空白字符时抛出。</exception>
|
|
public YamlConfigAllowedValue(string comparableValue, string displayValue)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(comparableValue);
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(displayValue);
|
|
if (comparableValue.Length > 0 &&
|
|
string.IsNullOrWhiteSpace(comparableValue))
|
|
{
|
|
throw new ArgumentException("The value cannot be composed entirely of whitespace.", nameof(comparableValue));
|
|
}
|
|
|
|
ComparableValue = comparableValue;
|
|
DisplayValue = displayValue;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取用于运行时比较的稳定键。
|
|
/// </summary>
|
|
public string ComparableValue { get; }
|
|
|
|
/// <summary>
|
|
/// 获取用于诊断输出的原始 JSON 文本。
|
|
/// </summary>
|
|
public string DisplayValue { get; }
|
|
}
|