diff --git a/src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs b/src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs index fe976f3d9..a662a3373 100644 --- a/src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs +++ b/src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs @@ -185,9 +185,12 @@ private static List ValidateExcludedColumns(CliConfig config, List warnings = new(); - var objectsToCheck = config.Tables.Where(x => x.ExcludedColumns?.Count > 0) + var tables = config.Tables ?? new List
(); + var views = config.Views ?? new List(); + + var objectsToCheck = tables.Where(x => x.ExcludedColumns?.Count > 0) .Select(table => table as IEntity) - .Union(config.Views.Where(x => x.ExcludedColumns?.Count > 0)); + .Union(views.Where(x => x.ExcludedColumns?.Count > 0)); foreach (var table in objectsToCheck) { @@ -324,7 +327,7 @@ private static List Add(IEnumerable models, List entities) var newItems = models.Where(o => o.ObjectType == objectType).ToList(); if (newItems.Count == 0) { - return new List(); + return null; } var result = entities ?? new List(); @@ -339,7 +342,7 @@ private static List Add(IEnumerable models, List entities) } } - return result; + return result.Count > 0 ? result : null; } private static ObjectType DefineObjectType() diff --git a/src/GUI/RevEng.Shared/Cli/Configuration/CliConfig.cs b/src/GUI/RevEng.Shared/Cli/Configuration/CliConfig.cs index 0136c2906..89d0722e9 100644 --- a/src/GUI/RevEng.Shared/Cli/Configuration/CliConfig.cs +++ b/src/GUI/RevEng.Shared/Cli/Configuration/CliConfig.cs @@ -6,43 +6,54 @@ namespace RevEng.Common.Cli.Configuration #pragma warning disable CA2227 public class CliConfig { + [JsonPropertyOrder(-1)] [JsonPropertyName("$schema")] #pragma warning disable CA1822 public string JsonSchema => "https://raw.githubusercontent.com/ErikEJ/EFCorePowerTools/master/samples/efcpt-schema.json"; #pragma warning restore CA1822 + + [JsonPropertyOrder(10)] [JsonPropertyName("code-generation")] public CodeGeneration CodeGeneration { get; set; } = new CodeGeneration(); - [JsonPropertyName("names")] - public Names Names { get; set; } = new Names(); - + [JsonPropertyOrder(20)] [JsonPropertyName("file-layout")] public FileLayout FileLayout { get; set; } = new FileLayout(); - [JsonPropertyName("type-mappings")] + [JsonPropertyOrder(30)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - public TypeMappings TypeMappings { get; set; } + [JsonPropertyName("functions")] + public List Functions { get; set; } + + [JsonPropertyOrder(40)] + [JsonPropertyName("names")] + public Names Names { get; set; } = new Names(); + [JsonPropertyOrder(50)] [JsonPropertyName("replacements")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public Replacements Replacements { get; set; } - [JsonPropertyName("tables")] + [JsonPropertyOrder(60)] + [JsonPropertyName("stored-procedures")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - public List
Tables { get; set; } + public List StoredProcedures { get; set; } - [JsonPropertyName("views")] + [JsonPropertyOrder(70)] + [JsonPropertyName("tables")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - public List Views { get; set; } + public List
Tables { get; set; } - [JsonPropertyName("stored-procedures")] + [JsonPropertyOrder(80)] + [JsonPropertyName("type-mappings")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - public List StoredProcedures { get; set; } + public TypeMappings TypeMappings { get; set; } + [JsonPropertyOrder(90)] + [JsonPropertyName("views")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - [JsonPropertyName("functions")] - public List Functions { get; set; } + public List Views { get; set; } } #pragma warning restore CA2227 } diff --git a/src/GUI/RevEng.Shared/Cli/Configuration/CodeGeneration.cs b/src/GUI/RevEng.Shared/Cli/Configuration/CodeGeneration.cs index eddf931c0..7f21fd112 100644 --- a/src/GUI/RevEng.Shared/Cli/Configuration/CodeGeneration.cs +++ b/src/GUI/RevEng.Shared/Cli/Configuration/CodeGeneration.cs @@ -4,66 +4,86 @@ namespace RevEng.Common.Cli.Configuration { public class CodeGeneration { + [JsonPropertyOrder(10)] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + [JsonPropertyName("discover-multiple-stored-procedure-resultsets-preview")] + public bool DiscoverMultipleStoredProcedureResultsetsPreview { get; set; } + + [JsonPropertyOrder(20)] [JsonPropertyName("enable-on-configuring")] public bool EnableOnConfiguring { get; set; } + [JsonPropertyOrder(30)] + [JsonPropertyName("generate-mermaid-diagram")] + public bool GenerateMermaidDiagram { get; set; } + + [JsonPropertyOrder(40)] + [JsonPropertyName("merge-dacpacs")] + public bool MergeDacpacs { get; set; } + + [JsonPropertyOrder(50)] + [JsonPropertyName("refresh-object-lists")] + public bool RefreshObjectLists { get; set; } = true; + + [JsonPropertyOrder(60)] + [JsonPropertyName("remove-defaultsql-from-bool-properties")] + public bool RemoveDefaultSqlFromBoolProperties { get; set; } + + [JsonPropertyOrder(70)] + [JsonPropertyName("soft-delete-obsolete-files")] + public bool SoftDeleteObsoleteFiles { get; set; } = true; + + [JsonPropertyOrder(80)] + [JsonPropertyName("t4-template-path")] + public string T4TemplatePath { get; set; } + + [JsonPropertyOrder(90)] [JsonPropertyName("type")] public string Type { get; set; } = "all"; - [JsonPropertyName("use-database-names")] - public bool UseDatabaseNames { get; set; } + [JsonPropertyOrder(100)] + [JsonPropertyName("use-alternate-stored-procedure-resultset-discovery")] + public bool UseAlternateStoredProcedureResultsetDiscovery { get; set; } + [JsonPropertyOrder(110)] [JsonPropertyName("use-data-annotations")] public bool UseDataAnnotations { get; set; } - [JsonPropertyName("use-nullable-reference-types")] - public bool UseNullableReferenceTypes { get; set; } = true; + [JsonPropertyOrder(120)] + [JsonPropertyName("use-database-names")] + public bool UseDatabaseNames { get; set; } + [JsonPropertyOrder(130)] + [JsonPropertyName("use-decimal-data-annotation-for-sproc-results")] + public bool UseDecimalDataAnnotation { get; set; } = true; + + [JsonPropertyOrder(140)] [JsonPropertyName("use-inflector")] public bool UseInflector { get; set; } = true; + [JsonPropertyOrder(150)] [JsonPropertyName("use-legacy-inflector")] public bool UseLegacyInflector { get; set; } + [JsonPropertyOrder(160)] [JsonPropertyName("use-many-to-many-entity")] public bool UseManyToManyEntity { get; set; } - [JsonPropertyName("use-t4")] - public bool UseT4 { get; set; } - - [JsonPropertyName("t4-template-path")] - public string T4TemplatePath { get; set; } - - [JsonPropertyName("remove-defaultsql-from-bool-properties")] - public bool RemoveDefaultSqlFromBoolProperties { get; set; } - - [JsonPropertyName("soft-delete-obsolete-files")] - public bool SoftDeleteObsoleteFiles { get; set; } = true; - - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - [JsonPropertyName("discover-multiple-stored-procedure-resultsets-preview")] - public bool DiscoverMultipleStoredProcedureResultsetsPreview { get; set; } - - [JsonPropertyName("use-alternate-stored-procedure-resultset-discovery")] - public bool UseAlternateStoredProcedureResultsetDiscovery { get; set; } - + [JsonPropertyOrder(170)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("use-no-navigations-preview")] public bool UseNoNavigationsPreview { get; set; } - [JsonPropertyName("merge-dacpacs")] - public bool MergeDacpacs { get; set; } - - [JsonPropertyName("use-decimal-data-annotation-for-sproc-results")] - public bool UseDecimalDataAnnotation { get; set; } = true; - - [JsonPropertyName("generate-mermaid-diagram")] - public bool GenerateMermaidDiagram { get; set; } - - [JsonPropertyName("refresh-object-lists")] - public bool RefreshObjectLists { get; set; } = true; + [JsonPropertyOrder(180)] + [JsonPropertyName("use-nullable-reference-types")] + public bool UseNullableReferenceTypes { get; set; } = true; + [JsonPropertyOrder(190)] [JsonPropertyName("use-prefix-navigation-naming")] public bool UsePrefixNavigationNaming { get; set; } + + [JsonPropertyOrder(200)] + [JsonPropertyName("use-t4")] + public bool UseT4 { get; set; } } } diff --git a/src/GUI/RevEng.Shared/Cli/Configuration/FileLayout.cs b/src/GUI/RevEng.Shared/Cli/Configuration/FileLayout.cs index 124135663..1425227d7 100644 --- a/src/GUI/RevEng.Shared/Cli/Configuration/FileLayout.cs +++ b/src/GUI/RevEng.Shared/Cli/Configuration/FileLayout.cs @@ -4,20 +4,25 @@ namespace RevEng.Common.Cli.Configuration { public class FileLayout { - [JsonPropertyName("output-path")] - public string OutputPath { get; set; } = "Models"; - + [JsonPropertyOrder(10)] [JsonPropertyName("output-dbcontext-path")] public string OutputDbContextPath { get; set; } + [JsonPropertyOrder(20)] + [JsonPropertyName("output-path")] + public string OutputPath { get; set; } = "Models"; + + [JsonPropertyOrder(30)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("split-dbcontext-preview")] public bool SplitDbContextPreview { get; set; } + [JsonPropertyOrder(40)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("use-schema-folders-preview")] public bool UseSchemaFoldersPreview { get; set; } + [JsonPropertyOrder(50)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("use-schema-namespaces-preview")] public bool UseSchemaNamespacesPreview { get; set; } diff --git a/src/GUI/RevEng.Shared/Cli/Configuration/Function.cs b/src/GUI/RevEng.Shared/Cli/Configuration/Function.cs index f14865244..9f5fa3e40 100644 --- a/src/GUI/RevEng.Shared/Cli/Configuration/Function.cs +++ b/src/GUI/RevEng.Shared/Cli/Configuration/Function.cs @@ -7,18 +7,21 @@ namespace RevEng.Common.Cli.Configuration public class Function : IEntity #pragma warning restore CA1716 // Identifiers should not match keywords { - [JsonPropertyName("name")] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - public string Name { get; set; } - + [JsonPropertyOrder(10)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("exclude")] public bool? Exclude { get; set; } + [JsonPropertyOrder(20)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("exclusionWildcard")] public string ExclusionWildcard { get; set; } + [JsonPropertyOrder(30)] + [JsonPropertyName("name")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string Name { get; set; } + [JsonIgnore] public List ExcludedColumns { get; set; } = null; } diff --git a/src/GUI/RevEng.Shared/Cli/Configuration/Names.cs b/src/GUI/RevEng.Shared/Cli/Configuration/Names.cs index b278856f1..ebe1e2fc2 100644 --- a/src/GUI/RevEng.Shared/Cli/Configuration/Names.cs +++ b/src/GUI/RevEng.Shared/Cli/Configuration/Names.cs @@ -4,16 +4,20 @@ namespace RevEng.Common.Cli.Configuration { public class Names { - [JsonPropertyName("root-namespace")] - public string RootNamespace { get; set; } - + [JsonPropertyOrder(10)] [JsonPropertyName("dbcontext-name")] public string DbContextName { get; set; } + [JsonPropertyOrder(20)] [JsonPropertyName("dbcontext-namespace")] public string DbContextNamespace { get; set; } + [JsonPropertyOrder(30)] [JsonPropertyName("model-namespace")] public string ModelNamespace { get; set; } + + [JsonPropertyOrder(40)] + [JsonPropertyName("root-namespace")] + public string RootNamespace { get; set; } } } diff --git a/src/GUI/RevEng.Shared/Cli/Configuration/Replacements.cs b/src/GUI/RevEng.Shared/Cli/Configuration/Replacements.cs index 9961b3347..334d39e0b 100644 --- a/src/GUI/RevEng.Shared/Cli/Configuration/Replacements.cs +++ b/src/GUI/RevEng.Shared/Cli/Configuration/Replacements.cs @@ -4,8 +4,11 @@ namespace RevEng.Common.Cli.Configuration { public class Replacements { + [JsonPropertyOrder(10)] [JsonPropertyName("preserve-casing-with-regex")] public bool PreserveCasingWithRegex { get; set; } + + [JsonPropertyOrder(20)] [JsonPropertyName("uncountable-words")] #pragma warning disable CA1819 public string[] UncountableWords { get; set; } diff --git a/src/GUI/RevEng.Shared/Cli/Configuration/StoredProcedure.cs b/src/GUI/RevEng.Shared/Cli/Configuration/StoredProcedure.cs index c3615b64b..19e8b92d2 100644 --- a/src/GUI/RevEng.Shared/Cli/Configuration/StoredProcedure.cs +++ b/src/GUI/RevEng.Shared/Cli/Configuration/StoredProcedure.cs @@ -5,25 +5,30 @@ namespace RevEng.Common.Cli.Configuration { public class StoredProcedure : IEntity { - [JsonPropertyName("name")] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - public string Name { get; set; } - + [JsonPropertyOrder(10)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("exclude")] public bool? Exclude { get; set; } + [JsonPropertyOrder(20)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - [JsonPropertyName("use-legacy-resultset-discovery")] - public bool UseLegacyResultsetDiscovery { get; set; } + [JsonPropertyName("exclusionWildcard")] + public string ExclusionWildcard { get; set; } + [JsonPropertyOrder(30)] [JsonPropertyName("mapped-type")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string MappedType { get; set; } + [JsonPropertyOrder(40)] + [JsonPropertyName("name")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - [JsonPropertyName("exclusionWildcard")] - public string ExclusionWildcard { get; set; } + public string Name { get; set; } + + [JsonPropertyOrder(50)] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + [JsonPropertyName("use-legacy-resultset-discovery")] + public bool UseLegacyResultsetDiscovery { get; set; } [JsonIgnore] public List ExcludedColumns { get; set; } diff --git a/src/GUI/RevEng.Shared/Cli/Configuration/Table.cs b/src/GUI/RevEng.Shared/Cli/Configuration/Table.cs index 66cb182d6..ed25fccc2 100644 --- a/src/GUI/RevEng.Shared/Cli/Configuration/Table.cs +++ b/src/GUI/RevEng.Shared/Cli/Configuration/Table.cs @@ -5,20 +5,24 @@ namespace RevEng.Common.Cli.Configuration { public class Table : IEntity { - [JsonPropertyName("name")] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - public string Name { get; set; } - + [JsonPropertyOrder(10)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("exclude")] public bool? Exclude { get; set; } + [JsonPropertyOrder(20)] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + [JsonPropertyName("excludedColumns")] + public List ExcludedColumns { get; set; } = null; + + [JsonPropertyOrder(30)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("exclusionWildcard")] public string ExclusionWildcard { get; set; } + [JsonPropertyOrder(40)] + [JsonPropertyName("name")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - [JsonPropertyName("excludedColumns")] - public List ExcludedColumns { get; set; } = null; + public string Name { get; set; } } } diff --git a/src/GUI/RevEng.Shared/Cli/Configuration/TypeMappings.cs b/src/GUI/RevEng.Shared/Cli/Configuration/TypeMappings.cs index e2e39f6e8..82b52813e 100644 --- a/src/GUI/RevEng.Shared/Cli/Configuration/TypeMappings.cs +++ b/src/GUI/RevEng.Shared/Cli/Configuration/TypeMappings.cs @@ -4,13 +4,20 @@ namespace RevEng.Common.Cli.Configuration { public class TypeMappings { + [JsonPropertyOrder(10)] [JsonPropertyName("use-DateOnly-TimeOnly")] public bool UseDateOnlyTimeOnly { get; set; } + + [JsonPropertyOrder(20)] [JsonPropertyName("use-HierarchyId")] public bool UseHierarchyId { get; set; } - [JsonPropertyName("use-spatial")] - public bool UseSpatial { get; set; } + + [JsonPropertyOrder(30)] [JsonPropertyName("use-NodaTime")] public bool UseNodaTime { get; set; } + + [JsonPropertyOrder(40)] + [JsonPropertyName("use-spatial")] + public bool UseSpatial { get; set; } } } diff --git a/src/GUI/RevEng.Shared/Cli/Configuration/View.cs b/src/GUI/RevEng.Shared/Cli/Configuration/View.cs index beff84e14..4ad27335c 100644 --- a/src/GUI/RevEng.Shared/Cli/Configuration/View.cs +++ b/src/GUI/RevEng.Shared/Cli/Configuration/View.cs @@ -5,20 +5,25 @@ namespace RevEng.Common.Cli.Configuration { public class View : IEntity { - [JsonPropertyName("name")] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - public string Name { get; set; } - + [JsonPropertyOrder(10)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("exclude")] public bool? Exclude { get; set; } + [JsonPropertyOrder(20)] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + [JsonPropertyName("excludedColumns")] + public List ExcludedColumns { get; set; } = null; + + [JsonPropertyOrder(30)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonPropertyName("exclusionWildcard")] public string ExclusionWildcard { get; set; } + [JsonPropertyOrder(40)] + [JsonPropertyName("name")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - [JsonPropertyName("excludedColumns")] - public List ExcludedColumns { get; set; } = null; + public string Name { get; set; } + } }