Browse Source

handle json comments and exception improvement.

pull/6668/head
Ilkay Ilknur 6 years ago
parent
commit
4ec7a536ad
  1. 15
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/ConfigReader.cs

15
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<AbpCliConfig>(configText,options);
return JsonSerializer.Deserialize<AbpCliConfig>(configText, options);
}
}
}

Loading…
Cancel
Save