Skip to content

Commit

Permalink
修复配置文件转换为Yml时没有对特殊符号加上双引号的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GardenHamster committed Jun 20, 2024
1 parent 02a4eb3 commit 0fab9ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Theresa3rd-Bot/TheresaBot.Main/Model/Yml/YmlOperater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ public void SaveConfig(T data)
{
data.FormatConfig();
var enumConverter = new EnumConverter();
var serializer = new SerializerBuilder().WithTypeConverter(enumConverter).Build();
var yamlContent = serializer.Serialize(data);
var serializer = new SerializerBuilder();
serializer.WithTypeConverter(enumConverter);
serializer.WithQuotingNecessaryStrings();
var yamlContent = serializer.Build().Serialize(data);
using StreamWriter stream = new StreamWriter(YmlPath, false, Encoding.GetEncoding("gb2312"));
stream.Write(yamlContent);
stream.Flush();
Expand Down
2 changes: 1 addition & 1 deletion Theresa3rd-Bot/TheresaBot.Main/TheresaBot.Main.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<PackageReference Include="SqlSugar.IOC" Version="2.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.129" />
<PackageReference Include="WordCloud.NetCore" Version="1.1.0" />
<PackageReference Include="YamlDotNet" Version="13.7.1" />
<PackageReference Include="YamlDotNet" Version="15.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 0fab9ab

Please sign in to comment.