Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            CheckDebugMode();
            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                var messageFormatter = new JsonMessageFormatter();
                // StreamJsonRpc v1.4 serializer defaults
                messageFormatter.JsonSerializer.NullValueHandling   = NullValueHandling.Ignore;
                messageFormatter.JsonSerializer.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
                messageFormatter.JsonSerializer.Converters.Add(new UriConverter());

                using (var cin = Console.OpenStandardInput())
                    using (var cout = Console.OpenStandardOutput())
                        using (var server = new Implementation.LanguageServer())
                            using (var rpc = new LanguageServerJsonRpc(cout, cin, messageFormatter, server)) {
                                rpc.TraceSource.Switch.Level = SourceLevels.Error;
                                rpc.SynchronizationContext   = new SingleThreadSynchronizationContext();

                                services.AddService(new UIService(rpc));
                                services.AddService(new ProgressService(rpc));
                                services.AddService(new TelemetryService(rpc));
                                services.AddService(messageFormatter.JsonSerializer);

                                var token = server.Start(services, rpc);
                                rpc.StartListening();

                                // Wait for the "exit" request, it will terminate the process.
                                token.WaitHandle.WaitOne();
                            }
            }
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            var debugMode = CheckDebugMode(args);

            using (CoreShell.Create()) {
                var connection = new VsCodeConnection(CoreShell.Current.ServiceManager);
                connection.Connect(debugMode);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.CancelKeyPress += Console_CancelKeyPress;

            var programName = "Microsoft.R.Host.Client.Program";

            using (var shell = new CoreShell(programName)) {
                var localConnector = new LocalBrokerClient(programName, BrokerConnectionInfo.Create(null, "local", args[0], null, false), shell.Services, new NullConsole());
                var host           = localConnector.ConnectAsync(new HostConnectionInfo(programName, new Program())).GetAwaiter().GetResult();
                _evaluator = host;
                host.Run().GetAwaiter().GetResult();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates R session
        /// </summary>
        /// <param name="name">Session name</param>
        /// <param name="url">Path to local R interpreter (folder with R.dll) or URL to the remote machine</param>
        /// <returns>R session</returns>
        public static IRHostSession Create(string name)
        {
            var e = new WindowsRInstallation().GetCompatibleEngines().FirstOrDefault();

            if (e == null)
            {
                throw new InvalidOperationException("No R engines installed");
            }

            var ci = BrokerConnectionInfo.Create(e.Name, e.InstallPath, e.Architecture, string.Empty);
            var bc = new LocalBrokerClient(name, ci, CoreShell.Create());

            return(new RHostSession(new RSession(0, name, bc, new NullLock(), () => { })));
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            CheckDebugMode();
            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                using (var cin = Console.OpenStandardInput())
                    using (var cout = Console.OpenStandardOutput())
                        using (var server = new LanguageServer())
                            using (var rpc = JsonRpc.Attach(cout, cin, server)) {
                                services.AddService(new UIService(rpc));
                                services.AddService(new TelemetryService(rpc));
                                var token = server.Start(services, rpc);
                                // Wait for the "shutdown" request.
                                token.WaitHandle.WaitOne();
                            }
            }
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
#if WAIT_FOR_DEBUGGER
            while (!System.Diagnostics.Debugger.IsAttached)
            {
                System.Threading.Thread.Sleep(1000);
            }
#endif
            var messageFormatter = new JsonMessageFormatter();
            // StreamJsonRpc v1.4 serializer defaults
            messageFormatter.JsonSerializer.NullValueHandling   = NullValueHandling.Ignore;
            messageFormatter.JsonSerializer.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
            messageFormatter.JsonSerializer.Converters.Add(new UriConverter());

            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                using (var cin = Console.OpenStandardInput())
                    using (var bcin = new BufferedStream(cin))
                        using (var cout = Console.OpenStandardOutput())
                            using (var server = new LanguageServer(services))
                                using (var rpc = new JsonRpc(cout, cin, server)) {
                                    rpc.SynchronizationContext = new SingleThreadSynchronizationContext();

                                    services
                                    .AddService(new UIService(rpc))
                                    .AddService(new Client(rpc))
                                    .AddService(new TelemetryService())
                                    .AddService(messageFormatter.JsonSerializer);

                                    var cts = new CancellationTokenSource();
                                    using (new RConnection(services, cts.Token)) {
                                        var token = server.Start();
                                        rpc.StartListening();
                                        // Wait for the "stop" request.
                                        token.WaitHandle.WaitOne();
                                        cts.Cancel();
                                    }
                                }
            }
        }
