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

Auto update for omnisharp.json (VSCode extension) #623

Merged
merged 6 commits into from
Dec 27, 2019

Conversation

AdrianWilczynski
Copy link
Contributor

@AdrianWilczynski AdrianWilczynski commented Dec 14, 2019

Hey, I took a stab at adding an auto-update for the omnisharp.json file to eliminate the need to set it up manually.

Let me know if it's something you're interested in and if I can fix/improve upon submitted code.

Fair warning, it's my first attempt at contributing to open source 😅

I've also realized now that this PR might be kinda off-putting because of its size but most of it is just standard extension boilerplate. The actual functionality is mostly contained in extension.ts file.

All it really does is checking (at startup) if omnisharp.json exists & contains appropriate settings and creating/updating it if needed.

PR also defines configuration setting (in VSCode) to disable this functionality (just in case).

There are two test cases (in extension.test.ts):

  • omnisharp.json doesn't exist and needs to be created,
  • omnisharp.json exists but contains outdated settings

(should fix: #615)

@josefpihrt
Copy link
Collaborator

Hi,

thanks for this contribution. It looks nice.

@josefpihrt josefpihrt merged commit eab95e6 into dotnet:2019 Dec 27, 2019
@josefpihrt
Copy link
Collaborator

@AdrianWilczynski I'm getting error when trying to pack an extension (vsce package)

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'vscode:prepublish'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v12.14.0
4 verbose run-script [
4 verbose run-script   'prevscode:prepublish',
4 verbose run-script   'vscode:prepublish',
4 verbose run-script   'postvscode:prepublish'
4 verbose run-script ]
5 info lifecycle roslynator@2.2.0~prevscode:prepublish: roslynator@2.2.0
6 info lifecycle roslynator@2.2.0~vscode:prepublish: roslynator@2.2.0
7 verbose lifecycle roslynator@2.2.0~vscode:prepublish: unsafe-perm in lifecycle true
8 verbose lifecycle roslynator@2.2.0~vscode:prepublish: PATH: ***
9 verbose lifecycle roslynator@2.2.0~vscode:prepublish: CWD: ***\Roslynator2019\src\VisualStudioCode\package
10 silly lifecycle roslynator@2.2.0~vscode:prepublish: Args: [ '/d /s /c', 'npm run compile' ]
11 silly lifecycle roslynator@2.2.0~vscode:prepublish: Returned: code: 2  signal: null
12 info lifecycle roslynator@2.2.0~vscode:prepublish: Failed to exec vscode:prepublish script
13 verbose stack Error: roslynator@2.2.0 vscode:prepublish: `npm run compile`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:210:5)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:210:5)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid roslynator@2.2.0
15 verbose cwd ***\Roslynator2019\src\VisualStudioCode\package
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "vscode:prepublish"
18 verbose node v12.14.0
19 verbose npm  v6.13.4
20 error code ELIFECYCLE
21 error errno 2
22 error roslynator@2.2.0 vscode:prepublish: `npm run compile`
22 error Exit status 2
23 error Failed at the roslynator@2.2.0 vscode:prepublish script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

Could you help me out?

@AdrianWilczynski
Copy link
Contributor Author

I think you have to run npm install in extension directory before to pull in dependencies.

@josefpihrt
Copy link
Collaborator

Thanks!

@josefpihrt
Copy link
Collaborator

I have one thing to improve. After installing an extension the omnisharp.json content is not formatted, it is on one line. Is it possible to run some formatter before saving the file?

@AdrianWilczynski
Copy link
Contributor Author

It should be formatted already because of JSON.stringify(omnisharpSettings, null, 4). I'm passing in 4 so I think it should indent everything with 4 spaces. I'm gonna check again to see what's going on.

@AdrianWilczynski
Copy link
Contributor Author

AdrianWilczynski commented Dec 28, 2019

So I think It might be because JSON.stringify seems to use Unix style end of lines regardless of platform you're on (I'm on Windows 10 and I still get LF). I can run replace and set environment specific EOLs.

Though it still looks formatted on my machine when I open omnisharp.json with Notepad, Notepad++ or VSCode so I'm not sure if that's what's going on.

@josefpihrt
Copy link
Collaborator

You're right, EOL is LF. I'm on Windows 7 and Notepad cannot handle LF as EOL.

I think we can leave it as it is for now.

@josefpihrt
Copy link
Collaborator

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants