Skip to content

Commit

Permalink
clean up generated Fields.cs file
Browse files Browse the repository at this point in the history
 #921 partial

mostly just removing excess whitespace, shaved over 1500 blank lines
  • Loading branch information
gbirchmeier committed Jan 2, 2025
1 parent 091420f commit 154c25c
Show file tree
Hide file tree
Showing 2 changed files with 23,175 additions and 24,793 deletions.
69 changes: 34 additions & 35 deletions DDTool/DDTool/Generators/GenFields.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using DDTool.Structures;

Expand Down Expand Up @@ -29,11 +30,11 @@ private static string Generate(List<DDField> fields) {
"",
"using System;",
"",
"namespace QuickFix.Fields",
"{"
"namespace QuickFix.Fields;",
};

foreach (var field in fields) {
lines.Add("");
switch (field.CsClass) {
case "DateTimeField":
case "TimeOnlyField":
Expand All @@ -45,56 +46,54 @@ private static string Generate(List<DDField> fields) {
}
}

lines.Add("}");
lines.Add("");
return string.Join(Environment.NewLine, lines);
}

private static void AppendDateField(List<string> lines, DDField field) {
lines.Add(" /// <summary>");
lines.Add($" /// {field.Name} Field");
lines.Add(" /// </summary>");
lines.Add($" public sealed class {field.Name} : {field.CsClass}");
lines.Add(" {");
lines.Add($" public const int TAG = {field.Tag};");
lines.Add("/// <summary>");
lines.Add($"/// {field.Name} Field");
lines.Add("/// </summary>");
lines.Add($"public sealed class {field.Name} : {field.CsClass}");
lines.Add("{");
lines.Add($" public const int TAG = {field.Tag};");
lines.Add("");

lines.Add($" public {field.Name}()");
lines.Add($" :base(Tags.{field.Name}) {{}}");
lines.Add($" public {field.Name}({field.BaseType} val)");
lines.Add($" :base(Tags.{field.Name}, val) {{}}");
lines.Add($" public {field.Name}({field.BaseType} val, bool showMilliseconds)");
lines.Add($" :base(Tags.{field.Name}, val, showMilliseconds) {{}}");
lines.Add($" public {field.Name}({field.BaseType} val, Converters.TimeStampPrecision precision)");
lines.Add($" :base(Tags.{field.Name}, val, precision) {{}}");
lines.Add($" public {field.Name}()");
lines.Add($" : base(Tags.{field.Name}) {{}}");
lines.Add($" public {field.Name}({field.BaseType} val)");
lines.Add($" : base(Tags.{field.Name}, val) {{}}");
lines.Add($" public {field.Name}({field.BaseType} val, bool showMilliseconds)");
lines.Add($" : base(Tags.{field.Name}, val, showMilliseconds) {{}}");
lines.Add($" public {field.Name}({field.BaseType} val, Converters.TimeStampPrecision precision)");
lines.Add($" : base(Tags.{field.Name}, val, precision) {{}}");
lines.Add("");

AppendFieldEnumerations(lines, field);

lines.Add(" }");
lines.Add("");
lines.Add("}");
lines.Add("");
}

private static void AppendNonDateField(List<string> lines, DDField field) {
lines.Add(" /// <summary>");
lines.Add($" /// {field.Name} Field");
lines.Add(" /// </summary>");
lines.Add($" public sealed class {field.Name} : {field.CsClass}");
lines.Add(" {");
lines.Add($" public const int TAG = {field.Tag};");
lines.Add("/// <summary>");
lines.Add($"/// {field.Name} Field");
lines.Add("/// </summary>");
lines.Add($"public sealed class {field.Name} : {field.CsClass}");
lines.Add("{");
lines.Add($" public const int TAG = {field.Tag};");
lines.Add("");

lines.Add($" public {field.Name}()");
lines.Add($" :base(Tags.{field.Name}) {{}}");
lines.Add($" public {field.Name}({field.BaseType} val)");
lines.Add($" :base(Tags.{field.Name}, val) {{}}");
lines.Add("");
lines.Add($" public {field.Name}()");
lines.Add($" : base(Tags.{field.Name}) {{}}");
lines.Add($" public {field.Name}({field.BaseType} val)");
lines.Add($" : base(Tags.{field.Name}, val) {{}}");

AppendFieldEnumerations(lines, field);
if (lines.Count > 0) {
AppendFieldEnumerations(lines, field);
}

lines.Add(" }");
lines.Add("");
lines.Add("}");
lines.Add("");
}

Expand All @@ -103,7 +102,7 @@ private static void AppendFieldEnumerations(List<string> lines, DDField field) {
return;

lines.Add("");
lines.Add(" // Field Enumerations");
lines.Add(" // Field Enumerations");

foreach (var enumVal in field.Enums) {
string desc = enumVal.Desc.Replace('.', '_');
Expand All @@ -122,7 +121,7 @@ private static void AppendFieldEnumerations(List<string> lines, DDField field) {
$"unsupported field type '{field.BaseType}' ({field})")
};

lines.Add($" public const {field.BaseType} {desc} = {outVal};");
lines.Add($" public const {field.BaseType} {desc} = {outVal};");
}
}
}
Loading

0 comments on commit 154c25c

Please sign in to comment.