icsharpcode / ILSpy

.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
21.19k stars 3.32k forks source link

Feature Request: Searching for References #1177

Open SchoolGuy opened 6 years ago

SchoolGuy commented 6 years ago

Hi guys,

I am pretty new to C# and stuff, but I am learning it for work, so I guess I will do this Feature Request by myself and start a pull request.

My collegue asked me to extend the search. He wants me to enable him to search for references and (if possible) for specific versions of them. The benefit would be that in larger solutions he could search through all projects and look if they are referencing the same versions or diffrent versions.

As far as I understood the architecture of ILSpy it is not possible to write an extension for this kind of functionality, I have to dive into ILSpy and adjust and extend the code of the application itself.

If someone around here feels intrested to help me I would appreciate some guideance. I am also in the Gitter channel, so just mention me there. In the I would like to implement the feature by myself because of the learning factor.

Regards, SchoolGuy

siegfriedpammer commented 6 years ago

Implementing such a feature would require to completely change the way search works. Currently it is only possible to search type definitions and members, nothing else.

I would suggest separating AbstractSearchStrategy and its implementations from the Cecil object model and add an interface that serves as "data source" for the search strategies. Then the search could access multiple data sources. There could be a data source for objects from the type system (that is, type definitions and members), for references and for other things we might add in the future.

If you need further help, do not hesitate to ask!

SchoolGuy commented 6 years ago

Ok, I am currently working on it. Currently there are no questions. Exept one...

Why are there multiple classes in one file? - My collegues explained (I am really a newbie) that you should try to keep classes as small as possible (if reasonable). They also added that that you should only have one class, interface, ... keyword per file.

For myself it is currently a bit strange to navigate trough one very large file. I am getting used to it and don't want to start a philosophical discussion about it, but I would love to hear the reason for this because it is quite the opposite I've learned so far.

Thanks for your help!

siegfriedpammer commented 6 years ago

Currently it is very hard to do a lot of clean-up, because we have work on other branches that introduces massive changes. Having massive changes on multiple branches of our code base is not a good idea, as it makes merging them back together hell.

Cleaning up the SearchPane/SearchStrategies.cs will have to wait until we're done with merging the srm branch back to master.

Disclaimer: the search-related code was not written by me.

I try to follow the "one-class-per-file" rule, whereever it makes sense. Sometimes classes are so small that I put them in the same file. Also I like to put many similar enums in one file, or next to the class the enum "belongs".

I think moving the search-related code to its own sub folder "Search" and splitting up the classes into multiple files is a good idea, however currently, please don't!

For myself it is currently a bit strange to navigate trough one very large file.

The sooner you get used to it, the better, 😄 because sooner or later you might end up working with code that is a big mess.

SchoolGuy commented 6 years ago

Ok, thanks for the input. Would it be acceptable for you if I do the clean up? I would also do the merging, when somebody notifys me. For my feature request I would fork, develop and clean up, pull when notified and then send a pull request containing the clean up and new feature.

I know that I have to deal with code in my future developer live which is a big mess that's why I was just asking why the structure was in this particular way.

siegfriedpammer commented 6 years ago

If you are OK with handling a lot of merge conflicts, then I won't stop you. Thank you for stepping in and contributing!

Before you start, please install a git commit hook, that checks if all files use the correct indentation, quote from the README:

If you want to contribute a pull request, please add https://gist.github.com/siegfriedpammer/75700ea61609eb22714d21885e4eb084 to your .git/hooks to prevent checking in code with wrong indentation. We use tabs and not spaces. The build server runs the same script, so any pull requests using wrong indentation will fail.

Also note that there is currently one pull request #1119 that should be merged before you start moving the classes around. I hope we will get that done soon.

Probably it's best if you start with prototyping the ISearchItemProvider and ISearchItem interfaces (names are just suggestions). But I haven't thought much about it yet, so we'll have to talk about it, once you've got something.

Thank you!

SchoolGuy commented 6 years ago

Ok, then I will dive deeper into the search code and try to prototype the two Interfaces.

siegfriedpammer commented 5 years ago

Did you ever complete any of your work? Thank you!

SchoolGuy commented 5 years ago

@siegfriedpammer To be honest switched workplaces and kind of lost track of this one. I am still curious also to be honest but my plate is full, so I have to step back from this one or you need to patient until I can shovel off some stuff of my plate.

imreallybadatnames commented 3 years ago

almost 3 years passed...

Soft-me commented 2 years ago

Is it possible to just search for same string name through all project, not references... It is enough for me.

Ok, I just found that you can right click member and click Analyze, then you can see all instance. Is it kind of same way to search for references ?