Skip to content

Commit

Permalink
Only save cliConfig when the cliConfig file does not exists or config…
Browse files Browse the repository at this point in the history
….CodeGeneration object is true (#2163)
  • Loading branch information
fredyadriano90 authored Feb 15, 2024
1 parent 8f7b567 commit 4e1b66b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public static ReverseEngineerCommandOptions ToOptions(this CliConfig config, str

public static bool TryGetCliConfig(string fullPath, string connectionString, DatabaseType databaseType, List<TableModel> objects, CodeGenerationMode codeGenerationMode, out CliConfig config, out List<string> warnings)
{
if (File.Exists(fullPath))
var cliConfigExists = File.Exists(fullPath);
if (cliConfigExists)
{
config = JsonSerializer.Deserialize<CliConfig>(File.ReadAllText(fullPath, Encoding.UTF8));
}
Expand Down Expand Up @@ -147,10 +148,13 @@ public static bool TryGetCliConfig(string fullPath, string connectionString, Dat

warnings = ValidateExcludedColumns(config, objects);

if (!cliConfigExists || config.CodeGeneration.RefreshObjectLists)
{
#pragma warning disable CA1869 // Cache and reuse 'JsonSerializerOptions' instances
var options = new JsonSerializerOptions { WriteIndented = true };
var options = new JsonSerializerOptions { WriteIndented = true };
#pragma warning restore CA1869 // Cache and reuse 'JsonSerializerOptions' instances
File.WriteAllText(fullPath, JsonSerializer.Serialize(config, options), Encoding.UTF8);
File.WriteAllText(fullPath, JsonSerializer.Serialize(config, options), Encoding.UTF8);
}

return true;
}
Expand Down

0 comments on commit 4e1b66b

Please sign in to comment.