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
Select compatible KSP versions #1957
Conversation
… no longer displayed there
…during startup if KSP has bean updated in the meantime
I can see that continuous integration is failing but I am not sure what can be the cause. It says: System.IO.DirectoryNotFoundException: Could not find a part of the path "/home/travis/build/KSP-CKAN/CKAN/build/Tests/bin/Debug/CKAN.Tests.dll". I can successfully build CKAN tests project. Are there any more details available of the possible cause? |
Note: checking out 'grzegrzk/master'. $ make test Doesn't like Autofac - looks like we haven't used it in the CKAN-GUI space previously, so you'll need to add the reference. I like the sound of this update. Something that lets users break their version compatibility without destroying the main system is a great idea! What does it currently do if the (actual) version of KSP is upgraded between CKAN loads? |
Don't we already have that functionality? yo-yo mode etc, just no GUI for it. |
Thanks for the hint, I have corrected it.
Good to hear - I was missing this feature for some time and I hoped it is in-line with general CKAN philosophy
It displays a warning during CKAN startup or during KSP installation folder switching and forces the user to review selected compatible versions.
As far as I could see YoyoGameComparator returns true regardless of KSP version so it is very unsafe - as an user you have all or nothing. Also, as you mentioned there is no GUI for it. |
Just a side note, @grzegrzk - if you plan to contribute further to the CKAN, you'll find it much easier to do development of changes in a branch, rather than your master. I should be able to review this in detail tomorrow. @ayan4m1, if you have a chance to look it over, I'd appreciate that.
The trouble I have with the previous attempts to get this is that it relied on us making judgement calls about which KSP versions were "close enough", and I have yet to find any two versions of KSP (apart from rushed out patches that don't really count) that didn't break something. |
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.
Changes look sensible to me for the most part. Additional comments:
- I know the codebase is very inconsistent, but new code should follow the appropriate style (which happens to be the general style for all C# code). Basically
PascalCase
all the things except for private fields which should be_underscoreCamelCase
and local variables which should becamelCase
. - There should be a mechanism by which the compatibility list can be manipulated on the command line. Something like:
I could probably do that since you've handled the actual hard part of dealing with the GUI (oh how I loathe the GUI). Of course all of these commands would support the
> ckan ksp compat list Version Actual ---------- ------ 1.2.2.1622 Yes > ckan ksp compat add 1.2.1 > ckan ksp compat list Version Actual ---------- ------ 1.2.2.1622 Yes 1.2.1 No > ckan ksp compat forget 1.2.1 > ckan ksp compat list Version Actual ---------- ------ 1.2.2.1622 Yes > ckan ksp compat add foobar ERROR: 'foobar' is not a valid KSP version. > ckan ksp compat forget foobar ERROR: 'foobar' is not a valid KSP version. > ckan ksp compat forget 1.2.1 > ckan ksp compat forget 1.2.2.1622 ERROR: Cannot forget the actual KSP version.
--ksp
and--kspdir
flags to select a specific installation. - Can the user mark their installation is not compatible with the actual version of their installation? (They probably shouldn't be able to and I made that an error in my CLI example above).
|
||
return moduleRange.IsSupersetOf(gameVersionRange); |
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.
Why is this change necessary? IsSupersetOf
should do exactly what is intended and I believe handles an edge case this code does not.
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.
Now I assume that user can specify that his/her KSP is compatible with "1.0", which is interpreted as "1.0.*" - that is, all mods that are compatible with 1.0.x.y (x and y can be any value) are compatible with this KSP. The old implementation fails in this case.
I have added some test cases to GameComparator. This case is covered by TestStrictGameComparator, test case:
new object[] { "1.0.4.1234", "1.0.4", true },
where "1.0.4.1234" is mod compatibility and "1.0.4" is specified KSP version.
If you have some corner case that should be taken into consideration please let me know what is it and why - I will try to cover it.
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.
I see, so what we really want to test is it the ranges intersect each other. I've added such a method in #1958. It returns a new KspVersionRange
which is equal to the intersection or null
if there is no intersection. Feel free to cherry-pick or merge in.
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.
I also added equivalent tests.
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.
I see, so what we really want to test is it the ranges intersect each other. I've added such a method in #1958. It returns a new KspVersionRange which is equal to the intersection or null if there is no intersection. Feel free to cherry-pick or merge in.
I merged it and it fails in some corner cases. Example: mod specifies min/max supported KSP version, min=1.0.4, max=null, game version=1.0.4. It should return "true" but returns "false" (no intersection).
I tried to thoroughly test the code that I used here because it is tricky :). I can move it to some another place and name the method accordingly, but...I do not know how to name it ("There are only two hard things in Computer Science: cache invalidation and naming things." :) )
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.
Should be fixed in c36ace0, the problem was unbounded bounds (i.e. KspVersionBound.Unbounded
) needed to be treated as highest and lowest possible values in KspVersionBound.Highest()
and KspVersionBound.Lowest()
. Test cases have been added for those situations. Thanks.
EDIT: Fix commit
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.
Also, the saying is:
There are only two hard things in Computer Science: cache invalidation, naming things, and off by one bugs.
😉
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.
Also, the saying is:
There are only two hard things in Computer Science: cache invalidation, naming things, and off by one bugs.
Ha ha, your are right :)
I have pushed the code that uses IntersectWith - all tests are green now :)
this.versions.AddRange(compatibleVersions); | ||
} | ||
|
||
public List<KspVersion> Versions { |
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.
Please keep record-like classes immutable. In this case Versions
should only be exposed as an IEnumerable<KspVersion>
so that client code can't willy-nilly modify the collection (without doing something potentially unsafe like explicitly casting it back to a List<>
).
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.
Actually, I'd rather have this class implement IEnumerable<KspVersion>
and get rid of the Versions
property. It'd simplify a lot of code using this.
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.
Please keep record-like classes immutable.
It now returns _versions.AsReadOnly()
, is it OK?
Actually, I'd rather have this class implement IEnumerable
If the name is changed to KspVersionSet
as you suggested then it would be OK, but I am not sure about naming change (please see my comment above).
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.
It now returns
_versions.AsReadOnly()
, is it OK?
Good enough for me.
|
||
namespace CKAN.Versioning | ||
{ | ||
public class KspVersionCriteria |
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.
I think KspVersionSet
is more descriptive of what this class actually does at the moment. If at some point in the future we actually need additional properties on it that make it "criteria" we can subclass it and add those properties there.
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 class should also behave like a set and only keep a single copy of duplicate KspVersion
objects. This should be easy as KspVersion
implements IEquatable<KspVersion>
.
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.
I think KspVersionSet is more descriptive
I had a feeling that KspVersionCriteria is more general and can be adjusted in the future to behave differently if needed. I assume that you will take care of this code in the future more than me so you have the last word, but in my opinion "Criteria" is OK. Let me know if I should change it.
The class should also behave like a set and only keep a single copy of duplicate KspVersion
Done
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.
Fair enough.
this.versions.Add (v); | ||
} | ||
|
||
public KspVersionCriteria(KspVersion v, List<KspVersion> compatibleVersions) |
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.
Rather than having two constructors how about just a single one with a variadic parameter:
public KspVersionSet(params KspVersion[] versions) { }
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 one that is now is more convenient to use from CKAN.KSP.VersionCriteria()
|
||
private string CompatibleKspVersionsFile() | ||
{ | ||
return Path.Combine(CkanDir(), "compatible_ksp_versions.json"); |
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.
As a sidenote we should really come up with a centralized mechanism to store both global and local settings data that is not the registry. But that's a story for another day.
From my perspective it does not matter - I think of my clone as separate feature branch. But if it is more convenience for you that I create new branch I will do it in the future - no problem, just let me know what you prefer :).
I tried to spot all cases where I introduced something against code style and I have corrected it. If you spot something more please let me know - I will correct it as well. In my daily work I am not from C# world but from Java world, so such style nuances are hard to spot for me :).
I would really appreciate if you could do it - I have the opposite feelings that GUI is much more comfortable to deal with for me - both as an user and as a programmer.
There is no possibility for user to mark anything as "not compatible" - the user can only add compatibility with over versions. |
No problem, that's what I figured. The codebase is a mishmash of styles from all sorts of languages.
We're going to have to clone you. Most programmers I know hate GUI programming. :)
Cool. |
Replace compatibility check with But as a general approach I'm wondering if just having users specify a min and max (so basically a |
I could not figure out that CLI option! I knew there had to be one. @dbent , any chance you could write up a comprehensive list of CLI options that I can make into a CKAN-CLI how-to? |
…ed more unit tests to GameComparator
I sadly do not have advice, but I say, thank you for this. |
A reversion bug, there. We try to avoid hiding inherited members of system libraries. I think this is down to us monodevelop users changing the designer.cs directly, and VisualStudio overwritiing the changes. We really want that column to be called "UpdateCol", not "Update". If you can make that change in VisualStudio, I'd be grateful. Oh, there's that 'ex' variable not being used, too. |
Can you rename that button to get rid of this build warning, too? |
And a couple of warnings in the Tests module as well. |
I also note that (at least on Linux) the Apply and Cancel buttons aren't showing up on the Changeset tab after clicking "Apply Changes". |
@politas Same on Windows |
I do not know what is going on but when I change Main.cs using designer in Visual Studio it completely messes up a lot of controls and design. It caused the buttons to disappear. I reverted the file to the state before my changes and added menu item by hand. Now it works without problem. I also got rid of compilation warnings. |
@politas Probably, but they're pretty much all in here. At some point I want to do a complete overhaul of how the CLI works. |
this.compatibleKSPVersionsToolStripMenuItem.Name = "compatibleKSPVersionsToolStripMenuItem"; | ||
this.compatibleKSPVersionsToolStripMenuItem.Size = new System.Drawing.Size(233, 24); | ||
this.compatibleKSPVersionsToolStripMenuItem.Text = "Compatible KSP versions"; | ||
// |
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.
this.CompatibleKspVersionsToolStripMenuItem.Click += new System.EventHandler(this.CompatibleKspVersionsToolStripMenuItem_Click);
I think you missed this line
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.
Definitely, corrected
The trouble is that the .Designer.cs files have been changed by hand several times, but that doesn't update the .resx file, which I believe is where Visual Studio keeps its knowledge of the layout in a binary format. |
finally with this, i can join the 100+ mod master race with the latest ksp |
@politas the resx only stores things like icons, images, and localized string tables. The Designer.cs is the entirety of the "form layout/position/style" information. |
Wonderful stuff!! @dbent, are you likely to be able to add CLI commands for this functionality in the next couple of days? If not, then I'll push out a new release without waiting for it, then we can do a point release to catch up the CLI. |
All hail @grzegrzk ! Implementer of the most requested feature of all time 👍 |
Thx guys, I am glad that you like it :) |
@grzegrzk, do you have a KSP forum user account I can reference when crediting your submission? You definitely deserve much kudos from the CKAN user community for this. |
@politas Yes, I am Ker_nale. Thx for mentioning me :). |
Is there any way to access this without the GUI? |
Yes, try |
Hi,
I have modified CKAN so user can select which versions of KSP are compatible which his installation (for example user can select that all mods compatible with 1.2.* should be available for him/her).
In my opinion it is especially important now when Squad is releasing frequent small updates that do not break compatibility of majority of mods.
From the user perspective it looks like this: http://imgur.com/vqXRVoI
Changes in code:
I hope it will be useful for more people than just me :).