From 4ec7a536ad21d79af170672d63a1a4849e28a339 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Mon, 14 Dec 2020 23:55:06 +0300 Subject: [PATCH] handle json comments and exception improvement. --- .../Volo/Abp/Cli/Configuration/ConfigReader.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/ConfigReader.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/ConfigReader.cs index f010ac3a56..baf1fc79dc 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/ConfigReader.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/ConfigReader.cs @@ -18,12 +18,17 @@ namespace Volo.Abp.Cli.Configuration if (!File.Exists(settingsFilePath)) { - throw new Exception(); + throw new FileNotFoundException($"appsettings file could not be found. Path:{settingsFilePath}"); } var settingsFileContent = File.ReadAllText(settingsFilePath); - using (var document = JsonDocument.Parse(settingsFileContent)) + var documentOptions = new JsonDocumentOptions + { + CommentHandling = JsonCommentHandling.Skip + }; + + using (var document = JsonDocument.Parse(settingsFileContent,documentOptions)) { var element = document.RootElement.GetProperty("AbpCli"); var configText = element.GetRawText(); @@ -32,9 +37,11 @@ namespace Volo.Abp.Cli.Configuration Converters = { new JsonStringEnumConverter() - } + }, + ReadCommentHandling = JsonCommentHandling.Skip }; - return JsonSerializer.Deserialize(configText,options); + + return JsonSerializer.Deserialize(configText, options); } } }