Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c190e846
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,发现更多精彩内容 >>
未验证
提交
c190e846
编写于
5月 21, 2018
作者:
S
Shyam-Gupta
提交者:
GitHub
5月 21, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #27019 from dotnet/merges/dev15.8-preview2-to-master
Merge dev15.8-preview2 to master
上级
8e5768ed
32df6a6f
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
51 addition
and
72 deletion
+51
-72
src/Interactive/EditorFeatures/Core/Extensibility/Interactive/InteractiveEvaluator.cs
...es/Core/Extensibility/Interactive/InteractiveEvaluator.cs
+4
-4
src/Interactive/Features/Interactive/Core/InteractiveHost.LazyRemoteService.cs
...res/Interactive/Core/InteractiveHost.LazyRemoteService.cs
+1
-1
src/Interactive/Features/Interactive/Core/InteractiveHost.RemoteService.cs
...eatures/Interactive/Core/InteractiveHost.RemoteService.cs
+9
-12
src/Interactive/Features/Interactive/Core/InteractiveHost.cs
src/Interactive/Features/Interactive/Core/InteractiveHost.cs
+35
-53
src/Interactive/HostTest/InteractiveHostTests.cs
src/Interactive/HostTest/InteractiveHostTests.cs
+2
-2
未找到文件。
src/Interactive/EditorFeatures/Core/Extensibility/Interactive/InteractiveEvaluator.cs
浏览文件 @
c190e846
...
...
@@ -137,8 +137,8 @@ public IInteractiveWindow CurrentWindow
_currentWindow
=
value
;
_workspace
.
Window
=
value
;
_interactiveHost
.
SetOutput
(
_currentWindow
.
OutputWriter
)
;
_interactiveHost
.
SetErrorOutput
(
_currentWindow
.
ErrorOutputWriter
)
;
_interactiveHost
.
Output
=
_currentWindow
.
OutputWriter
;
_interactiveHost
.
ErrorOutput
=
_currentWindow
.
ErrorOutputWriter
;
_currentWindow
.
SubmissionBufferAdded
+=
SubmissionBufferAdded
;
_interactiveCommands
=
_commandsFactory
.
CreateInteractiveCommands
(
_currentWindow
,
CommandPrefix
,
_commands
);
...
...
@@ -171,8 +171,8 @@ private IInteractiveWindow GetCurrentWindowOrThrow()
public
Task
<
ExecutionResult
>
InitializeAsync
()
{
var
window
=
GetCurrentWindowOrThrow
();
_interactiveHost
.
SetOutput
(
window
.
OutputWriter
)
;
_interactiveHost
.
SetErrorOutput
(
window
.
ErrorOutputWriter
)
;
_interactiveHost
.
Output
=
window
.
OutputWriter
;
_interactiveHost
.
ErrorOutput
=
window
.
ErrorOutputWriter
;
return
ResetAsyncWorker
();
}
...
...
src/Interactive/Features/Interactive/Core/InteractiveHost.LazyRemoteService.cs
浏览文件 @
c190e846
...
...
@@ -81,8 +81,8 @@ private async Task<InitializedRemoteService> TryStartAndInitializeProcessAsync(C
if
(!
initializationResult
.
Success
)
{
Host
.
ReportProcessExited
(
remoteService
.
Process
);
remoteService
.
Dispose
(
joinThreads
:
false
);
Host
.
ReportProcessExited
(
remoteService
.
Process
);
return
default
(
InitializedRemoteService
);
}
...
...
src/Interactive/Features/Interactive/Core/InteractiveHost.RemoteService.cs
浏览文件 @
c190e846
...
...
@@ -74,14 +74,9 @@ private async void ProcessExitedHandler(object _, EventArgs __)
_processExitHandlerStatus
=
ProcessExitHandlerStatus
.
Handled
;
// Should set _processExitHandlerStatus before calling OnProcessExited to avoid deadlocks.
// Calling the host should be within the lock to prevent its disposing during the execution.
await
_host
.
OnProcessExited
(
Process
).
ConfigureAwait
(
false
);
}
}
var
host
=
_host
;
if
(
host
!=
null
)
{
await
host
.
OnProcessExited
(
Process
).
ConfigureAwait
(
false
);
}
}
catch
(
Exception
e
)
when
(
FatalError
.
Report
(
e
))
{
...
...
@@ -119,11 +114,12 @@ private void ReadOutput(bool error)
}
}
// Dispose may called anytime.
internal
void
Dispose
(
bool
joinThreads
)
{
// There can be a call from host initiated from OnProcessExit.
// We should not proceed with disposing if _disposeSemaphore is locked.
// This check on the beginning helps to avoid a reentrancy.
if
(
_processExitHandlerStatus
==
ProcessExitHandlerStatus
.
Hooked
)
{
using
(
_disposeSemaphore
.
DisposableWait
())
{
if
(
_processExitHandlerStatus
==
ProcessExitHandlerStatus
.
Hooked
)
...
...
@@ -132,6 +128,7 @@ internal void Dispose(bool joinThreads)
_processExitHandlerStatus
=
ProcessExitHandlerStatus
.
Handled
;
}
}
}
InitiateTermination
(
Process
,
_processId
);
...
...
src/Interactive/Features/Interactive/Core/InteractiveHost.cs
浏览文件 @
c190e846
...
...
@@ -40,8 +40,6 @@ internal sealed partial class InteractiveHost : MarshalByRefObject
private
TextWriter
_output
;
private
TextWriter
_errorOutput
;
private
readonly
object
_outputGuard
;
private
readonly
object
_errorOutputGuard
;
internal
event
Action
<
bool
>
ProcessStarting
;
...
...
@@ -57,8 +55,6 @@ internal sealed partial class InteractiveHost : MarshalByRefObject
_replServiceProviderType
=
replServiceProviderType
;
_hostPath
=
hostPath
;
_initialWorkingDirectory
=
workingDirectory
;
_outputGuard
=
new
object
();
_errorOutputGuard
=
new
object
();
var
serverProvider
=
new
BinaryServerFormatterSinkProvider
{
TypeFilterLevel
=
TypeFilterLevel
.
Full
};
_serverChannel
=
new
IpcServerChannel
(
GenerateUniqueChannelLocalName
(),
"ReplChannel-"
+
Guid
.
NewGuid
(),
serverProvider
);
...
...
@@ -73,9 +69,9 @@ internal sealed partial class InteractiveHost : MarshalByRefObject
internal
Process
TryGetProcess
()
{
InitializedRemoteService
initializedService
;
var
lazyRemoteService
=
_lazyRemoteService
;
return
(
lazyRemoteService
?.
InitializedService
!=
null
&&
lazyRemoteService
.
InitializedService
.
TryGetValue
(
out
initializedService
))
?
initializedService
.
ServiceOpt
.
Process
:
null
;
return
(
_
lazyRemoteService
?.
InitializedService
!=
null
&&
_
lazyRemoteService
.
InitializedService
.
TryGetValue
(
out
initializedService
))
?
initializedService
.
ServiceOpt
.
Process
:
null
;
}
internal
Service
TryGetService
()
...
...
@@ -171,11 +167,7 @@ private RemoteService TryStartProcess(CultureInfo culture, CancellationToken can
return
null
;
}
lock
(
_outputGuard
)
{
_output
.
WriteLine
(
FeaturesResources
.
Attempt_to_connect_to_process_Sharp_0_failed_retrying
,
newProcessId
);
}
cancellationToken
.
ThrowIfCancellationRequested
();
}
...
...
@@ -219,13 +211,9 @@ private bool CheckAlive(Process process)
{
bool
alive
=
process
.
IsAlive
();
if
(!
alive
)
{
string
errorString
=
process
.
StandardError
.
ReadToEnd
();
lock
(
_errorOutputGuard
)
{
_errorOutput
.
WriteLine
(
FeaturesResources
.
Failed_to_launch_0_process_exit_code_colon_1_with_output_colon
,
_hostPath
,
process
.
ExitCode
);
_errorOutput
.
WriteLine
(
errorString
);
}
_errorOutput
.
WriteLine
(
process
.
StandardError
.
ReadToEnd
());
}
return
alive
;
...
...
@@ -236,12 +224,9 @@ private bool CheckAlive(Process process)
DisposeRemoteService
(
disposing
:
false
);
}
// Dispose may be called anytime.
public
void
Dispose
()
{
DisposeChannel
();
SetOutput
(
TextWriter
.
Null
);
SetErrorOutput
(
TextWriter
.
Null
);
DisposeRemoteService
(
disposing
:
true
);
GC
.
SuppressFinalize
(
this
);
}
...
...
@@ -264,31 +249,41 @@ private void DisposeChannel()
}
}
public
void
SetOutput
(
TextWriter
value
)
public
TextWriter
Output
{
get
{
return
_output
;
}
set
{
if
(
value
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
value
));
}
lock
(
_outputGuard
)
{
_output
.
Flush
();
_output
=
value
;
var
oldOutput
=
Interlocked
.
Exchange
(
ref
_output
,
value
);
oldOutput
.
Flush
();
}
}
public
TextWriter
ErrorOutput
{
get
{
return
_errorOutput
;
}
public
void
SetErrorOutput
(
TextWriter
value
)
set
{
if
(
value
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
value
));
}
lock
(
_errorOutputGuard
)
{
_errorOutput
.
Flush
();
_errorOutput
=
value
;
var
oldOutput
=
Interlocked
.
Exchange
(
ref
_errorOutput
,
value
);
oldOutput
.
Flush
();
}
}
...
...
@@ -296,13 +291,9 @@ internal void OnOutputReceived(bool error, char[] buffer, int count)
{
(
error
?
ErrorOutputReceived
:
OutputReceived
)?.
Invoke
(
buffer
,
count
);
var
writer
=
error
?
_errorOutput
:
_output
;
var
guard
=
error
?
_errorOutputGuard
:
_outputGuard
;
lock
(
guard
)
{
var
writer
=
error
?
ErrorOutput
:
Output
;
writer
.
Write
(
buffer
,
0
,
count
);
}
}
private
LazyRemoteService
CreateRemoteService
(
InteractiveHostOptions
options
,
bool
skipInitialization
)
{
...
...
@@ -328,13 +319,10 @@ private void ReportProcessExited(Process process)
}
if
(
exitCode
.
HasValue
)
{
lock
(
_errorOutputGuard
)
{
_errorOutput
.
WriteLine
(
FeaturesResources
.
Hosting_process_exited_with_exit_code_0
,
exitCode
.
Value
);
}
}
}
private
async
Task
<
InitializedRemoteService
>
TryGetOrCreateRemoteServiceAsync
(
bool
processPendingOutput
)
{
...
...
@@ -342,14 +330,11 @@ private async Task<InitializedRemoteService> TryGetOrCreateRemoteServiceAsync(bo
{
LazyRemoteService
currentRemoteService
=
_lazyRemoteService
;
// disposed or not reset:
Debug
.
Assert
(
currentRemoteService
!=
null
);
for
(
int
attempt
=
0
;
attempt
<
MaxAttemptsToCreateProcess
;
attempt
++)
{
// Remote service may be disposed anytime.
if
(
currentRemoteService
==
null
)
{
return
default
;
}
var
initializedService
=
await
currentRemoteService
.
InitializedService
.
GetValueAsync
(
currentRemoteService
.
CancellationSource
.
Token
).
ConfigureAwait
(
false
);
if
(
initializedService
.
ServiceOpt
!=
null
&&
initializedService
.
ServiceOpt
.
Process
.
IsAlive
())
{
...
...
@@ -374,11 +359,8 @@ private async Task<InitializedRemoteService> TryGetOrCreateRemoteServiceAsync(bo
}
}
lock
(
_errorOutputGuard
)
{
_errorOutput
.
WriteLine
(
FeaturesResources
.
Unable_to_create_hosting_process
);
}
}
catch
(
OperationCanceledException
)
{
// The user reset the process during initialization.
...
...
src/Interactive/HostTest/InteractiveHostTests.cs
浏览文件 @
c190e846
...
...
@@ -92,8 +92,8 @@ private void RedirectOutput()
_synchronizedOutput
=
new
SynchronizedStringWriter
();
_synchronizedErrorOutput
=
new
SynchronizedStringWriter
();
ClearOutput
();
_host
.
SetOutput
(
_synchronizedOutput
)
;
_host
.
SetErrorOutput
(
_synchronizedErrorOutput
)
;
_host
.
Output
=
_synchronizedOutput
;
_host
.
ErrorOutput
=
_synchronizedErrorOutput
;
}
private
bool
LoadReference
(
string
reference
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录