From c8c50492bff502bfd62f2bfe7b12e7e4bcead4dd Mon Sep 17 00:00:00 2001 From: Gabe Stocco <98900+gfs@users.noreply.github.com> Date: Mon, 27 Mar 2023 12:19:21 -0700 Subject: [PATCH] Tidy main, add comment for the configuration section --- .../Program.cs | 48 +++++-------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/DevSkim-DotNet/Microsoft.DevSkim.LanguageServer/Program.cs b/DevSkim-DotNet/Microsoft.DevSkim.LanguageServer/Program.cs index f2a57cc..620f4f3 100644 --- a/DevSkim-DotNet/Microsoft.DevSkim.LanguageServer/Program.cs +++ b/DevSkim-DotNet/Microsoft.DevSkim.LanguageServer/Program.cs @@ -1,14 +1,9 @@ using CommandLine; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Extensions.LanguageServer.Server; using Serilog; -using System.Diagnostics; -using System.IO.Pipes; -using YamlDotNet.Core; namespace DevSkim.LanguageServer; @@ -19,30 +14,10 @@ internal class Program MainAsync(args).Wait(); } - private static (Stream, Stream) GetStreams(bool usePipes) - { - if (usePipes) - { - var stdInPipeName = @"devskim-language-server-input"; - var stdOutPipeName = @"devskim-language-server-output"; - var readerPipe = new NamedPipeClientStream(".", stdInPipeName, PipeDirection.InOut, PipeOptions.Asynchronous); - var writerPipe = new NamedPipeClientStream(".", stdOutPipeName, PipeDirection.InOut, PipeOptions.Asynchronous); - return (readerPipe, writerPipe); - } - else - { - return (Console.OpenStandardInput(), Console.OpenStandardOutput()); - } - } - public class Options - { - [Option('p', "use pipes", Required = false, HelpText = "If set, will use pipes, if not set will use stdin/stdout.")] - public bool UsePipes { get; set; } + { } - - - private static async Task MainAsync(string[] args) + private static async Task MainAsync(string[] args) { #if DEBUG // Debugger.Launch(); @@ -66,7 +41,7 @@ internal class Program { _opts = o; }); - (Stream input, Stream output) = GetStreams(_opts.UsePipes); + (Stream input, Stream output) = (Console.OpenStandardInput(), Console.OpenStandardOutput()); Log.Logger.Debug("Configuring server..."); IObserver workDone = null!; @@ -119,13 +94,16 @@ internal class Program new WorkDoneProgressBegin { Title = "Beginning server routines..." }).ConfigureAwait(false); - IConfiguration configuration = await languageServer.Configuration.GetConfiguration( - new ConfigurationItem - { - Section = ConfigHelpers.Section - } - ).ConfigureAwait(false); - ConfigHelpers.SetScannerSettings(configuration); + // This calls "workspace/configuration" over jsonrpc to the language client + // The Visual Studio client doesn't understand this, so temporarily commented out until it can listen and respond with the right configuration + + //IConfiguration configuration = await languageServer.Configuration.GetConfiguration( + // new ConfigurationItem + // { + // Section = ConfigHelpers.Section + // } + //).ConfigureAwait(false); + //ConfigHelpers.SetScannerSettings(configuration); Log.Logger.Debug("Listening for client events..."); } )