question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DiffTools.TryFind method is confusing

See original GitHub issue

The DiffTools.TryFind is a bit confusing.

Is the feature request related to a problem

Spot the issue:

// Add if not already there
if (!DiffTools.TryFind(name, out _))
{
    DiffTools.AddTool(name, ... );
}

The issue is here that:

  • There is a overload of TryFind that searches by name: public static bool TryFind(DiffTool tool, out ResolvedTool? resolvedTool), while the other (with string parameter), searches by extension: public static bool TryFind(string extension, out ResolvedTool? tool)
  • I expected that the TryFind method is consistent with the AddTool, where name is the first argument.

Describe the solution

There are multiple solutions, those could be technical or semantic breaking. See the "or"s below 😉

  • Add TryFindByExtension(string extension, ...)
  • Rename TryFind(DiffTool tool, ...) to TryFindByName(DiffTool tool, ...)
  • Add TryFindByName(string name, ...)
  • Make TryFind(string extension, ...) obsolete (breaking change!)
  • Make TryFind(DiffTool tool, ...) obsolete (breaking change!)

Describe alternatives considered

  • Instead of TryFind rename to TryFindTool etc for consistency with AddTool
  • No obsolete but hard breaking change

Additional context

Current work around (ugly, need Equals? Needs dictionary lookup?):

// Add if not already there
if (!DiffTools.Resolved.Any(c => c.Name == name))
{
    DiffTools.AddTool(name, ... );
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
SimonCroppcommented, Feb 9, 2022

i agree in principle. can u submit a PR with your changes. then we can iterate on that if necessary

Read more comments on GitHub >

github_iconTop Results From Across the Web

Polymorph (was UI Enhancements) (Version 92)
Now includes *Diff Tools* for comparing code in the method versions browser and Monticello. ... Things to try - Find a class, say...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found