Skip to content

Commit

Permalink
fixes #1998
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikEJ committed Nov 11, 2023
1 parent 962ae05 commit dffe05b
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 13 deletions.
Binary file modified .nuget/nuget.exe
Binary file not shown.
1 change: 1 addition & 0 deletions src/GUI/RevEng.Core.60/ReverseEngineerScaffolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public SavedModelFiles GenerateStoredProcedures(
UseSchemaFolders = options.UseSchemaFolders,
UseAsyncCalls = options.UseAsyncCalls,
UseSchemaNamespaces = options.UseSchemaNamespaces,
UseDecimalDataAnnotation = options.UseDecimalDataAnnotation,
};

var procedureScaffoldedModel = procedureScaffolder.ScaffoldModel(procedureModel, procedureOptions, schemas, ref errors);
Expand Down
19 changes: 13 additions & 6 deletions src/GUI/RevEng.Core.60/Routines/SqlServerRoutineScaffolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,36 +309,43 @@ private string WriteResultClass(List<ModuleResultElement> resultElements, Module

using (Sb.Indent())
{
GenerateClass(resultElements, name, options.NullableReferences);
GenerateClass(resultElements, name, options.NullableReferences, options.UseDecimalDataAnnotation);
}

Sb.AppendLine("}");

return Sb.ToString();
}

private void GenerateClass(List<ModuleResultElement> resultElements, string name, bool nullableReferences)
private void GenerateClass(List<ModuleResultElement> resultElements, string name, bool nullableReferences, bool useDecimalDataAnnotation)
{
Sb.AppendLine($"public partial class {name}");
Sb.AppendLine("{");

using (Sb.Indent())
{
GenerateProperties(resultElements, nullableReferences);
GenerateProperties(resultElements, nullableReferences, useDecimalDataAnnotation);
}

Sb.AppendLine("}");
}

private void GenerateProperties(List<ModuleResultElement> resultElements, bool nullableReferences)
private void GenerateProperties(List<ModuleResultElement> resultElements, bool nullableReferences, bool useDecimalDataAnnotation)
{
foreach (var property in resultElements.OrderBy(e => e.Ordinal))
{
var propertyNames = GeneratePropertyName(property.Name);

if (!string.IsNullOrEmpty(propertyNames.Item2))
if (property.StoreType == "decimal" && useDecimalDataAnnotation)
{
Sb.AppendLine(propertyNames.Item2);
Sb.AppendLine($"[Column(\"{property.Name}\", TypeName = \"{property.StoreType}({property.Precision},{property.Scale})\")]");
}
else
{
if (!string.IsNullOrEmpty(propertyNames.Item2))
{
Sb.AppendLine(propertyNames.Item2);
}
}

var propertyType = property.ClrType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class ModuleScaffolderOptions
public virtual bool UseSchemaFolders { get; set; }
public virtual bool UseAsyncCalls { get; set; }
public virtual bool UseSchemaNamespaces { get; set; }
public virtual bool UseDecimalDataAnnotation { get; set; }
}
}
1 change: 1 addition & 0 deletions src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static ReverseEngineerCommandOptions ToOptions(this CliConfig config, str
UseNullableReferences = config.CodeGeneration.UseNullableReferenceTypes,
ProjectRootNamespace = names.RootNamespace,
MergeDacpacs = config.CodeGeneration.MergeDacpacs,
UseDecimalDataAnnotation = config.CodeGeneration.UseDecimalDataAnnotation,

// Not supported:
UseHandleBars = false,
Expand Down
3 changes: 3 additions & 0 deletions src/GUI/RevEng.Shared/Cli/Configuration/CodeGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ public class CodeGeneration

[JsonPropertyName("merge-dacpacs")]
public bool MergeDacpacs { get; set; }

[JsonPropertyName("use-decimal-data-annotation-for-sproc-results")]
public bool UseDecimalDataAnnotation { get; set; } = true;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace RevEng.Common.Cli.VsCode
{
public class Input
internal sealed class InputItem
{
public string type { get; set; }
public string id { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/GUI/RevEng.Shared/Cli/VsCode/Presentation.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace RevEng.Common.Cli.VsCode
{
public class Presentation
internal sealed class Presentation
{
public string reveal { get; set; }
}
Expand Down
2 changes: 1 addition & 1 deletion src/GUI/RevEng.Shared/Cli/VsCode/TaskItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace RevEng.Common.Cli.VsCode
{
internal class TaskItem
internal sealed class TaskItem
{
public string label { get; set; }
public string command { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/GUI/RevEng.Shared/Cli/VsCode/VsCodeTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace RevEng.Common.Cli.VsCode
{
internal class VsCodeTask
internal sealed class VsCodeTask
{
public string version { get; set; }
public List<TaskItem> tasks { get; set; }
public List<Input> inputs { get; set; }
public List<InputItem> inputs { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/GUI/RevEng.Shared/Cli/VsCode/VsCodeTaskHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public static void GenerateTaskPayload(string projectPath, int version, string r
problemMatcher = "$msCompile",
},
},
inputs = new System.Collections.Generic.List<Input>
inputs = new System.Collections.Generic.List<InputItem>
{
new Input
new InputItem
{
type = "promptString",
id = "connection",
Expand Down
1 change: 1 addition & 0 deletions src/GUI/RevEng.Shared/ReverseEngineerCommandOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class ReverseEngineerCommandOptions
public bool MergeDacpacs { get; set; }
public bool UseLegacyResultSetDiscovery { get; set; }
public bool UseAsyncCalls { get; set; }
public bool UseDecimalDataAnnotation { get; set; }
public bool PreserveCasingWithRegex { get; set; }
public bool UseDateOnlyTimeOnly { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public static async Task<ReverseEngineerResult> LaunchExternalRunnerAsync(Revers
PreserveCasingWithRegex = options.PreserveCasingWithRegex,
UseDateOnlyTimeOnly = options.UseDateOnlyTimeOnly,
UseSchemaNamespaces = options.UseSchemaNamespaces,
UseDecimalDataAnnotation = options.UseDecimalDataAnnotationForSprocResult,
};

var launcher = new EfRevEngLauncher(commandOptions, codeGenerationMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ public class ReverseEngineerOptions
public bool PreserveCasingWithRegex { get; set; } = true;
public bool UseDateOnlyTimeOnly { get; set; }
public string T4TemplatePath { get; set; }
public bool UseDecimalDataAnnotationForSprocResult { get; set; } = true;
}
}
Binary file modified src/GUI/lib/efreveng60.exe.zip
Binary file not shown.
Binary file modified src/GUI/lib/efreveng70.exe.zip
Binary file not shown.
Binary file modified src/GUI/lib/efreveng80.exe.zip
Binary file not shown.

0 comments on commit dffe05b

Please sign in to comment.