Ejemplo n.º 1
0
        internal static ServerData CreateServer(
            string pipeName = null,
            TimeSpan? timeout = null,
            ICompilerServerHost compilerServerHost = null)
        {
            pipeName = pipeName ?? Guid.NewGuid().ToString();
            compilerServerHost = compilerServerHost ?? new DesktopCompilerServerHost(DefaultClientDirectory, DefaultSdkDirectory);

            var taskSource = new TaskCompletionSource<ServerStats>();
            var cts = new CancellationTokenSource();
            var thread = new Thread(_ =>
            {
                var listener = new TestableDiagnosticListener();
                try
                {
                    var clientConnectionHost = new NamedPipeClientConnectionHost(compilerServerHost, pipeName);
                    var mutexName = BuildProtocolConstants.GetServerMutexName(pipeName);
                    VBCSCompiler.Run(
                        mutexName,
                        clientConnectionHost,
                        listener,
                        timeout ?? TimeSpan.FromMilliseconds(-1),
                        cts.Token);
                }
                finally
                {
                    var serverStats = new ServerStats(connections: listener.ConnectionCount, completedConnections: listener.CompletedCount);
                    taskSource.SetResult(serverStats);
                }
            });

            thread.Start();

            return new ServerData(cts, taskSource.Task, pipeName);
        }
Ejemplo n.º 2
0
 public NamedPipeClientConnectionHostTests(ITestOutputHelper testOutputHelper)
 {
     _host = new NamedPipeClientConnectionHost(
         ServerUtil.GetPipeName(),
         new XunitCompilerServerLogger(testOutputHelper)
         );
 }
Ejemplo n.º 3
0
        internal static ServerData CreateServer(
            string pipeName  = null,
            TimeSpan?timeout = null,
            ICompilerServerHost compilerServerHost = null)
        {
            pipeName           = pipeName ?? Guid.NewGuid().ToString();
            compilerServerHost = compilerServerHost ?? new DesktopCompilerServerHost(DefaultClientDirectory, DefaultSdkDirectory);

            var taskSource = new TaskCompletionSource <ServerStats>();
            var cts        = new CancellationTokenSource();
            var thread     = new Thread(_ =>
            {
                var listener = new TestableDiagnosticListener();
                try
                {
                    var clientConnectionHost = new NamedPipeClientConnectionHost(compilerServerHost, pipeName);
                    var mutexName            = BuildProtocolConstants.GetServerMutexName(pipeName);
                    VBCSCompiler.Run(
                        mutexName,
                        clientConnectionHost,
                        listener,
                        timeout ?? TimeSpan.FromMilliseconds(-1),
                        cts.Token);
                }
                finally
                {
                    var serverStats = new ServerStats(connections: listener.ConnectionCount, completedConnections: listener.CompletedCount);
                    taskSource.SetResult(serverStats);
                }
            });

            thread.Start();

            return(new ServerData(cts, taskSource.Task, pipeName));
        }
Ejemplo n.º 4
0
            private Task CreateServerCore(string pipeName)
            {
                Action action = () =>
                {
                    var compilerServerHost = new DesktopCompilerServerHost(ClientDirectory, SdkDirectory);
                    var clientConnectionHost = new NamedPipeClientConnectionHost(compilerServerHost, pipeName);
                    var mutexName = $"{pipeName}.server";
                    VBCSCompiler.Run(mutexName, clientConnectionHost, TimeSpan.FromSeconds(3));
                };

                var task = new Task(action, TaskCreationOptions.LongRunning);
                task.Start(TaskScheduler.Default);
                return task;
            }
Ejemplo n.º 5
0
            private Task CreateServerCore(string pipeName)
            {
                Action action = () =>
                {
                    var compilerServerHost   = new DesktopCompilerServerHost(ClientDirectory, SdkDirectory);
                    var clientConnectionHost = new NamedPipeClientConnectionHost(compilerServerHost, pipeName);
                    var mutexName            = $"{pipeName}.server";
                    VBCSCompiler.Run(mutexName, clientConnectionHost, TimeSpan.FromSeconds(3));
                };

                var task = new Task(action, TaskCreationOptions.LongRunning);

                task.Start(TaskScheduler.Default);
                return(task);
            }
 public NamedPipeClientConnectionHostTests()
 {
     _host = new NamedPipeClientConnectionHost(ServerUtil.GetPipeName());
 }