-
Notifications
You must be signed in to change notification settings - Fork 676
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
Add support for configuring default startup *.sln in settings.json #2053
Conversation
… there are multiple
- tweak bin and obj exlusion - refactor lauch config
Thanks @janaka! @rchande will you have cycles to review? @DustinCampbell can you look at test/integrationTests/testAssets/slnWithCsproj/.vscode/settings.json? what are your thoughts on the settings file addition? |
package.json
Outdated
}, | ||
"linux": { | ||
"program": "./.debugger/vsdbg-ui" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure that you don't want these changes in your PR. Is that correct @gregg-miskelly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how/why those got in there tbh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can happen when debugging the extension.
package.json
Outdated
"program": "./.debugger/vsdbg-ui" | ||
}, | ||
"linux": { | ||
"program": "./.debugger/vsdbg-ui" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure that you don't want these changes in your PR. Is that correct @gregg-miskelly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janaka: You need to revert this bit.
package.json
Outdated
"omnisharp.defaultLaunchSolution": { | ||
"type": "string", | ||
"default": null, | ||
"description": "The name of the default solution used at start up if the repo has multiple. e.g.'MyAwesomeSolution.sln'. Default value is `null` which will cause the first in alphabetical order to be chosen" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This should have a period at the end.
src/omnisharp/server.ts
Outdated
const defaultLaunchSolution = launchTargets.filter((a) => (a.isDefault === true)); | ||
// If there's more than one target, launch the server with the launch target that | ||
// matches the default solution (if it's configured). | ||
// The user can still manually switch to another solution from the 'Omnisharp: Select Project command' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it still remember the last selected project on the next start up (i.e. the preferredPath
). Or, does setting this option effectively override it? I would expect defaultLaunchSolution
to be used in the case where there isn't a preferredPath
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ifomnisharp.defaultLaunchSolution
is set (to a valid existing solution), it will be used at start up. That's the intended behaviour. If it's not set then the last selected should be remembered and used at start up per the original logic.
.vscode/launch.json
Outdated
], | ||
"stopOnEntry": false, | ||
"sourceMaps": true, | ||
"outFiles": [ | ||
"${workspaceRoot}/out/test/**/*.js" | ||
"${workspaceFolder}/out/test/**/*.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{workspaceFolder} [](start = 18, length = 17)
Can you explain this? It looks like VSCode deprecated workspaceroot for workspacefolder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. workspaceRoot
was deprecated when multi-root workspaces were added to VS Code.
"args": ["Run tests in VS Code by launching the debugger with the 'Launch Tests' configuration."], | ||
"args": [ | ||
"Run tests in VS Code by launching the debugger with the 'Launch Tests' configuration." | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're making whitespace-only changes, can we tab->space ?
package.json
Outdated
"omnisharp.defaultLaunchSolution": { | ||
"type": "string", | ||
"default": null, | ||
"description": "The name of the default solution used at start up if the repo has multiple. e.g.'MyAwesomeSolution.sln'. Default value is `null` which will cause the first in alphabetical order to be chosen" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"multiple solutions"
src/omnisharp/launcher.ts
Outdated
return targets.sort((a, b) => a.directory.localeCompare(b.directory)); | ||
let rtnTargets: LaunchTarget[]; | ||
|
||
const options = Options.Read(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onst options = Options.Read( [](start = 5, length = 28)
Why not read the options at the beginning of this method and check each solution file's name as we add them to targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely checking targets that aren't solutions...
In reply to: 171064995 [](ancestors = 171064995)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, originally I generalised the config key for any target then realised it didn't make sense in most/all other context so switched it to be solution specific.
Your suggestion makes sense. Should be able to remove the isDefault
property as per your suggestion below. Good call.
src/omnisharp/server.ts
Outdated
// matches the preferred path. Otherwise, we fire the "MultipleLaunchTargets" event, | ||
// which is handled in status.ts to display the launch target selector. | ||
if (launchTargets.length > 1 && preferredPath) { | ||
const defaultLaunchSolution = launchTargets.filter((a) => (a.isDefault === true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const defaultLaunchSolution = launchTargets.filter((a) => (a.isDefault === true)); [](start = 11, length = 83)
I wonder if we can avoid spreading the default launch target selection through 2 different components.
If we're going to scan this list for the "Default" one anyway, why not just read the option here too?
{717BE881-D74C-45FC-B55D-2085499E1BF8}.Release|x86.ActiveCfg = Release|x86 | ||
{717BE881-D74C-45FC-B55D-2085499E1BF8}.Release|x86.Build.0 = Release|x86 | ||
{4679428B-0CA0-4228-B8C0-B676B34A1B30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4679428B-0CA0-4228-B8C0-B676B34A1B30}.Debug|Any CPU.Build.0 = Debug|Any CPU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to add this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Can we give this a more informative name?
In reply to: 171066267 [](ancestors = 171066267)
"name": ".NET Core Attach", | ||
"type": "coreclr", | ||
"request": "attach", | ||
"processId": "${command:pickProcess}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to check these in--we have a test that tests generation of these files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I added some feedback for you.
@rchande much appreciated. |
@@ -1314,13 +1319,13 @@ | |||
"type": "coreclr", | |||
"request": "launch", | |||
"preLaunchTask": "build", | |||
"program": "^\"\\${workspaceRoot}/bin/Debug/${1:<target-framework>}/${2:<project-name.dll>}\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this part of launch.json is generated from src/tools/OptionsSchema.json. Can you fix it there too? Otherwise this will be lost the next time we run the generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is fixed now in the latest master.
I've been away for the last 4 weeks. Will start working on these this week. |
Cool, taking a look. Thanks |
Cleanup/simplify
Nice. Merged in ^. I've tried running integration and feature tests on master and they fail same/similarly. It looks like tests that involve executing VS Code complex commands are the ones having issues so like with errors like this (just a snippet)
|
@janaka That error means that when the test tried to get signature help, it didn't get a result back. Usually this indicates a problem with OmniSharp loading your project. If you run the integration tests and show the output window in the VS Code test host, what's the C#/o# log? Interestingly, our travis run is showing your PR as green, so this might be a configuration issue on your machine (I also have green tests with your changes). |
@@ -1,9 +1,4 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
|
|||
<ItemGroup> | |||
<ProjectReference Include="..\lib\lib.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly don't remember exactly why or if I even directly removed this, likely I did. I'll revert.
@@ -7,8 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D28FC441-C95 | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "app", "src\app\app.csproj", "{D36E1CC9-62CA-45A3-8BD0-6ADC2767FFB3}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lib", "src\lib\lib.csproj", "{717BE881-D74C-45FC-B55D-2085499E1BF8}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
@rchande once I've addressed those ^ and merged latest master in, what else do you need to to get this PR merged into master? Maybe best to improve test automation on a different PR? |
@janaka Yes, fix up those last couple of things and I'll get this merged for you. Thanks for your contribution! |
Nice! I'm away from this evening for a week. Will get this done next weekend. |
@rchande I've merged in upstream master and fixed the lib project ref in both sln files and the app.csproj. I've looked through the remaining changes since the merge and don't think I've broken anything new. sorry it's a few days later than promised. |
@janaka No problem. Thanks for your contribution, and sorry it took us so long to get this merged. This LGTM-- @akshita31 want to take a look too? |
@@ -0,0 +1,2 @@ | |||
**/obj/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ignores the obj directory for integrationtests, which I think is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Just merged master. Will merge once travis approves :)
Under 1.16 > project system? |
@janaka Yup, that would be good. |
Fix: broken link formatting
Done. |
Thanks! |
This PR is a proposed solution for allowing the default startup
*.sln
file to be configured insettings.json
(issue #2052).Thanks in advance for considering this PR.
Current Behaviour
At present, if a workspace has multiple
*.sln
files, the first one in alphabetical order is selected at startup. If this solution file isn't for the primary project then it get's very confusing when intelli-sense doesn't work. There's no reminder or otherwise intuitive path paved for the user prompting them to switch solutions by clicking on the right of the status bar (orOmniSharp: Select Project
from the command palette). Further switch option only seems to be available when on a file belonging to .NET code which may be inside a/src
or similar.Proposed Solution
The proposed solution adds the config option
omnisharp.defaultLaunchSolution
allowing users to optionally set the desired default solution file. It can even be checked in as a workspace setting in.vscode/settings.json
allows it to be fixed for everybody.Note that today when a solution is selected using the
OmniSharp: Select Project
command is persisted in local storage within the user profile on their machine. Ifomnisharp.defaultLaunchSolution
has a value it will be used instead on startup.Testing