Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Predefined List in Code Generation extension #23

Merged
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a6fad7e
Added handling for predefined lists for code generation of TextField
devlife Mar 5, 2021
a546a6d
Reverted some string formatting
devlife Mar 5, 2021
3448418
Check for name and value properties
devlife Mar 6, 2021
8b1ac54
Spacing
devlife Mar 8, 2021
b979035
Updated formatting
devlife Apr 8, 2021
52c07ff
Update Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs
devlife Apr 9, 2021
aeae0f1
Replaced tabs with spaces
devlife Apr 19, 2021
4712eba
Merge branch 'extension/code-generation/add-predefined-list-handling'…
devlife Apr 19, 2021
8da317e
Update Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs
devlife Apr 20, 2021
4de0065
Merge branch 'Lombiq:dev' into extension/code-generation/add-predefin…
devlife Mar 5, 2022
b8c7555
Fixed up formatting
devlife Mar 5, 2022
af195a0
Removed NuGet.config
devlife Mar 5, 2022
480e111
Update to use ContainsOrdinalIgnoreCase
devlife Mar 7, 2022
a3b98fc
Rename parameter
devlife Mar 8, 2022
926bcc6
Update error message
devlife Mar 8, 2022
6cc87f4
Made array init format properties on separate lines
devlife Mar 8, 2022
af907dd
Fix formatting
devlife Mar 8, 2022
49cff4c
Remove extra closing brace
devlife Mar 8, 2022
5103ada
Updated formatting and removed @ symbol
devlife Mar 8, 2022
372c1f2
Fix string array formatting
devlife Mar 8, 2022
fd3a307
Add missing comma
devlife Mar 8, 2022
74e462e
Update for code analyzer fixes
devlife Mar 8, 2022
c985db2
Update Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs
devlife Mar 8, 2022
b62ee3a
Update Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs
devlife Mar 8, 2022
24d2e11
Update Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs
devlife Mar 8, 2022
1016044
Update Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs
devlife Mar 8, 2022
78f895d
Update Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs
devlife Mar 8, 2022
9b6be42
Renamed `format` to `indentation`
devlife Mar 9, 2022
18ce507
Merge branch 'extension/code-generation/add-predefined-list-handling'…
devlife Mar 9, 2022
70942a4
Rename variable
devlife Mar 9, 2022
dd7160f
Converted string.Join to use string ctor
devlife Mar 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,24 @@ private string ConvertJToken(JToken jToken)
string _ => $"\"{value}\"",
_ => value?.ToString()?.Replace(',', '.'), // Replace decimal commas.
};

case JArray jArray:
return $"new[] {{ {string.Join(", ", jArray.Select(ConvertJToken))} }}";
var token = string.Join(", ", jArray.Select(ConvertJToken));
var format = token.Contains("ListValueOption") ? "\n\t\t\t" : "";
devlife marked this conversation as resolved.
Show resolved Hide resolved
Piedone marked this conversation as resolved.
Show resolved Hide resolved

return $"new[] {format}{{ {string.Join(", ", token)} {format}}}";

case JObject jObject:
// Using a quoted string so it doesn't mess up the syntax highlighting of the rest of the code.
return T["\"FIX ME! Couldn't determine the actual type to instantiate.\" {0}", jObject.ToString()];
if (jObject["name"] != null && jObject["value"] != null)
{
return $"\n\t\t\t\tnew ListValueOption {{ Name = \"{jObject["name"]}\", Value = \"{jObject["value"]}\" }}";
}
else
{
// Using a quoted string so it doesn't mess up the syntax highlighting of the rest of the code.
return T["\"FIX ME! Couldn't determine the actual type to instantiate.\" {0}", jObject.ToString()];
}
devlife marked this conversation as resolved.
Show resolved Hide resolved

default:
throw new NotSupportedException($"Settings values of type {jToken.GetType()} are not supported.");
}
Expand Down