提交 9fa1f3c1 编写于 作者: J Jared Parsons

Move around the SDK directory dependency

It's no longer needed on the ICompilerServerHost implementation.  It is
just threaded through the compiler server creation like the other
directory parameters.
上级 c4a7c8de
......@@ -41,11 +41,6 @@ public async Task<IClientConnection> CreateListenTask(CancellationToken cancella
return new TcpClientConnection(tcpClient);
}
public string GetSdkDirectory()
{
return null;
}
public void Log(string message)
{
// BTODO: Do we need this anymore?
......
......@@ -14,7 +14,7 @@ public static void Main(string[] args)
var endPoint = new IPEndPoint(ipAddress, port: 12000);
var clientDirectory = AppContext.BaseDirectory;
var compilerHost = new CoreClrCompilerServerHost(endPoint);
var compilerRequestHandler = new CompilerRequestHandler(compilerHost, clientDirectory);
var compilerRequestHandler = new CompilerRequestHandler(compilerHost, clientDirectory, sdkDirectory: null);
var serverDispatcher = new ServerDispatcher(compilerHost, compilerRequestHandler, new EmptyDiagnosticListener());
serverDispatcher.ListenAndDispatchConnections(keepAlive: null, cancellationToken: CancellationToken.None);
}
......
......@@ -42,10 +42,16 @@ internal sealed class CompilerRequestHandler : IRequestHandler
/// </summary>
private readonly string _clientDirectory;
internal CompilerRequestHandler(ICompilerServerHost compilerServerHost, string clientDirectory)
/// <summary>
/// Directory holding mscorlib. It will be null when run under CoreCLR,
/// </summary>
private readonly string _sdkDirectory;
internal CompilerRequestHandler(ICompilerServerHost compilerServerHost, string clientDirectory, string sdkDirectory)
{
_compilerServerHost = compilerServerHost;
_clientDirectory = clientDirectory;
_sdkDirectory = sdkDirectory;
}
/// <summary>
......@@ -106,7 +112,7 @@ private CommonCompiler CreateCSharpCompiler(RunRequest request)
request.Arguments,
_clientDirectory,
request.CurrentDirectory,
_compilerServerHost.GetSdkDirectory(),
_sdkDirectory,
request.LibDirectory,
_compilerServerHost.AnalyzerAssemblyLoader);
}
......@@ -118,7 +124,7 @@ private CommonCompiler CreateBasicCompiler(RunRequest request)
request.Arguments,
_clientDirectory,
request.CurrentDirectory,
_compilerServerHost.GetSdkDirectory(),
_sdkDirectory,
request.LibDirectory,
_compilerServerHost.AnalyzerAssemblyLoader);
}
......
......@@ -16,7 +16,6 @@ internal interface ICompilerServerHost
Func<string, MetadataReferenceProperties, PortableExecutableReference> AssemblyReferenceProvider { get; }
Task<IClientConnection> CreateListenTask(CancellationToken cancellationToken);
string GetSdkDirectory();
bool CheckAnalyzers(string baseDirectory, ImmutableArray<CommandLineAnalyzerReference> analyzers);
void Log(string message);
}
......
......@@ -42,11 +42,6 @@ public bool CheckAnalyzers(string baseDirectory, ImmutableArray<CommandLineAnaly
return AnalyzerConsistencyChecker.Check(baseDirectory, analyzers, s_analyzerLoader);
}
public string GetSdkDirectory()
{
return RuntimeEnvironment.GetRuntimeDirectory();
}
public void Log(string message)
{
CompilerServerLogger.Log(message);
......
......@@ -13,6 +13,7 @@
using System.Threading.Tasks;
using System.Globalization;
using Microsoft.CodeAnalysis.CommandLine;
using System.Runtime.InteropServices;
namespace Microsoft.CodeAnalysis.CompilerServer
{
......@@ -100,10 +101,11 @@ private static int Run(TimeSpan? keepAliveTimeout, string compilerExeDirectory,
CompilerServerLogger.Log("Keep alive timeout is: {0} milliseconds.", keepAliveTimeout?.TotalMilliseconds ?? 0);
FatalError.Handler = FailFast.OnFatalException;
var sdkDirectory = RuntimeEnvironment.GetRuntimeDirectory();
var compilerServerHost = new DesktopCompilerServerHost(pipeName);
var dispatcher = new ServerDispatcher(
compilerServerHost,
new CompilerRequestHandler(compilerServerHost, compilerExeDirectory),
new CompilerRequestHandler(compilerServerHost, compilerExeDirectory, sdkDirectory),
new EmptyDiagnosticListener());
dispatcher.ListenAndDispatchConnections(keepAliveTimeout);
......
......@@ -10,6 +10,7 @@
using Moq;
using Roslyn.Test.Utilities;
using Xunit;
using System.Runtime.InteropServices;
namespace Microsoft.CodeAnalysis.CompilerServer.UnitTests
{
......@@ -316,7 +317,7 @@ public async Task KeepAliveAfterMultipleConnection()
{
var dispatcher = new ServerDispatcher(
CreateNopCompilerServerHost().Object,
new CompilerRequestHandler(CreateNopCompilerServerHost().Object, Temp.CreateDirectory().Path),
new CompilerRequestHandler(CreateNopCompilerServerHost().Object, Temp.CreateDirectory().Path, RuntimeEnvironment.GetRuntimeDirectory()),
listener);
dispatcher.ListenAndDispatchConnections(keepAlive);
});
......@@ -345,7 +346,7 @@ public async Task KeepAliveAfterSimultaneousConnection()
{
var dispatcher = new ServerDispatcher(
CreateNopCompilerServerHost().Object,
new CompilerRequestHandler(CreateNopCompilerServerHost().Object, Temp.CreateDirectory().Path),
new CompilerRequestHandler(CreateNopCompilerServerHost().Object, Temp.CreateDirectory().Path, RuntimeEnvironment.GetRuntimeDirectory()),
listener);
dispatcher.ListenAndDispatchConnections(keepAlive);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册