From e24dbdc496debec225414d4d2c760f5775e64f2a Mon Sep 17 00:00:00 2001
From: 天地 <tiandiweizun@gmail.com>
Date: 星期三, 26 三月 2025 13:44:41 +0800
Subject: [PATCH] 感觉应该从文件读取更合适,因为上面判断了文件存在,且可以读取,如果本身是文本的话,下面也会有逻辑进行处理 (#2452)

---
 runtime/csharp/AliParaformerAsr/AliParaformerAsr/Utils/YamlHelper.cs |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/runtime/csharp/AliParaformerAsr/AliParaformerAsr/Utils/YamlHelper.cs b/runtime/csharp/AliParaformerAsr/AliParaformerAsr/Utils/YamlHelper.cs
index 15c13e3..225d4c8 100644
--- a/runtime/csharp/AliParaformerAsr/AliParaformerAsr/Utils/YamlHelper.cs
+++ b/runtime/csharp/AliParaformerAsr/AliParaformerAsr/Utils/YamlHelper.cs
@@ -14,16 +14,19 @@
     /// YamlHelper
     /// Copyright (c)  2023 by manyeyes
     /// </summary>
-    internal class YamlHelper
+    internal class YamlHelper 
     {
-        public static T ReadYaml<T>(string yamlFilePath)
+        public static T ReadYaml<T>(string yamlFilePath) where T:new()
         {
             if (!File.Exists(yamlFilePath))
             {
-#pragma warning disable CS8603 // 鍙兘杩斿洖 null 寮曠敤銆�
-                return default(T);
-#pragma warning restore CS8603 // 鍙兘杩斿洖 null 寮曠敤銆�
+                // 濡傛灉鍏佽杩斿洖榛樿瀵硅薄锛屽垯鏂板缓涓�涓粯璁ゅ璞★紝鍚﹀垯搴旇鏄姏鍑哄紓甯�
+                // If allowing to return a default object, create a new default object; otherwise, throw an exception
+
+                return new T();
+                // throw new Exception($"not find yaml config file: {yamlFilePath}");
             }
+
             StreamReader yamlReader = File.OpenText(yamlFilePath);
             Deserializer yamlDeserializer = new Deserializer();
             T info = yamlDeserializer.Deserialize<T>(yamlReader);

--
Gitblit v1.9.1