{"record":{"id":"64b3f36866529a1f","repo":"babalae/better-genshin-impact","slug":"paramname","errorCode":null,"errorMessage":"{paramName} 不能为空","messagePattern":"\\{paramName\\} 不能为空","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/BgiVision/BvPage.cs","lineNumber":176,"sourceCode":"        if (values is string || values is not IEnumerable enumerable)\n        {\n            throw new ArgumentException($\"{paramName} 必须是集合或 JS Array\", paramName);\n        }\n\n        List<T> result = [];\n        foreach (var value in enumerable)\n        {\n            if (value is not T typedValue)\n            {\n                throw new ArgumentException($\"{paramName} 中的每个元素都必须是 {typeof(T).Name}\", paramName);\n            }\n\n            result.Add(typedValue);\n        }\n\n        if (result.Count == 0)\n        {\n            throw new ArgumentException($\"{paramName} 不能为空\", paramName);\n        }\n\n        return result;\n    }\n}\n","sourceCodeStart":158,"sourceCodeEnd":182,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/BgiVision/BvPage.cs#L158-L182","documentation":"The final guard in ParseCollection<T> rejects an empty collection with ArgumentException. A zero-length match set is useless for OCR/text matching (no candidate can ever succeed) and would mask caller bugs, so the helper treats it as a contract violation rather than returning an unusable locator.","triggerScenarios":"GetByAnyText(new string[]{}); GetByAnyText([]) from JS; a dynamically-built list that ended up empty after filtering.","commonSituations":"Localization tables with no entries for a given key; filters that remove all candidates; config-driven arrays left uninitialized.","solutions":["Ensure at least one non-empty candidate is present before calling.","If the list is dynamic, check .Any() first and skip/handle the empty case explicitly.","Default to a sensible fallback candidate rather than an empty array."],"exampleFix":"// before\nvar loc = page.GetByAnyText(candidates); // candidates may be empty\n\n// after\nif (candidates.Length == 0)\n{\n    // handle missing-text case (skip, log, default)\n}\nelse\n{\n    var loc = page.GetByAnyText(candidates);\n}","handlingStrategy":"validation","validationCode":"if (candidates is null || !candidates.Any())\n{\n    // handle empty case (skip, default, log)\n    return;\n}\nvar loc = page.GetByAnyText(candidates);","typeGuard":"static bool IsNonEmpty<T>(IEnumerable<T>? xs) => xs?.Any() == true;","tryCatchPattern":null,"preventionTips":["Check .Any() on dynamically built candidate lists before calling.","Default to a known-good fallback candidate instead of an empty array.","Treat an empty match set as a configuration error and surface it."],"tags":["bgivision","argument-validation","empty-collection"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}