GFValidationSuite¶
API Reference / Standard / 类索引
- 路径:
addons/gf/standard/foundation/validation/gf_validation_suite.gd - 模块:
Standard - 继承:
Resource - API:
public - 类别:资源定义 (
resource_definition) - 首次版本:
3.17.0
通用校验套件资源。 保存一组规则与可选资源路径筛选条件。套件只描述“要检查什么”,实际加载、 实例化和报告聚合由 GFValidationRunner 完成。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 常量 | GFValidationRuleBase |
const GFValidationRuleBase = preload("res://addons/gf/standard/foundation/validation/gf_validation_rule.gd") |
| 常量 | DEFAULT_MAX_SCAN_DEPTH |
const DEFAULT_MAX_SCAN_DEPTH: int = 32 |
| 常量 | DEFAULT_MAX_COLLECTED_PATHS |
const DEFAULT_MAX_COLLECTED_PATHS: int = 10_000 |
| 属性 | suite_id |
var suite_id: StringName = &"" |
| 属性 | description |
var description: String = "" |
| 属性 | enabled |
var enabled: bool = true |
| 属性 | treat_warnings_as_errors |
var treat_warnings_as_errors: bool = false |
| 属性 | rules |
var rules: Array[GFValidationRuleBase] = [] |
| 属性 | include_paths |
var include_paths: PackedStringArray = PackedStringArray() |
| 属性 | exclude_paths |
var exclude_paths: PackedStringArray = PackedStringArray() |
| 属性 | resource_extensions |
var resource_extensions: PackedStringArray = PackedStringArray(["tres", "res"]) |
| 属性 | scene_extensions |
var scene_extensions: PackedStringArray = PackedStringArray(["tscn", "scn"]) |
| 属性 | recursive |
var recursive: bool = true |
| 属性 | include_hidden |
var include_hidden: bool = false |
| 属性 | max_scan_depth |
var max_scan_depth: int = DEFAULT_MAX_SCAN_DEPTH: |
| 属性 | max_collected_paths |
var max_collected_paths: int = DEFAULT_MAX_COLLECTED_PATHS: |
| 属性 | metadata |
var metadata: Dictionary = {} |
| 方法 | add_rule |
func add_rule(rule: GFValidationRuleBase) -> bool: |
| 方法 | remove_rule |
func remove_rule(rule: GFValidationRuleBase) -> bool: |
| 方法 | get_enabled_rules |
func get_enabled_rules() -> Array[GFValidationRuleBase]: |
| 方法 | matches_path |
func matches_path(path: String) -> bool: |
| 方法 | collect_paths |
func collect_paths() -> PackedStringArray: |
| 方法 | duplicate_suite |
func duplicate_suite() -> GFValidationSuite: |
常量¶
GFValidationRuleBase¶
- API:
public
const GFValidationRuleBase = preload("res://addons/gf/standard/foundation/validation/gf_validation_rule.gd")
校验规则脚本基类。
DEFAULT_MAX_SCAN_DEPTH¶
- API:
public
默认递归扫描目录深度上限。
DEFAULT_MAX_COLLECTED_PATHS¶
- API:
public
默认单次路径收集数量上限。
属性¶
suite_id¶
- API:
public
套件标识。
description¶
- API:
public
套件说明。
enabled¶
- API:
public
是否启用套件。
treat_warnings_as_errors¶
- API:
public
是否把警告提升为错误。
rules¶
- API:
public
校验规则列表。
include_paths¶
- API:
public
需要扫描的路径。可以是文件或目录;为空时不自动扫描。
exclude_paths¶
- API:
public
需要排除的路径或通配模式。
resource_extensions¶
- API:
public
资源文件扩展名,不含点号。
scene_extensions¶
- API:
public
场景文件扩展名,不含点号。
recursive¶
- API:
public
扫描目录时是否递归。
include_hidden¶
- API:
public
扫描目录时是否包含隐藏目录和文件。
max_scan_depth¶
- API:
public
递归扫描的最大目录深度。0 表示不限制。
max_collected_paths¶
- API:
public
单次 collect_paths() 最多收集的路径数量。0 表示不限制。
metadata¶
- API:
public
可选元数据。框架不解释该字段。
结构:
metadata: Dictionary of caller-defined suite metadata.
方法¶
add_rule¶
- API:
public
添加规则。
参数:
| 名称 | 说明 |
|---|---|
rule |
规则资源。 |
返回:添加成功返回 true。
remove_rule¶
- API:
public
移除规则。
参数:
| 名称 | 说明 |
|---|---|
rule |
规则资源。 |
返回:移除成功返回 true。
get_enabled_rules¶
- API:
public
获取启用的规则。
返回:规则数组副本。
matches_path¶
- API:
public
检查路径是否会被套件扫描。
参数:
| 名称 | 说明 |
|---|---|
path |
资源或场景路径。 |
返回:匹配返回 true。
collect_paths¶
- API:
public
收集 include_paths 中匹配的资源和场景路径。
返回:已排序路径列表。
duplicate_suite¶
- API:
public
创建套件配置副本。
返回:新套件。