Avoid null ksp_version in Netkan #2558
Merged
+17
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
#2553 tried to fix a problem with setting
"ksp_version": "any"
in a netkan that also has a$vref
. The change worked insofar as netkan was able to generate a .ckan file instead of erroring out, but the script that checks the .ckan file against the schema found a problem:ksp_version
was null, and that's not allowed.This is blocking KSP-CKAN/NetKAN#6791.
Cause
KspVersion.Any.ToString()
returns null because of this:CKAN/Core/Versioning/KspVersion.cs
Line 774 in 5b54850
(This is kind of gross, since the string "any" is specifically allowed in the spec and could be used here, but I'm reluctant to mess with such a core assumption.)
Then when we parse "any" and return
KspVersion.Any
, these lines then setksp_version
to null:CKAN/Netkan/Transformers/AvcTransformer.cs
Lines 145 to 152 in 5b54850
Changes
The
if
checks in these lines are in charge of keepingnull
out of the lists of possible min and max versions:CKAN/Netkan/Transformers/AvcTransformer.cs
Lines 122 to 132 in 5b54850
Now they're updated to also prevent
KspVersion.Any
from being added to those lists. This is done with a new static helper functionKspVersion.IsNullOrAny
in the style ofstring.IsNullOrEmpty
. This will cause the AVC transformer to not make any changes, and the "any" value from the original netkan will flow through to the .ckan file, which is valid according to the spec.