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); }
public NamedPipeClientConnectionHostTests(ITestOutputHelper testOutputHelper) { _host = new NamedPipeClientConnectionHost( ServerUtil.GetPipeName(), new XunitCompilerServerLogger(testOutputHelper) ); }
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)); }
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; }
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()); }