DiffTools.TryFind method is confusing
See original GitHub issueThe 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, ...)
toTryFindByName(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 toTryFindTool
etc for consistency withAddTool
- 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:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i agree in principle. can u submit a PR with your changes. then we can iterate on that if necessary
–> https://github.com/VerifyTests/DiffEngine/pull/272