From 57b522fe42aaefc48a3c7c4275ca8fe330116203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=93=E7=A3=8A?= Date: Thu, 13 Jun 2024 15:59:13 +0800 Subject: [PATCH] Update TranslationService.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复空白字符串AI不翻译返回导致数组越界的问题 --- .../BotSharp.Core/Translation/TranslationService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs b/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs index 97e997c7c..ec33f609d 100644 --- a/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs +++ b/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs @@ -121,7 +121,7 @@ private void Collect(T data, ref HashSet res) where T : class if (data == null) return; var dataType = data.GetType(); - if (IsStringType(dataType)) + if (IsStringType(dataType) && !string.IsNullOrWhiteSpace(data.ToString())) { res.Add(data.ToString()); return; @@ -139,7 +139,7 @@ private void Collect(T data, ref HashSet res) where T : class { foreach (var item in (data as IEnumerable)) { - if (item == null) continue; + if (string.IsNullOrWhiteSpace(item)) continue; res.Add(item); } }