Exemplo n.º 7
0
        public static void Main(string[] args)
        {
            CheckDebugMode();
            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                using (var cin = Console.OpenStandardInput())
                    using (var cout = Console.OpenStandardOutput())
                        using (var server = new LanguageServer())
                            using (var rpc = new JsonRpc(cout, cin, server)) {
                                var ui = new UIService(rpc);
                                rpc.SynchronizationContext = new SingleThreadSynchronizationContext(ui);

                                services.AddService(ui);
                                services.AddService(new TelemetryService(rpc));
                                var token = server.Start(services, rpc);
                                rpc.StartListening();

                                // Wait for the "shutdown" request.
                                token.WaitHandle.WaitOne();
                            }
            }
        }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            CheckDebugMode();
            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                using (var cin = Console.OpenStandardInput())
                    using (var cout = Console.OpenStandardOutput())
                        using (var server = new Implementation.LanguageServer())
                            using (var rpc = new JsonRpc(cout, cin, server)) {
                                rpc.SynchronizationContext = new SingleThreadSynchronizationContext();
                                rpc.JsonSerializer.Converters.Add(new UriConverter());

                                services.AddService(new UIService(rpc));
                                services.AddService(new ProgressService(rpc));
                                services.AddService(new TelemetryService(rpc));
                                var token = server.Start(services, rpc);
                                rpc.StartListening();

                                // Wait for the "exit" request, it will terminate the process.
                                token.WaitHandle.WaitOne();
                            }
            }
        }
Exemplo n.º 9
0
        static /* void */ async Task Main(string[] args)
        {
#if false
            Implementation.Server s = new Implementation.Server();
            // Console.WriteLine($"An analyzer for language {s.pa.PythonAnalysisSource}.");

            // Read JSON directly from a file
            JObject data         = JObject.Parse(File.ReadAllText(Path.Combine("..", "data.json")));
            JToken  processId    = (JToken)data.SelectToken("processId");
            JToken  capabilities = (JToken)data.SelectToken("capabilities");

            Console.WriteLine($"testing: {processId}, [{processId.GetType()}]");
            Console.WriteLine($"testing: {capabilities}, [{capabilities.GetType()}]");
            Test(processId);
            Test(capabilities);
#else
#if false
            using (CoreShell.Create()) {
                var services         = CoreShell.Current.ServiceManager;
                var messageFormatter = new JsonMessageFormatter();
                messageFormatter.JsonSerializer.NullValueHandling   = NullValueHandling.Ignore;
                messageFormatter.JsonSerializer.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
                messageFormatter.JsonSerializer.Converters.Add(new UriConverter());
            }
#endif
#endif
            IConfigurationRoot config = new ConfigurationBuilder()
                                        .AddJsonFile("config.json")         // the order the providers are added to the builder denotes priority of the config key-values (later takes precedence)
                                        .AddCommandLine(args)
                                        .Build();

            Console.WriteLine($"Should be setting backend to {config["preferredBackend"]}");

            Console.WriteLine("Done!");
            Environment.Exit(0);
        }
Exemplo n.º 10
0
        public static void Main(string[] args)
        {
#if WAIT_FOR_DEBUGGER
            while (!System.Diagnostics.Debugger.IsAttached)
            {
                System.Threading.Thread.Sleep(1000);
            }
#endif
            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                using (var cin = Console.OpenStandardInput())
                    using (var bcin = new BufferedStream(cin))
                        using (var cout = Console.OpenStandardOutput())
                            using (var server = new LanguageServer(services))
                                using (var rpc = new JsonRpc(cout, cin, server)) {
                                    services.AddService(new UIService(rpc));

                                    var token = server.Start();
                                    rpc.StartListening();
                                    token.WaitHandle.WaitOne();
                                }
            }
        }