{"record":{"id":"d7046ec30f5c5d9d","repo":"babalae/better-genshin-impact","slug":"error-d7046e","errorCode":null,"errorMessage":"角色养成识别：当前结果尚未初始化。","messagePattern":"角色养成识别：当前结果尚未初始化。","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs","lineNumber":261,"sourceCode":"    private CharacterDevelopmentResult? _currentResult;\n    private Queue<CharacterDevelopmentCategory> _pendingCategories = new();\n    private CharacterDevelopmentCategory _currentCategory;\n    private string? _pendingElementType;\n    private string? _pendingWeaponType;\n    private List<Point> _talentPoints = [];\n    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","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs#L243-L279","documentation":"Thrown by the `CurrentResult` property getter when `_currentResult` is null. `_currentResult` is created in `PrepareCharacter` (line 345) alongside `_currentTarget`. It accumulates the recognized attributes/weapon/talent for the active character and is pushed into `_results`. Like the other lazy properties, it is non-null only during an active run for the current character.","triggerScenarios":"Reading `CurrentResult` before `PrepareCharacter` has run, or from code outside the `Start()` execution window.","commonSituations":"Direct handler invocation in tests; accessing results mid-run from another thread before `PrepareCharacter` completes; reading the property after `Start` returns.","solutions":["Use `Start()` as the only entry point — it guarantees `PrepareCharacter(0)` runs first.","To obtain results, read the `List<CharacterDevelopmentResult>` returned by `Start()` rather than `CurrentResult`.","Do not read `CurrentResult` from cleanup or post-run code."],"exampleFix":"// before\nvar result = task.CurrentResult; // throws if not running\n\n// after\nvar results = await task.Start(ct); // use the returned list","handlingStrategy":"validation","validationCode":"// CurrentResult is per-active-character and only valid during Start().\n// Use the returned results list: var results = await task.Start(ct);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Consume the List<CharacterDevelopmentResult> from Start() rather than CurrentResult.","Do not read CurrentResult from post-run or cleanup code.","Ensure PrepareCharacter runs before any handler that writes to CurrentResult."],"tags":["state-machine","null-guard","lifecycle","character-development"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}