Author |
Topic |
|
Uniwares
Tomato Guru
Portugal
2322 Posts |
Posted - Mar 17 2021 : 05:24:28 AM
|
Often I wish I could open all source files related to the code I am working on. Especially when writing white-box tests. And if I could select "open all related types/files" -> from project / from solution, with the option to open them all in a new document well, that would be perfect. I am not talking here about the cpp/h files but types and their files. When doing C++ it should consider of course the appropriate cpp/h files, in C# it would consider only .cs files. |
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Mar 17 2021 : 07:51:50 AM
|
Can you give me an example of what you mean?
How are you defining "related" files? Is this a function of the file name? The headers included? The classes used, so basically all files containing the string "FooBarThing"? |
zen is the art of being at one with the two'ness |
|
|
Uniwares
Tomato Guru
Portugal
2322 Posts |
Posted - Mar 17 2021 : 08:16:20 AM
|
Given the following (parcial) code file:
public void TestLabelPrinting()
{
const string content = "some test text to print ";
HardwareManager.Instance.SetupPrinters();
using (var testlistener = new IPTestListener("127.0.0.1", 5000))
{
testlistener.Run();
LocalLabelPrinter a = new LocalLabelPrinter();
a.PrintQRCode(new Barcode(123456));
}
}
Here, related files/types would be "IPTestListener.cs", "LocalLabelPrinter.cs", "Barcode.cs" and "Barcode.subcodes.cs" (partial class spread over 2 files) (all of the classes declared in their own file) but it should not open "HardwareManager.cs" since its not part of the project where the method "TestLabelPrinting()" resides. (unless, I specify "open related files from solution")
For C++ one might want to chose between definition and implementation.
In other words: open files with types that are used in the current file (per project or per solution) |
|
|
Uniwares
Tomato Guru
Portugal
2322 Posts |
Posted - Mar 17 2021 : 08:18:16 AM
|
I would even go so far as set a limit for automatically opening a number of files. lets say, more than 5 files and a dialog shows with the full list, where you chose which ones to open. |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Mar 17 2021 : 08:57:03 AM
|
OK, so the project, or solution, requirement filters out any stable include / system files. That makes sense.
How "related" does a type have to be? Just trying to get a good sense of the obvious edge cases.
A class holding a member of "Barcode", but currently the class isn't used. A function taking a parameter of type "Barcode"? If you are in C++ and are in a header file, are all included files to be listed? You often have unused includes after all.
I am just thinking that for larger files you could end up with quite a few related files, but being able to limit it to project will help cut down the list size. |
zen is the art of being at one with the two'ness |
|
|
Uniwares
Tomato Guru
Portugal
2322 Posts |
Posted - Mar 17 2021 : 10:08:44 AM
|
In my point of view, any type that is actually used should be considered. When I instantiate a type, it is used. When I receive a type as parameter, its used. Doesn't make much sense to include files that are just "included" for C++, if the types in it are not used anywhere (in this file). Includes for external types, never open. Sure that for C++ its a bit more complex, but doable. C# should be quite easy.
Maybe even offer a "open files for types in current method|class(type)|file" to further limit which files are opened. I might have 50 methods in the current file but only the current method is my focus (although one might consider types from the enclosing type when they are used in the method. Like in class members used in method. etc. bunch of possibilities here)
Maybe I should just make an VS extension for that... (I have no idea how to do that though) |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Mar 17 2021 : 2:01:56 PM
|
Based on a support point of view, doing this yourself is probably "easy for the easy cases", and rapidly gets messy after that
When I need something like this I tend to just use a mixture of bookmarks, to get me back to where I started, and Alt-G, to find the symbols, files I want. So just opening the main files you want makes a lot of sense, getting a clear sense of what you are trying to achieve here is important though. I have put in a feature request, to see what our developers make of this idea:
case=144540 |
zen is the art of being at one with the two'ness |
|
|
|
Topic |
|