Repository navigation
Add backward compatibility with Nuke projects not yet migrated in the CLI completion #663
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,10 +28,7 @@ public static IReadOnlyDictionary<string, string[]> GetItemsFromSchema( | |
| var rootElement = schema.RootElement; | ||
| var definitions = rootElement.GetProperty("definitions").EnumerateObject().ToDictionary(x => x.Name, x => x); | ||
|
|
||
| var parameterProperties = rootElement.GetProperty("definitions").TryGetProperty("FalloutBuild", out var baseSchema) | ||
| ? baseSchema.GetProperty("properties").EnumerateObject() | ||
| .Concat(rootElement.GetProperty("allOf")[0].TryGetProperty("properties", out var properties) ? properties.EnumerateObject() : []) | ||
| : definitions["build"].Value.GetProperty("properties").EnumerateObject(); | ||
| var parameterProperties = GetParameterProperties(rootElement, definitions); | ||
|
|
||
| return parameterProperties | ||
| .Where(filter) | ||
|
|
@@ -72,6 +69,34 @@ string[] GetValues(JsonProperty property) | |
| } | ||
| } | ||
|
|
||
| private static IEnumerable<JsonProperty> GetParameterProperties(JsonElement rootElement, | ||
| Dictionary<string, JsonProperty> definitions) | ||
| { | ||
| if (!TryGetSchema(rootElement, "FalloutBuild", out var baseSchema) && | ||
| // Backward compatibility with NukeBuild projects not yet migrated | ||
| !TryGetSchema(rootElement, "NukeBuild", out baseSchema)) | ||
| { | ||
| if (!definitions.TryGetValue("build", out var buildProperties)) | ||
| { | ||
| // legacy build properties not found ! | ||
| return []; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔🤖 A missing |
||
| } | ||
| return buildProperties.Value.GetProperty("properties").EnumerateObject(); | ||
| } | ||
|
|
||
| return baseSchema.GetProperty("properties").EnumerateObject() | ||
| .Concat(rootElement.GetProperty("allOf")[0].TryGetProperty("properties", out var properties) | ||
| ? properties.EnumerateObject() | ||
| : []); | ||
| } | ||
|
|
||
| private static bool TryGetSchema(JsonElement rootElement, string buildPropertyName, out JsonElement baseSchema) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ♻️🤖 |
||
| { | ||
| return rootElement | ||
| .GetProperty("definitions") | ||
| .TryGetProperty(buildPropertyName, out baseSchema); | ||
| } | ||
|
|
||
| // ReSharper disable once CognitiveComplexity | ||
| public static IEnumerable<string> GetRelevantItems( | ||
| string words, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧🤖 The negated
TryGetSchemachain with theout baseSchematrick is hard to follow. Pick the first ofFalloutBuild/NukeBuildfound indefinitions, then fall back tobuild.