roslynator
roslynator copied to clipboard
Updating omnisharp.json doesn't respect %OMNISHARPHOME%
Product and Version Used:
v3.0.0 from Visual Studio Marketplace
Steps to Reproduce:
Install Roslynator and use Visual Studio Code with environment variable %OMNISHARPHOME%
set to any location besides ~/
Actual Behavior:
Extension updates ~/.omnisharp/omnisharp.json
Expected Behavior:
Extension updates %OMNISHARPHOME%/.omnisharp/omnisharp.json
Omnisharp added this option back in https://github.com/OmniSharp/omnisharp-roslyn/pull/1317
I noticed it because I use a portable install of VSCode on a flash drive and have my data folder on the flash drive. Roslynator has been creating a .omnisharp/omnisharp.json
file in my local computer account folder on every launch. I've already put the appropriate settings in my actual omnisharp.json
file
I've done some research on this but I don't know enough about Node/TypeScript to submit a PR to fix it. It looks like omnisharp is currently using this C# code to determine the directory. It reads, in order, the environment variables OMNISHARPHOME
, USERPROFILE
, and HOME
, and takes the first defined value.
var root = Environment.GetEnvironmentVariable("OMNISHARPHOME") ??
Environment.GetEnvironmentVariable("USERPROFILE") ??
Environment.GetEnvironmentVariable("HOME");
Then in https://github.com/JosefPihrt/Roslynator/blob/master/src/VisualStudioCode/package/src/extension.ts in function activate
, ensureOmnisharpConfigurationUpdated
is called with a context object that assigns the root directory.
https://github.com/JosefPihrt/Roslynator/blob/b9152dd6c652e4cd4e50630b7d7f6ea663d241c0/src/VisualStudioCode/package/src/extension.ts#L14
I believe this line, along with any related tests is what would need to change.
Hi. I'm not sure how portable install works, but you might be able to set roslynator.autoUpdateOmnisharpJson
to false
through VSCode settings to stop omnisharp.json
from getting created.