-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #809 from filipw/features/global-omnisharp.json
Added support for a global omnisharp.json
- Loading branch information
Showing
6 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ internal static T GetValueOrDefault<T>(this CommandOption opt, T defaultValue) | |
return defaultValue; | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/OmniSharp.Host/Internal/ConfigurationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.FileProviders; | ||
using OmniSharp.Services; | ||
using System; | ||
using System.IO; | ||
|
||
namespace OmniSharp.Host.Internal | ||
{ | ||
internal static class ConfigurationBuilderExtensions | ||
{ | ||
internal static void CreateAndAddGlobalOptionsFile(this IConfigurationBuilder configBuilder, IOmniSharpEnvironment env) | ||
{ | ||
if (env?.SharedDirectoryPath == null) return; | ||
|
||
try | ||
{ | ||
if (!Directory.Exists(env.SharedDirectoryPath)) | ||
{ | ||
Directory.CreateDirectory(env.SharedDirectoryPath); | ||
} | ||
|
||
var omnisharpGlobalFilePath = Path.Combine(env.SharedDirectoryPath, Constants.OptionsFile); | ||
configBuilder.AddJsonFile( | ||
new PhysicalFileProvider(env.SharedDirectoryPath), | ||
Constants.OptionsFile, | ||
optional: true, | ||
reloadOnChange: true); | ||
} | ||
catch (Exception e) | ||
{ | ||
// at this point we have no ILogger yet | ||
Console.Error.WriteLine($"There was an error when trying to create a global '{Constants.OptionsFile}' file in '{env.SharedDirectoryPath}'. {e.ToString()}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace OmniSharp.Host.Internal | ||
{ | ||
internal static class Constants | ||
{ | ||
internal const string ConfigFile = "config.json"; | ||
internal const string OptionsFile = "omnisharp.json"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters