{"record":{"id":"cc805805f37ab3e1","repo":"babalae/better-genshin-impact","slug":"error-cc8058","errorCode":null,"errorMessage":"角色名集合不能为空。","messagePattern":"角色名集合不能为空。","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs","lineNumber":143,"sourceCode":"        if (characterNames is not IEnumerable enumerable)\n        {\n            throw new ArgumentException(\"角色名参数必须是字符串集合或 JS Array。\", nameof(characterNames));\n        }\n\n        List<string> names = [];\n        foreach (var item in enumerable)\n        {\n            if (item is not string name)\n            {\n                throw new ArgumentException(\"角色名集合中的每个元素都必须是字符串。\", nameof(characterNames));\n            }\n\n            names.Add(NormalizeCharacterName(name));\n        }\n\n        if (names.Count == 0)\n        {\n            throw new ArgumentException(\"角色名集合不能为空。\", nameof(characterNames));\n        }\n\n        return names;\n    }\n\n    private static string NormalizeCharacterName(string characterName)\n    {\n        var name = characterName?.Trim() ?? string.Empty;\n        if (string.IsNullOrWhiteSpace(name))\n        {\n            throw new ArgumentException(\"角色名不能为空。\", nameof(characterName));\n        }\n\n        return name;\n    }\n\n    internal static CharacterDevelopmentCategory ParseCategories(string? categories)\n    {","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs#L125-L161","documentation":"Thrown by ParseCharacterNames when the collection is enumerable and all elements are valid strings, but the resulting list is empty (names.Count == 0). An empty collection is not a valid input since there are no characters to process.","triggerScenarios":"Called from ParseCharacterNames. The enumerable yields no elements (e.g. empty array, empty list). All type checks pass but names.Count == 0 at the end.","commonSituations":"JavaScript caller passes an empty array []; C# caller passes an empty List<string>(); the collection was constructed dynamically and ended up empty.","solutions":["Pass at least one valid character name in the collection.","Check the array length before calling GetMultiCharacters.","If no characters are needed, don't call the method at all."],"exampleFix":"// before (wrong)\nawait dev.GetMultiCharacters([]);\n// after\nawait dev.GetMultiCharacters(['钟离']);","handlingStrategy":"validation","validationCode":"// Check collection is non-empty before calling\nif (names is ICollection col && col.Count == 0)\n{\n    throw new ArgumentException(\"characterNames collection must not be empty.\");\n}","typeGuard":"static bool IsNonEmptyStringCollection(object obj)\n{\n    if (obj is string || obj is not IEnumerable e) return false;\n    return e.Cast<object>().Any(x => x is string);\n}","tryCatchPattern":"try\n{\n    await dev.GetMultiCharacters(names);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"不能为空\"))\n{\n    // Add at least one character name\n}","preventionTips":["Check the collection has at least one element before calling.","Don't call GetMultiCharacters if no characters are needed.","Validate array length from JavaScript callers."],"tags":["character-development","argument-validation","empty-collection"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}