{"record":{"id":"97e5572c9ecc3fd1","repo":"babalae/better-genshin-impact","slug":"error-97e557","errorCode":null,"errorMessage":"至少需要指定一个角色。","messagePattern":"至少需要指定一个角色。","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs","lineNumber":267,"sourceCode":"    private int _talentIndex;\n    private readonly HashSet<string> _readTalentTypes = new(StringComparer.Ordinal);\n\n    protected override ILogger Logger => _logger;\n\n    private AvatarGridIconRecognizer Recognizer =>\n        _recognizer ?? throw new InvalidOperationException(\"角色养成识别：头像识别器尚未初始化。\");\n\n    private CharacterSelectionTarget CurrentTarget =>\n        _currentTarget ?? throw new InvalidOperationException(\"角色养成识别：当前角色尚未初始化。\");\n\n    private CharacterDevelopmentResult CurrentResult =>\n        _currentResult ?? throw new InvalidOperationException(\"角色养成识别：当前结果尚未初始化。\");\n\n    public CharacterDevelopmentStateMachineTask(IReadOnlyList<string> characterNames, CharacterDevelopmentCategory categories)\n    {\n        if (characterNames.Count == 0)\n        {\n            throw new ArgumentException(\"至少需要指定一个角色。\", nameof(characterNames));\n        }\n\n        if (categories == CharacterDevelopmentCategory.None)\n        {\n            throw new ArgumentException(\"至少需要指定一个读取分类。\", nameof(categories));\n        }\n\n        _categories = categories;\n        _targets = characterNames.Select(CharacterSelectionHelper.CreateTarget).ToList();\n        var captureRect = TaskContext.Instance().SystemInfo.ScaleMax1080PCaptureRect;\n        _assets = CharacterDevelopmentAssets.Get(captureRect.Width, captureRect.Height);\n\n        RegisterStateMethodsByAttribute();\n        RegisterStateTransitions(\n            (CharacterDevelopmentState.Unknown, [CharacterDevelopmentState.MainUi, CharacterDevelopmentState.OpenCharacterList]),\n            (CharacterDevelopmentState.MainUi, [CharacterDevelopmentState.OpenCharacterList]),\n            (CharacterDevelopmentState.OpenCharacterList, [CharacterDevelopmentState.OpenFilterPanel]),\n            (CharacterDevelopmentState.OpenFilterPanel, [CharacterDevelopmentState.FilterPanel]),","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs#L249-L285","documentation":"Constructor argument check: `CharacterDevelopmentStateMachineTask` refuses an empty `characterNames` collection. The task must read at least one character, so an empty list is a programmer error and fails fast with `ArgumentException`.","triggerScenarios":"Constructing the task with `new List<string>()`, an empty array `[]`, or a collection whose only element normalizes to nothing upstream; calling a hypothetical batch API that forwards an empty list.","commonSituations":"A script/config that supplies no character names; a UI that lets the user start the task without selecting any character; passing through an unvalidated list from user input.","solutions":["Validate that the character list is non-empty before constructing the task.","Ensure the caller (e.g. `GetCharacter`/`GetCharacters`) forwards at least one non-empty name.","Guard the UI/script layer so the task cannot be started with zero characters."],"exampleFix":"// before\nvar task = new CharacterDevelopmentStateMachineTask([], cats);\n\n// after\nif (characterNames is null || characterNames.Count == 0)\n    throw new ArgumentException(\"至少需要指定一个角色。\", nameof(characterNames));\nvar task = new CharacterDevelopmentStateMachineTask(characterNames, cats);","handlingStrategy":"validation","validationCode":"if (characterNames is null || characterNames.Count == 0)\n    throw new ArgumentException(\"至少需要指定一个角色。\", nameof(characterNames));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the character list at the UI/script boundary before constructing the task.","Filter empty entries from user-provided name lists.","Ensure batch callers always forward at least one name."],"tags":["argument-validation","constructor","character-development"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}