OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.79k stars 418 forks source link

Feature request: Omnisharp server project/solution free scan mode. #1206

Open DustinCampbell opened 6 years ago

DustinCampbell commented 6 years ago

From @Fritzoid on May 25, 2018 12:3

Hi,

I'm not sure im putting this in the right place, but couldnt find anywhere better.

I wish there was a way to tell vscode/omnisharp to ignore projects (.csproj) and solutions (.sln) when scanning csharp code. This would be very useful when working with very large c# codebases where the .sln and .csproj not necessarily reflect the true hierarchy of the system.

Right now, it seems to start by finding .sln files and loading corresponding projects etc. You can then switch between the solutions and the projects in that solution get loaded. At least I cant find a way of making it satisfy my wishes. :) There might be a way to do what i want today, but can't fogure out how.

So, I wish that when I open a folder, i could tell it to just find every csharp file under that folder and subfolders recursively, load it and index it etc. So that the end product is one big pile of symbols you can jump around in.

I dont care about being able to build it or anything like that, it would just be great for learning and navigating a huge code base.

br Frederic

Copied from original issue: OmniSharp/omnisharp-vscode#2344

DustinCampbell commented 6 years ago

I've moved this because I think it's more relevant to the omnisharp-roslyn repo, where the OmniSharp server is located.

If I understand your question correctly, I think you might be running into a known issue of OmniSharp. Essentially, when OmniSharp is launched with a folder path, it will do one of two things:

  1. If it finds solution files in the folder it will try to use them, picking the first one.
  2. If there are no solution files in that folder, it will crawl the directories looking for .csproj files and load all of them.

Please correct me if I'm wrong, but I think you want the behavior of the second point above, but you have solution files present, so you get the behavior of the first point. Is that right?

Fritzoid commented 6 years ago

Yes, the move is fine.

No :) I want it to scan for .cs files, or some configurable filter. No sln, no csproj. Just find all the files in the tree and index them with roslyn and store the symbols in whatever way it does, do its business to link it all together, etc.

One thing is, when the server chokes on a csproj, it stops scanning afterwards, and csprojs are notoriously fubar in big older codebases.

DustinCampbell commented 6 years ago

Got it -- thanks! This request is still more relevant with this repo.

Note that if we were to implement what you've described, it might not be as useful as you'd like. Many features would not be reliable because there would be no way to identify what references or compiler options are needed.

Fritzoid commented 6 years ago

Yes, thats true. But maybe the server could start with the cs files, so that all symbols are seen first. It could then load the sln prj files and figure it all out. Build is irrelevant or people should change their build task. It could just be empty.

DustinCampbell commented 6 years ago

@Fritzoid: I think that would be very tricky to implement, but it's not a bad idea.

Fritzoid commented 6 years ago

Yes, Its tricky. It probably changes the main loop a lot. Maybe it could be done by ensuring scanning continues between projects no matter what and loose files are picked up.

per-samuelsson commented 5 years ago

Please correct me if I'm wrong, but I think you want the behavior of the second point above, but you have solution files present, so you get the behavior of the first point. Is that right?

That is the behavior I'd really like.

Basically, I'd want to be able to say "don't mind any solution files, just use projects", getting an experience similar to how things would work if I delete any solution file.

I don't think it's very uncommon either: many repos have a solution (for those that prefer full VS) and then other devs working on the same workspace, but prefering like VS Code, and being in the later camp, I get pretty frustrated some times seeing things break because something regarding the solution.

Any chance something like that is in the pipe?

(Noticed https://github.com/OmniSharp/omnisharp-vscode/pull/2053 recently: maybe get it to support "null", to revert back to just using directory structure as a fallback).

hernot commented 5 years ago

Hm I'd also love to see a project and solution free fallback for example to some rsp alike file format for specifiying the compiler options at least a minimal set sufficient for liniting and autocompletion eg (/r /unsafe /target ) etc. Would allow to use on non omnisharp, vscode and alike projects still use liniting and autocompleteion services provided by omnisharp eg (omnisharp-vim)

For simple things the noisy sln and csproj files are way to complicated and without gui tools it is nearly not pussible to just specifiy specific assemblies (.dll) to link in instead of pulling in whole projects. and project trees. The closest are the rsp files which can be used in csx scripting mode which if usable also for non csx projects and solutions would already be a start.

fatfatson commented 5 years ago

need this +1 I'd like to switch to none-solution mode because sometimes I want to ignore some projects temporarily, if there's a solution file, all projects within it will be processed inspite of the FileOptions.userExcludeSearchPatterns setting in omnisharp.json.