// Need to be able to stub this method out for testing
 protected virtual /* for testing */ void CreateChannelAndStreamLogs()
 {
     channel      = new Channel($"{DaemonHost}:{Port}", ChannelCredentials.Insecure);
     daemonClient = new StandaloneSonarLint.StandaloneSonarLintClient(channel);
     ListenForLogs();
     StartHeartBeat();
 }
Esempio n. 2
0
 private void CreateChannelAndStreamLogs()
 {
     channel      = new Channel($"{DAEMON_HOST}:{port}", ChannelCredentials.Insecure);
     daemonClient = new StandaloneSonarLint.StandaloneSonarLintClient(channel);
     ListenForLogs();
     StartHeartBeat();
 }
Esempio n. 3
0
        private async void Analyze(string path, string charset, IIssueConsumer consumer)
        {
            var request = new AnalysisReq
            {
                BaseDir = path,
                WorkDir = workingDirectory,
            };

            request.File.Add(new InputFile
            {
                Path    = path,
                Charset = charset,
            });

            var channel = new Channel($"{DAEMON_HOST}:{port}", ChannelCredentials.Insecure);
            var client  = new StandaloneSonarLint.StandaloneSonarLintClient(channel);

            using (var call = client.Analyze(request))
            {
                try
                {
                    await ProcessIssues(call, path, consumer);
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Call to client.Analyze failed: {0}", e);
                }
            }

            await channel.ShutdownAsync();
        }
 public void Stop()
 {
     if (!IsRunning)
     {
         return;
         // throw exception?
     }
     daemonClient = null;
     channel?.ShutdownAsync().Wait();
     channel = null;
     process?.Kill();
     process?.WaitForExit();
     process = null;
 }
Esempio n. 5
0
        public void Stop()
        {
            if (!IsRunning)
            {
                return;
                // throw exception?
            }

            logger.WriteLine(Strings.Daemon_Stopping);
            daemonClient = null;
            channel?.ShutdownAsync().Wait();
            channel = null;
            process?.Kill();
            process?.WaitForExit();
            process = null;
            logger.WriteLine(Strings.Daemon_Stopped);
        }
        // Need to be able to stub this method out for testing
        protected virtual void SafeInternalStop()
        {
            // Note: we're not checking IsRunning here as that check can fail if the
            // process wasn't started correctly.
            logger.WriteLine(Strings.Daemon_Stopping);

            SafeOperation(() =>
            {
                daemonClient = null;
                channel?.ShutdownAsync().Wait();
                channel = null;

                // Will throw an InvalidOperationException if the process isn't valid
                if (!process?.HasExited ?? false)
                {
                    process?.Kill();
                    process?.WaitForExit();
                }
                process = null;
            });

            logger.WriteLine(Strings.Daemon_Stopped);
        }