Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f3a55ed2
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,发现更多精彩内容 >>
提交
f3a55ed2
编写于
2月 24, 2019
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply a hang mitigating timeout to WaitForAllAsyncOperations
上级
8ef458b2
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
38 addition
and
10 deletion
+38
-10
src/Test/Diagnostics/TestingOnly_WaitingService.cs
src/Test/Diagnostics/TestingOnly_WaitingService.cs
+22
-5
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpCodeActions.cs
...egrationTest/IntegrationTests/CSharp/CSharpCodeActions.cs
+2
-0
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpFormatting.cs
...tegrationTest/IntegrationTests/CSharp/CSharpFormatting.cs
+3
-0
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpKeywordHighlighting.cs
...Test/IntegrationTests/CSharp/CSharpKeywordHighlighting.cs
+1
-0
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs
...st/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs
+2
-0
src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicKeywordHighlighting.cs
.../IntegrationTests/VisualBasic/BasicKeywordHighlighting.cs
+1
-0
src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicReferenceHighlighting.cs
...ntegrationTests/VisualBasic/BasicReferenceHighlighting.cs
+2
-0
src/VisualStudio/IntegrationTest/TestUtilities/InProcess/VisualStudioWorkspace_InProc.cs
...t/TestUtilities/InProcess/VisualStudioWorkspace_InProc.cs
+2
-2
src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/VisualStudioWorkspace_OutOfProc.cs
...Utilities/OutOfProcess/VisualStudioWorkspace_OutOfProc.cs
+2
-2
src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstance.cs
...dio/IntegrationTest/TestUtilities/VisualStudioInstance.cs
+1
-1
未找到文件。
src/Test/Diagnostics/TestingOnly_WaitingService.cs
浏览文件 @
f3a55ed2
...
...
@@ -2,6 +2,8 @@
using
System
;
using
System.Composition
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Windows.Threading
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Roslyn.Utilities
;
...
...
@@ -35,7 +37,7 @@ public void WaitForAsyncOperations(string featureName, bool waitForWorkspaceFirs
var
waitTask
=
featureWaiter
.
CreateWaitTask
();
WaitForTask
(
waitTask
);
WaitForTask
(
waitTask
,
CancellationToken
.
None
);
// Debugging trick: don't let the listeners collection get optimized away during execution.
// This means if the process is killed during integration tests and the test was waiting, you can
...
...
@@ -45,6 +47,11 @@ public void WaitForAsyncOperations(string featureName, bool waitForWorkspaceFirs
}
public
void
WaitForAllAsyncOperations
(
params
string
[]
featureNames
)
{
WaitForAllAsyncOperations
(
TimeSpan
.
FromMilliseconds
(-
1
),
featureNames
);
}
public
void
WaitForAllAsyncOperations
(
TimeSpan
timeout
,
params
string
[]
featureNames
)
{
var
task
=
_provider
.
WaitAllAsync
(
featureNames
,
...
...
@@ -52,7 +59,17 @@ public void WaitForAllAsyncOperations(params string[] featureNames)
eventProcessingAction
:
()
=>
Dispatcher
.
CurrentDispatcher
.
Invoke
(()
=>
{
},
DispatcherPriority
.
ApplicationIdle
));
#pragma warning restore VSTHRD001 // Avoid legacy thread switching APIs
WaitForTask
(
task
);
if
(
timeout
==
TimeSpan
.
FromMilliseconds
(-
1
))
{
WaitForTask
(
task
,
CancellationToken
.
None
);
}
else
{
using
(
var
cancellationTokenSource
=
new
CancellationTokenSource
(
timeout
))
{
WaitForTask
(
task
,
cancellationTokenSource
.
Token
);
}
}
}
public
void
EnableActiveTokenTracking
(
bool
enable
)
...
...
@@ -65,9 +82,9 @@ public void Enable(bool enable)
AsynchronousOperationListenerProvider
.
Enable
(
enable
);
}
private
void
WaitForTask
(
System
.
Threading
.
Tasks
.
Task
task
)
private
void
WaitForTask
(
Task
task
,
CancellationToken
cancellationToken
)
{
while
(!
task
.
Wait
(
100
))
while
(!
task
.
Wait
(
100
,
cancellationToken
))
{
// set breakpoint here when debugging
var
tokens
=
_provider
.
GetTokens
();
...
...
@@ -76,7 +93,7 @@ private void WaitForTask(System.Threading.Tasks.Task task)
// make sure pending task that require UI threads to finish as well.
#pragma warning disable VSTHRD001 // Avoid legacy thread switching APIs
Dispatcher
.
CurrentDispatcher
.
Invoke
(()
=>
{
},
DispatcherPriority
.
ApplicationIdle
);
Dispatcher
.
CurrentDispatcher
.
Invoke
(()
=>
{
},
DispatcherPriority
.
ApplicationIdle
,
cancellationToken
);
#pragma warning restore VSTHRD001 // Avoid legacy thread switching APIs
}
}
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpCodeActions.cs
浏览文件 @
f3a55ed2
...
...
@@ -210,6 +210,7 @@ class C
// Wait for CodingConventions library events to propagate to the workspace
VisualStudio
.
WaitForApplicationIdle
(
CancellationToken
.
None
);
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
);
...
...
@@ -233,6 +234,7 @@ class C
// Wait for CodingConventions library events to propagate to the workspace
VisualStudio
.
WaitForApplicationIdle
(
CancellationToken
.
None
);
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
);
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpFormatting.cs
浏览文件 @
f3a55ed2
...
...
@@ -314,6 +314,7 @@ public int X1
*/
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
);
...
...
@@ -337,6 +338,7 @@ public int X1
// Wait for CodingConventions library events to propagate to the workspace
VisualStudio
.
WaitForApplicationIdle
(
CancellationToken
.
None
);
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
);
...
...
@@ -354,6 +356,7 @@ public int X1
// Wait for CodingConventions library events to propagate to the workspace
VisualStudio
.
WaitForApplicationIdle
(
CancellationToken
.
None
);
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
);
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpKeywordHighlighting.cs
浏览文件 @
f3a55ed2
...
...
@@ -104,6 +104,7 @@ private void Verify(string marker, ImmutableArray<TextSpan> expectedCount)
{
VisualStudio
.
Editor
.
PlaceCaret
(
marker
,
charsOffset
:
-
1
);
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
,
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpReferenceHighlighting.cs
浏览文件 @
f3a55ed2
...
...
@@ -86,6 +86,7 @@ private void Verify(string marker, IDictionary<string, ImmutableArray<TextSpan>>
{
VisualStudio
.
Editor
.
PlaceCaret
(
marker
,
charsOffset
:
-
1
);
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
,
...
...
@@ -109,6 +110,7 @@ private void VerifyNone(string marker)
{
VisualStudio
.
Editor
.
PlaceCaret
(
marker
,
charsOffset
:
-
1
);
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
,
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicKeywordHighlighting.cs
浏览文件 @
f3a55ed2
...
...
@@ -40,6 +40,7 @@ private void Verify(string marker, int expectedCount)
{
VisualStudio
.
Editor
.
PlaceCaret
(
marker
,
charsOffset
:
-
1
);
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
,
...
...
src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicReferenceHighlighting.cs
浏览文件 @
f3a55ed2
...
...
@@ -46,6 +46,7 @@ private void Verify(string marker, IDictionary<string, ImmutableArray<TextSpan>>
{
VisualStudio
.
Editor
.
PlaceCaret
(
marker
,
charsOffset
:
-
1
);
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
,
...
...
@@ -61,6 +62,7 @@ private void VerifyNone(string marker)
{
VisualStudio
.
Editor
.
PlaceCaret
(
marker
,
charsOffset
:
-
1
);
VisualStudio
.
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
,
FeatureAttribute
.
Workspace
,
FeatureAttribute
.
SolutionCrawler
,
FeatureAttribute
.
DiagnosticService
,
...
...
src/VisualStudio/IntegrationTest/TestUtilities/InProcess/VisualStudioWorkspace_InProc.cs
浏览文件 @
f3a55ed2
...
...
@@ -123,8 +123,8 @@ private static TestingOnly_WaitingService GetWaitingService()
public
void
WaitForAsyncOperations
(
string
featuresToWaitFor
,
bool
waitForWorkspaceFirst
=
true
)
=>
GetWaitingService
().
WaitForAsyncOperations
(
featuresToWaitFor
,
waitForWorkspaceFirst
);
public
void
WaitForAllAsyncOperations
(
params
string
[]
featureNames
)
=>
GetWaitingService
().
WaitForAllAsyncOperations
(
featureNames
);
public
void
WaitForAllAsyncOperations
(
TimeSpan
timeout
,
params
string
[]
featureNames
)
=>
GetWaitingService
().
WaitForAllAsyncOperations
(
timeout
,
featureNames
);
private
static
void
LoadRoslynPackage
()
{
...
...
src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/VisualStudioWorkspace_OutOfProc.cs
浏览文件 @
f3a55ed2
...
...
@@ -50,8 +50,8 @@ public void SetOption(string optionName, string feature, object value)
public
void
WaitForAsyncOperations
(
string
featuresToWaitFor
,
bool
waitForWorkspaceFirst
=
true
)
=>
_inProc
.
WaitForAsyncOperations
(
featuresToWaitFor
,
waitForWorkspaceFirst
);
public
void
WaitForAllAsyncOperations
(
params
string
[]
featureNames
)
=>
_inProc
.
WaitForAllAsyncOperations
(
featureNames
);
public
void
WaitForAllAsyncOperations
(
TimeSpan
timeout
,
params
string
[]
featureNames
)
=>
_inProc
.
WaitForAllAsyncOperations
(
timeout
,
featureNames
);
public
void
CleanUpWorkspace
()
=>
_inProc
.
CleanUpWorkspace
();
...
...
src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstance.cs
浏览文件 @
f3a55ed2
...
...
@@ -194,7 +194,7 @@ public void CleanUp()
Workspace
.
CleanUpWaitingService
();
Workspace
.
CleanUpWorkspace
();
SolutionExplorer
.
CleanUpOpenSolution
();
Workspace
.
WaitForAllAsyncOperations
();
Workspace
.
WaitForAllAsyncOperations
(
Helper
.
HangMitigatingTimeout
);
// Close any windows leftover from previous (failed) tests
InteractiveWindow
.
CloseInteractiveWindow
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录