Skip to content

Commit 57b522f

Browse files
authored
Update TranslationService.cs
修复空白字符串AI不翻译返回导致数组越界的问题
1 parent ce24ed9 commit 57b522f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private void Collect<T>(T data, ref HashSet<string> res) where T : class
121121
if (data == null) return;
122122

123123
var dataType = data.GetType();
124-
if (IsStringType(dataType))
124+
if (IsStringType(dataType) && !string.IsNullOrWhiteSpace(data.ToString()))
125125
{
126126
res.Add(data.ToString());
127127
return;
@@ -139,7 +139,7 @@ private void Collect<T>(T data, ref HashSet<string> res) where T : class
139139
{
140140
foreach (var item in (data as IEnumerable<string>))
141141
{
142-
if (item == null) continue;
142+
if (string.IsNullOrWhiteSpace(item)) continue;
143143
res.Add(item);
144144
}
145145
}

0 commit comments

Comments
 (0)