Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
7c75ef98
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7c75ef98
编写于
11月 10, 2015
作者:
J
Jared Parsons
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed the remaining TODOS
上级
bb151916
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
61 addition
and
23 deletion
+61
-23
src/Compilers/Server/PortableServer/CoreClrCompilerServerHost.cs
...pilers/Server/PortableServer/CoreClrCompilerServerHost.cs
+0
-5
src/Compilers/Server/ServerShared/CompilerRequestHandler.cs
src/Compilers/Server/ServerShared/CompilerRequestHandler.cs
+0
-2
src/Compilers/Server/ServerShared/Connection.cs
src/Compilers/Server/ServerShared/Connection.cs
+6
-7
src/Compilers/Server/ServerShared/DiagnosticListener.cs
src/Compilers/Server/ServerShared/DiagnosticListener.cs
+10
-0
src/Compilers/Server/ServerShared/ICompilerServerHost.cs
src/Compilers/Server/ServerShared/ICompilerServerHost.cs
+0
-2
src/Compilers/Server/ServerShared/ServerDispatcher.cs
src/Compilers/Server/ServerShared/ServerDispatcher.cs
+1
-0
src/Compilers/Server/VBCSCompiler/DesktopCompilerServerHost.cs
...ompilers/Server/VBCSCompiler/DesktopCompilerServerHost.cs
+0
-6
src/Compilers/Server/VBCSCompilerTests/CompilerServerApiTest.cs
...mpilers/Server/VBCSCompilerTests/CompilerServerApiTest.cs
+42
-0
src/Compilers/Shared/CoreClrBuildClient.cs
src/Compilers/Shared/CoreClrBuildClient.cs
+2
-1
未找到文件。
src/Compilers/Server/PortableServer/CoreClrCompilerServerHost.cs
浏览文件 @
7c75ef98
...
...
@@ -33,10 +33,5 @@ public override bool CheckAnalyzers(string baseDirectory, ImmutableArray<Command
// Analyzers not supported in the portable server yet.
return
analyzers
.
Length
==
0
;
}
public
override
void
Log
(
string
message
)
{
// BTODO: Do we need this anymore?
}
}
}
src/Compilers/Server/ServerShared/CompilerRequestHandler.cs
浏览文件 @
7c75ef98
...
...
@@ -53,8 +53,6 @@ protected CompilerServerHost(string clientDirectory, string sdkDirectory)
public
abstract
bool
CheckAnalyzers
(
string
baseDirectory
,
ImmutableArray
<
CommandLineAnalyzerReference
>
analyzers
);
public
abstract
void
Log
(
string
message
);
public
bool
TryCreateCompiler
(
RunRequest
request
,
out
CommonCompiler
compiler
)
{
switch
(
request
.
Language
)
...
...
src/Compilers/Server/ServerShared/Connection.cs
浏览文件 @
7c75ef98
...
...
@@ -43,7 +43,6 @@ internal enum CompletionReason
/// <summary>
/// There was an unhandled exception processing the result.
/// BTODO: need to handle this is the server.
/// </summary>
ClientException
,
}
...
...
@@ -190,15 +189,15 @@ private BuildResponse ServeBuildRequestCore(BuildRequest buildRequest, Cancellat
if
(!
_compilerServerHost
.
TryCreateCompiler
(
request
,
out
compiler
))
{
// We can't do anything with a request we don't know about.
_compilerServerHost
.
Log
(
$"Got request with id '
{
request
.
Language
}
'"
);
Log
(
$"Got request with id '
{
request
.
Language
}
'"
);
return
new
CompletedBuildResponse
(-
1
,
false
,
""
,
""
);
}
_compilerServerHost
.
Log
(
$"CurrentDirectory = '
{
request
.
CurrentDirectory
}
'"
);
_compilerServerHost
.
Log
(
$"LIB = '
{
request
.
LibDirectory
}
'"
);
Log
(
$"CurrentDirectory = '
{
request
.
CurrentDirectory
}
'"
);
Log
(
$"LIB = '
{
request
.
LibDirectory
}
'"
);
for
(
int
i
=
0
;
i
<
request
.
Arguments
.
Length
;
++
i
)
{
_compilerServerHost
.
Log
(
$"Argument[
{
i
}
] = '
{
request
.
Arguments
[
i
]}
'"
);
Log
(
$"Argument[
{
i
}
] = '
{
request
.
Arguments
[
i
]}
'"
);
}
bool
utf8output
=
compiler
.
Arguments
.
Utf8Output
;
...
...
@@ -207,10 +206,10 @@ private BuildResponse ServeBuildRequestCore(BuildRequest buildRequest, Cancellat
return
new
AnalyzerInconsistencyBuildResponse
();
}
_compilerServerHost
.
Log
(
$"****Running
{
request
.
Language
}
compiler..."
);
Log
(
$"****Running
{
request
.
Language
}
compiler..."
);
TextWriter
output
=
new
StringWriter
(
CultureInfo
.
InvariantCulture
);
int
returnCode
=
compiler
.
Run
(
output
,
cancellationToken
);
_compilerServerHost
.
Log
(
$"****
{
request
.
Language
}
Compilation complete.\r\n****Return code:
{
returnCode
}
\r\n****Output:\r\n
{
output
.
ToString
()}
\r\n"
);
Log
(
$"****
{
request
.
Language
}
Compilation complete.\r\n****Return code:
{
returnCode
}
\r\n****Output:\r\n
{
output
.
ToString
()}
\r\n"
);
return
new
CompletedBuildResponse
(
returnCode
,
utf8output
,
output
.
ToString
(),
""
);
}
...
...
src/Compilers/Server/ServerShared/DiagnosticListener.cs
浏览文件 @
7c75ef98
...
...
@@ -20,6 +20,12 @@ internal interface IDiagnosticListener
/// processed is provided in <paramref name="count"/>.
/// </summary>
void
ConnectionProcessed
(
int
count
);
/// <summary>
/// Called when a bad client connection was detected and the server will be shutting down as a
/// result.
/// </summary>
void
DetectedBadConnection
();
}
internal
sealed
class
EmptyDiagnosticListener
:
IDiagnosticListener
...
...
@@ -31,5 +37,9 @@ public void UpdateKeepAlive(TimeSpan timeSpan)
public
void
ConnectionProcessed
(
int
count
)
{
}
public
void
DetectedBadConnection
()
{
}
}
}
src/Compilers/Server/ServerShared/ICompilerServerHost.cs
浏览文件 @
7c75ef98
...
...
@@ -12,11 +12,9 @@ namespace Microsoft.CodeAnalysis.CompilerServer
{
internal
interface
ICompilerServerHost
{
// BTODO: how many of these are needed anymore?
IAnalyzerAssemblyLoader
AnalyzerAssemblyLoader
{
get
;
}
Func
<
string
,
MetadataReferenceProperties
,
PortableExecutableReference
>
AssemblyReferenceProvider
{
get
;
}
bool
TryCreateCompiler
(
RunRequest
request
,
out
CommonCompiler
compiler
);
bool
CheckAnalyzers
(
string
baseDirectory
,
ImmutableArray
<
CommandLineAnalyzerReference
>
analyzers
);
void
Log
(
string
message
);
}
}
src/Compilers/Server/ServerShared/ServerDispatcher.cs
浏览文件 @
7c75ef98
...
...
@@ -113,6 +113,7 @@ public void ListenAndDispatchConnections(TimeSpan? keepAlive, CancellationToken
// the shutdown process. We have to assume that the client disconnected via
// Ctrl+C and wants the server process to terminate. It's possible a compilation
// is running out of control and the client wants their machine back.
_diagnosticListener
.
DetectedBadConnection
();
listenCancellationTokenSource
.
Cancel
();
break
;
}
...
...
src/Compilers/Server/VBCSCompiler/DesktopCompilerServerHost.cs
浏览文件 @
7c75ef98
...
...
@@ -43,11 +43,5 @@ public override bool CheckAnalyzers(string baseDirectory, ImmutableArray<Command
{
return
AnalyzerConsistencyChecker
.
Check
(
baseDirectory
,
analyzers
,
s_analyzerLoader
);
}
public
override
void
Log
(
string
message
)
{
CompilerServerLogger
.
Log
(
message
);
}
}
}
src/Compilers/Server/VBCSCompilerTests/CompilerServerApiTest.cs
浏览文件 @
7c75ef98
...
...
@@ -21,6 +21,7 @@ private sealed class TestableDiagnosticListener : IDiagnosticListener
public
int
ProcessedCount
;
public
DateTime
?
LastProcessedTime
;
public
TimeSpan
?
KeepAlive
;
public
bool
HasDetectedBadConnection
;
public
void
ConnectionProcessed
(
int
count
)
{
...
...
@@ -32,6 +33,11 @@ public void UpdateKeepAlive(TimeSpan timeSpan)
{
KeepAlive
=
timeSpan
;
}
public
void
DetectedBadConnection
()
{
HasDetectedBadConnection
=
true
;
}
}
private
static
readonly
BuildRequest
s_emptyCSharpBuildRequest
=
new
BuildRequest
(
...
...
@@ -278,5 +284,41 @@ public async Task KeepAliveAfterSimultaneousConnection()
Assert
.
True
(
listener
.
LastProcessedTime
.
HasValue
);
Assert
.
True
((
DateTime
.
Now
-
listener
.
LastProcessedTime
.
Value
)
>
keepAlive
);
}
[
Fact
]
public
void
ClientExceptionShouldBeginShutdown
()
{
var
client
=
new
Mock
<
IClientConnection
>();
client
.
Setup
(
x
=>
x
.
HandleConnection
(
It
.
IsAny
<
CancellationToken
>()))
.
Throws
(
new
Exception
());
var
listenCancellationToken
=
default
(
CancellationToken
);
var
first
=
true
;
var
host
=
new
Mock
<
IClientConnectionHost
>();
host
.
Setup
(
x
=>
x
.
CreateListenTask
(
It
.
IsAny
<
CancellationToken
>()))
.
Returns
((
CancellationToken
cancellationToken
)
=>
{
if
(
first
)
{
first
=
false
;
return
Task
.
FromResult
(
client
.
Object
);
}
else
{
listenCancellationToken
=
cancellationToken
;
return
Task
.
Delay
(-
1
,
cancellationToken
).
ContinueWith
<
IClientConnection
>(
_
=>
null
,
TaskScheduler
.
Default
);
}
});
var
listener
=
new
TestableDiagnosticListener
();
var
dispatcher
=
new
ServerDispatcher
(
host
.
Object
,
listener
);
dispatcher
.
ListenAndDispatchConnections
(
TimeSpan
.
FromSeconds
(
10
));
Assert
.
True
(
listener
.
HasDetectedBadConnection
);
Assert
.
True
(
listenCancellationToken
.
IsCancellationRequested
);
}
}
}
src/Compilers/Shared/CoreClrBuildClient.cs
浏览文件 @
7c75ef98
...
...
@@ -25,9 +25,10 @@ private CoreClrBuildClient(RequestLanguage language, CompileFunc compileFunc)
internal
static
int
Run
(
IEnumerable
<
string
>
arguments
,
RequestLanguage
language
,
CompileFunc
compileFunc
)
{
//
BTODO:
Should be using BuildClient.GetCommandLineArgs(arguments) here. But the native invoke
// Should be using BuildClient.GetCommandLineArgs(arguments) here. But the native invoke
// ends up giving us both CoreRun and the exe file. Need to find a good way to remove the host
// as well as the EXE argument.
// https://github.com/dotnet/roslyn/issues/6677
var
client
=
new
CoreClrBuildClient
(
language
,
compileFunc
);
var
clientDir
=
AppContext
.
BaseDirectory
;
var
workingDir
=
Directory
.
GetCurrentDirectory
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录