-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Show conflict messages in status bar #2442
Conversation
I'll see if I can get to this in the next couple of days. |
Code looks good, although I haven't actually tested it yet. A few general remarks:
That used to be the case, C# 7.0 introduced a functional-style pattern matching syntax. The compiler is smart enough to recognize that an For confirmation you can check the IL produced by these two pieces of code: object o = null;
if (o == null)
Console.WriteLine(); object o = null;
if (o is null)
Console.WriteLine(); In the first case you get:
In the second case you get:
They're identical. In both cases the two operands are simply loaded onto the stack (lines 3-4) and then compared using the
I generally disagree, one of the benefits of static typing is that we can leverage tools like the IDE to aid the programmer. We know what type an object is because the compiler, and by extension the IDE, knows. We know what we're allowed to call on it because the compiler, and by extension the IDE, knows. In general, the only time I wouldn't use |
Good to know it wasn't actually misbehaving previously, but I think
That assumes that code is only ever viewed in an IDE with those specific features. Personally, I use a regular text editor, and I also frequently browse code on GitHub or in tools like Gitg. In such situations, The only time I find |
Thanks, @dbent, I was hoping for exactly that sort of discussion! In testing, I note that when the modlist is refreshed (removing all selections) thanks to changing KSP compatibility settings, the status bar message indicating conflicts does not disappear. |
e2261a9
to
17d9d77
Compare
@politas, thanks, I moved the status bar clearing from where it was to a spot that should be hit regardless of who resets the change set. |
Problems
If you try to install two mods that conflict with one another, they'll be highlighted red, but there are no hints as to the cause if they're not on-screen.
If you manually install a mod, and then attempt to install or upgrade a mod in CKAN that conflicts with it, the mod is not highlighted red and there are no other clues as to what's going on, see KSP-CKAN/NetKAN#6533.
Some effort was made toward creating a popup for this in #2237, but it was not completed. Part of the challenge is that a popup can be disruptive and is not something we would want to happen every time the user clicks a checkbox.
Causes
Conflicts previously were used to mark rows red, abort the creation of a change set, and leave the Apply button disabled, but specific descriptive messages weren't shown.
The code that highlights conflicts relies on
RelationshipResolver.ConflictList
, which only checks conflicts betweenCkanModule
s and ignores DLLs and DLCs.Changes
The changes in this pull request are somewhat high risk and should be subjected to close scrutiny. It's possible that I missed an important test case, so please try any obscure things you can think of and report problems!
Status bar shows conflict messages
Now if you select two conflicting mods for install, a short description of the conflict is shown in the status bar to explain why the rows are highlighted:
If more than one conflict is present, only one will be shown, because we stop looking once we find the first. If the displayed problem is fixed, then the other conflict will be shown. Hopefully this will be enough to help users figure out what to do.
Previously, clicking any row would clear the previous status bar message. This doesn't make sense anymore now that the status bar contains useful information about the current conflict. This is now removed, and instead the message is cleared if we are able to successfully calculate a change set without problems.
Conflicts with DLLs included in
RelationshipResolver.ConflictList
SanityChecker
is rewritten to throw a newBadRelationshipsKraken
exception instead ofInconsistentKraken
. This new exception inherits from the old one for backwards compatibility. WhereInconsistentKraken
provided only a list of opaque error strings, the new exception provides machine-readable descriptions of the problems to allow calling code to react to them.RelationshipResolver
now always runsSanityChecker
. (SanityChecker
's exception is only passed along if not turned off in the resolver options, as before.) If any conflicts with DLLs and DLCs are found, these are added to the data structure that providesRelationshipResolver.ConflictList
(by way of the new exception described above). This allows the conflicting row to be highlighted. A description of the conflict will be shown in the status bar as described above:Small things
The ", cannot install both" suffix is removed from the messages for conflicts, for consistency with other places that already don't have this.
In the course of investigation, I found several places where we check
variable is null
. Theis
operator in C# dynamically checks types, not values, and from what I can tell it's better to checkvariable == null
. This pull request makes that change.The
var
keyword obscures code because it's harder to tell what type an object is and what we're allowed to call on it. This is replaced with types in several places.The status bar tooltip is now set to the text it contains, in case some message is very long and some runtime displays such tooltips (I was not able to get these to display on Mono).
Some conflict-checking code in
CkanModule
was duplicative of logic inRelationshipDescriptor
. Now the duplication is removed by having one function call the other.A blank comment line was missing from the auto generated code in
Main.Designer.cs
. This is now restored, which hopefully will help prevent parsing problems in Visual Studio.