Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4bb1ffe5
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,发现更多精彩内容 >>
未验证
提交
4bb1ffe5
编写于
10月 05, 2018
作者:
H
Heejae Chang
提交者:
GitHub
10月 05, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ClientId to RemoteHost so that test window can discover our OOP from thier own OOP (#30333)
上级
c6b7941c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
58 addition
and
10 deletion
+58
-10
src/EditorFeatures/TestUtilities/Remote/InProcRemostHostClient.cs
...orFeatures/TestUtilities/Remote/InProcRemostHostClient.cs
+7
-2
src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.ConnectionManager.cs
...on/Remote/ServiceHubRemoteHostClient.ConnectionManager.cs
+2
-0
src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.cs
...e/Def/Implementation/Remote/ServiceHubRemoteHostClient.cs
+13
-7
src/VisualStudio/Core/Test.Next/Remote/RemoteHostClientServiceFactoryTests.cs
...e/Test.Next/Remote/RemoteHostClientServiceFactoryTests.cs
+20
-0
src/Workspaces/Core/Portable/Remote/RemoteHostClient.cs
src/Workspaces/Core/Portable/Remote/RemoteHostClient.cs
+16
-1
未找到文件。
src/EditorFeatures/TestUtilities/Remote/InProcRemostHostClient.cs
浏览文件 @
4bb1ffe5
...
...
@@ -29,10 +29,10 @@ public static async Task<RemoteHostClient> CreateAsync(Workspace workspace, bool
var
remoteHostStream
=
await
inprocServices
.
RequestServiceAsync
(
WellKnownRemoteHostServices
.
RemoteHostService
,
cancellationToken
).
ConfigureAwait
(
false
);
var
remotableDataRpc
=
new
RemotableDataJsonRpc
(
workspace
,
inprocServices
.
Logger
,
await
inprocServices
.
RequestServiceAsync
(
WellKnownServiceHubServices
.
SnapshotService
,
cancellationToken
).
ConfigureAwait
(
false
));
var
instance
=
new
InProcRemoteHostClient
(
workspace
,
inprocServices
,
new
ReferenceCountedDisposable
<
RemotableDataJsonRpc
>(
remotableDataRpc
),
remoteHostStream
);
var
current
=
CreateClientId
(
Process
.
GetCurrentProcess
().
Id
.
ToString
());
var
instance
=
new
InProcRemoteHostClient
(
current
,
workspace
,
inprocServices
,
new
ReferenceCountedDisposable
<
RemotableDataJsonRpc
>(
remotableDataRpc
),
remoteHostStream
);
// make sure connection is done right
var
current
=
$"VS (
{
Process
.
GetCurrentProcess
().
Id
}
)"
;
var
telemetrySession
=
default
(
string
);
var
uiCultureLCIDE
=
0
;
var
cultureLCID
=
0
;
...
...
@@ -49,6 +49,7 @@ public static async Task<RemoteHostClient> CreateAsync(Workspace workspace, bool
}
private
InProcRemoteHostClient
(
string
clientId
,
Workspace
workspace
,
InProcRemoteServices
inprocServices
,
ReferenceCountedDisposable
<
RemotableDataJsonRpc
>
remotableDataRpc
,
...
...
@@ -57,6 +58,8 @@ public static async Task<RemoteHostClient> CreateAsync(Workspace workspace, bool
{
Contract
.
ThrowIfNull
(
remotableDataRpc
);
ClientId
=
clientId
;
_inprocServices
=
inprocServices
;
_remotableDataRpc
=
remotableDataRpc
;
...
...
@@ -76,6 +79,8 @@ public void RegisterService(string name, Func<Stream, IServiceProvider, ServiceH
_inprocServices
.
RegisterService
(
name
,
serviceCreator
);
}
public
override
string
ClientId
{
get
;
}
public
override
async
Task
<
Connection
>
TryCreateConnectionAsync
(
string
serviceName
,
object
callbackTarget
,
CancellationToken
cancellationToken
)
{
...
...
src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.ConnectionManager.cs
浏览文件 @
4bb1ffe5
...
...
@@ -57,6 +57,8 @@ private partial class ConnectionManager
_shutdownLock
=
new
ReaderWriterLockSlim
(
LockRecursionPolicy
.
NoRecursion
);
}
public
HostGroup
HostGroup
=>
_hostGroup
;
public
Task
<
Connection
>
TryCreateConnectionAsync
(
string
serviceName
,
object
callbackTarget
,
CancellationToken
cancellationToken
)
{
// pool is not enabled by option
...
...
src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.cs
浏览文件 @
4bb1ffe5
...
...
@@ -7,7 +7,6 @@
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Internal.Log
;
using
Microsoft.CodeAnalysis.Notification
;
...
...
@@ -30,8 +29,6 @@ private enum GlobalNotificationState
Finished
}
private
static
int
s_instanceId
=
0
;
private
readonly
JsonRpc
_rpc
;
private
readonly
ConnectionManager
_connectionManager
;
...
...
@@ -75,9 +72,7 @@ public static async Task<ServiceHubRemoteHostClient> CreateWorkerAsync(Workspace
try
{
// let each client to have unique id so that we can distinguish different clients when service is restarted
var
currentInstanceId
=
Interlocked
.
Add
(
ref
s_instanceId
,
1
);
var
current
=
$"VS (
{
Process
.
GetCurrentProcess
().
Id
}
) (
{
currentInstanceId
}
)"
;
var
current
=
CreateClientId
(
Process
.
GetCurrentProcess
().
Id
.
ToString
());
var
hostGroup
=
new
HostGroup
(
current
);
var
remoteHostStream
=
await
Connections
.
RequestServiceAsync
(
workspace
,
primary
,
WellKnownRemoteHostServices
.
RemoteHostService
,
hostGroup
,
timeout
,
cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -133,6 +128,8 @@ public static async Task<ServiceHubRemoteHostClient> CreateWorkerAsync(Workspace
_rpc
.
StartListening
();
}
public
override
string
ClientId
=>
_connectionManager
.
HostGroup
.
Id
;
public
override
Task
<
Connection
>
TryCreateConnectionAsync
(
string
serviceName
,
object
callbackTarget
,
CancellationToken
cancellationToken
)
{
return
_connectionManager
.
TryCreateConnectionAsync
(
serviceName
,
callbackTarget
,
cancellationToken
);
...
...
@@ -158,6 +155,15 @@ protected override void OnStopped()
_connectionManager
.
Shutdown
();
}
public
HostGroup
HostGroup
{
get
{
Debug
.
Assert
(
_connectionManager
.
HostGroup
.
Id
==
ClientId
);
return
_connectionManager
.
HostGroup
;
}
}
private
void
RegisterGlobalOperationNotifications
()
{
var
globalOperationService
=
this
.
Workspace
.
Services
.
GetService
<
IGlobalOperationNotificationService
>();
...
...
@@ -295,4 +301,4 @@ private void OnRpcDisconnected(object sender, JsonRpcDisconnectedEventArgs e)
Stopped
();
}
}
}
\ No newline at end of file
}
src/VisualStudio/Core/Test.Next/Remote/RemoteHostClientServiceFactoryTests.cs
浏览文件 @
4bb1ffe5
...
...
@@ -52,6 +52,26 @@ public async Task Enable_Disable()
Assert
.
Null
(
disabledClient
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
RemoteHost
)]
public
async
Task
ClientId
()
{
var
service
=
CreateRemoteHostClientService
();
service
.
Enable
();
var
client1
=
await
service
.
TryGetRemoteHostClientAsync
(
CancellationToken
.
None
);
var
id1
=
client1
.
ClientId
;
await
service
.
RequestNewRemoteHostAsync
(
CancellationToken
.
None
);
var
client2
=
await
service
.
TryGetRemoteHostClientAsync
(
CancellationToken
.
None
);
var
id2
=
client2
.
ClientId
;
Assert
.
NotEqual
(
id1
,
id2
);
service
.
Disable
();
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
RemoteHost
)]
public
async
Task
GlobalAssets
()
{
...
...
src/Workspaces/Core/Portable/Remote/RemoteHostClient.cs
浏览文件 @
4bb1ffe5
...
...
@@ -26,6 +26,14 @@ protected RemoteHostClient(Workspace workspace)
public
event
EventHandler
<
bool
>
StatusChanged
;
/// <summary>
/// Return an unique string per client.
///
/// one can use this to distinguish different clients that are connected to different RemoteHosts including
/// cases where 2 external process finding each others
/// </summary>
public
abstract
string
ClientId
{
get
;
}
/// <summary>
/// Create <see cref="RemoteHostClient.Connection"/> for the <paramref name="serviceName"/> if possible.
/// otherwise, return null.
...
...
@@ -64,6 +72,11 @@ private void OnStatusChanged(bool started)
StatusChanged
?.
Invoke
(
this
,
started
);
}
public
static
string
CreateClientId
(
string
prefix
)
{
return
$"VS (
{
prefix
}
) (
{
Guid
.
NewGuid
().
ToString
()}
)"
;
}
/// <summary>
/// NoOpClient is used if a user killed our remote host process. Basically this client never
/// create a session
...
...
@@ -75,6 +88,8 @@ public class NoOpClient : RemoteHostClient
{
}
public
override
string
ClientId
=>
nameof
(
NoOpClient
);
public
override
Task
<
Connection
>
TryCreateConnectionAsync
(
string
serviceName
,
object
callbackTarget
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
Default
<
Connection
>();
...
...
@@ -140,7 +155,7 @@ public void Dispose()
// when that happen, we don't want to crash VS, so this is debug only check
if
(!
Environment
.
HasShutdownStarted
)
{
Debug
.
Assert
(
false
,
Debug
.
Assert
(
false
,
$"Unless OOP process (RoslynCodeAnalysisService) is explicitly killed, this should have been disposed!\r\n
{
_creationCallStack
}
"
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录