Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple omnisharp.json settings for one project #1208

Closed
filipw opened this issue May 31, 2018 · 7 comments
Closed

Multiple omnisharp.json settings for one project #1208

filipw opened this issue May 31, 2018 · 7 comments

Comments

@filipw
Copy link
Member

filipw commented May 31, 2018

From @ypapouin on May 31, 2018 11:20

Currently, you can override FormattingOptions by placing an omnisharp.json file at the project root folder.

In my projects, I'm using a lot of sub-modules (git) developed by third parties with different C# settings, but all changes made (for merge request to upstream) in these sub-modules must be formatted by hand to avoid losing original formatting.

I would be happy to be able to customize FormattingOptions for each of these sub-modules.

For each folder containing an omnisharp.json, all sub-folder would recursively apply these settings until a new omnisharp.json is found.

Environment data

dotnet --info output:
Outils en ligne de commande .NET (2.1.104)

Product Information:
Version: 2.1.104
Commit SHA-1 hash: 48ec687460

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.104\

Microsoft .NET Core Shared Framework Host

Version : 2.0.6
Build : 74b1c703813c8910df5b96f304b0f2b78cdf194d

VS Code version: 1.23.1
C# Extension version: 1.15.2

Copied from original issue: dotnet/vscode-csharp#2357

@filipw
Copy link
Member Author

filipw commented May 31, 2018

@ypapouin thanks for a feature request.

could you provide a bit more background on what you are trying to do? you have a single solution, where you load multiple projects, but would like to effectively have per-project settings based on the paths, am I understanding you correctly?

Because you can already have multiple omnisharp.json files on different levels, what matters is the startup folder though - OmniSharp will select the one in the current startup directory.

@ypapouin
Copy link

Thanks for moving issue to the right project.

Actually I have a single solution with a single project, but my project is versioned using git and some third-party libraries (as source code) that are set in their own sub-folder.

All these libraries sub-folders are git sub-modules since they are maintained for multiple project. But their maintainer have different formatting options:

MyProject:
├───.git
├───lib
│   ├───display
│   │   ├───.git
│   │   └───code.cs
│   ├───input
│   │   ├───.git
│   │   └───code.cs
│   └───network
│       ├───.git
│       └───code.cs
├───src
│    └───main.cs
├───omnisharp.json
├───project.csproj
└───project_solution.sln
LibMaintainerProject:
├───.git
├───lib
│   ├───display
│   │   ├───.git
│   │   └───code.cs
│   ├───input
│   │   ├───.git
│   │   └───code.cs
│   └───network
│       ├───.git
│       └───code.cs
├───omnisharp.json
├───src
│    └───test_display.cs
│    └───test_input.cs
│    └───test_network.cs
├───omnisharp.json
├───project_lib.csproj
└───project_lib_solution.sln

Would be nice to be able to have:

MyProject:
├───.git
├───lib
│   ├───display
│   │   ├───.git
│   │   ├───code.cs
│   │   └───omnisharp.json
│   ├───input
│   │   ├───.git
│   │   ├───code.cs
│   │   └───omnisharp.json
│   └───network
│       ├───.git
│   │   ├───code.cs
│   │   └───omnisharp.json
├───src
│    └───main.cs
├───omnisharp.json
├───project.csproj
└───project_solution.sln

or:

MyProject:
├───.git
├───lib
│   ├───display
│   │   ├───.git
│   │   └───code.cs
│   ├───input
│   │   ├───.git
│   │   └───code.cs
│   └───network
│   │   ├───.git
│   │   └───code.cs
│   └───omnisharp.json
├───src
│    └───main.cs
├───omnisharp.json
├───project.csproj
└───project_solution.sln

@DustinCampbell
Copy link
Contributor

Wouldn't this be better solved by supporting .editorconfig files?

@Siccity
Copy link

Siccity commented Feb 21, 2020

+1

@haacked
Copy link

haacked commented Aug 26, 2021

could you provide a bit more background on what you are trying to do? you have a single solution, where you load multiple projects, but would like to effectively have per-project settings based on the paths, am I understanding you correctly?

That's pretty much what I'm looking for. We're trying to support a nice editing experience for Abbot (see Background section here for more context). I want to have different references (rsp) for different folders.

In Abbot, a project might have multiple "skill" folders. Each skill is a script (.csx) file and a set of references defined in a .rsp file. Here's a typical layout.

Skills
├───skill-one
│   ├───omnisharp.json
│   ├───references.rsp
│   ├───main.csx
├───skill-two
│   ├───omnisharp.json
│   ├───references.rsp
│   ├───main.csx
...

The omnisharp file looks like:

    "script": {
        "enabled": true,
        "defaultTargetFramework": "net5.0",
        "enableScriptNuGetReferences": true,
        "RspFilePath": "references.rsp"
    }
}

But each skill may have a different set of usings and references, hence each one gets its own rsp file. What I would hope to happen is when editing /skill-one/main.csx the omnisharp.json file for that directory would be in play. When editing /skill-two/main.csx, the omnisharp.json file for that directory would be in play.

And if someone opens VS Code pointing to a skill folder, I want it all to continue to work. Does that make sense?

@filipw
Copy link
Member Author

filipw commented Aug 27, 2021

I do not think this is relevant anymore in the original form. The original formatting problem from this issue was already resolved by implementing the full support for editorconfig and its hierarchical structure.

The use case that you describe is one that I think is a reasonable one, but it's also a very specific example in one very concrete part of the config. However, at the moment omnisharp.json is primarily global/singleton options relevant mostly for server startup and its bootstrapping, so by its nature it's really not suitable for hierarchical structure.

@filipw
Copy link
Member Author

filipw commented Dec 7, 2021

We have decided to not implement this in favor of .editorconfig which can already be used to achieve everything described here

@filipw filipw closed this as completed Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants