Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
3e4cf945
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,发现更多精彩内容 >>
提交
3e4cf945
编写于
6月 13, 2018
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bypass the Preview Changes dialog for Fix All testing
上级
64764506
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
14 deletion
+40
-14
src/Features/Core/Portable/CodeFixes/FixAllOccurrences/FixSomeCodeAction.cs
...Portable/CodeFixes/FixAllOccurrences/FixSomeCodeAction.cs
+24
-1
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpCodeActions.cs
...egrationTest/IntegrationTests/CSharp/CSharpCodeActions.cs
+2
-11
src/VisualStudio/IntegrationTest/TestUtilities/InProcess/TextViewWindow_InProc.cs
...tionTest/TestUtilities/InProcess/TextViewWindow_InProc.cs
+14
-2
未找到文件。
src/Features/Core/Portable/CodeFixes/FixAllOccurrences/FixSomeCodeAction.cs
浏览文件 @
3e4cf945
...
...
@@ -16,7 +16,7 @@ internal abstract class FixSomeCodeAction : CodeAction
private
static
readonly
HashSet
<
string
>
s_predefinedCodeFixProviderNames
=
GetPredefinedCodeFixProviderNames
();
internal
readonly
FixAllState
FixAllState
;
private
readonly
bool
_showPreviewChangesDialog
;
private
bool
_showPreviewChangesDialog
;
internal
FixSomeCodeAction
(
FixAllState
fixAllState
,
bool
showPreviewChangesDialog
)
...
...
@@ -84,5 +84,28 @@ private static HashSet<string> GetPredefinedCodeFixProviderNames()
return
names
;
}
internal
TestAccessor
GetTestAccessor
()
{
return
new
TestAccessor
(
this
);
}
internal
readonly
struct
TestAccessor
{
private
readonly
FixSomeCodeAction
_fixSomeCodeAction
;
internal
TestAccessor
(
FixSomeCodeAction
fixSomeCodeAction
)
{
_fixSomeCodeAction
=
fixSomeCodeAction
;
}
/// <summary>
/// Gets a reference to <see cref="_showPreviewChangesDialog"/>, which can be read or written by test code.
/// </summary>
public
ref
bool
ShowPreviewChangesDialog
{
get
=>
ref
_fixSomeCodeAction
.
_showPreviewChangesDialog
;
}
}
}
}
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpCodeActions.cs
浏览文件 @
3e4cf945
...
...
@@ -215,12 +215,7 @@ class C
VisualStudio
.
Editor
.
Verify
.
CodeAction
(
"Use expression body for properties"
,
applyFix
:
true
,
fixAllScope
:
FixAllScope
.
Project
,
blockUntilComplete
:
false
);
var
expectedTitle
=
"Preview Changes - Fix all occurrences"
;
VisualStudio
.
PreviewChangesDialog
.
VerifyOpen
(
expectedTitle
,
Helper
.
HangMitigatingTimeout
);
VisualStudio
.
PreviewChangesDialog
.
ClickApplyAndWaitForFeature
(
expectedTitle
,
FeatureAttribute
.
DiagnosticService
);
fixAllScope
:
FixAllScope
.
Project
);
Assert
.
Equal
(
expectedText
,
VisualStudio
.
Editor
.
GetText
());
...
...
@@ -243,11 +238,7 @@ class C
VisualStudio
.
Editor
.
Verify
.
CodeAction
(
"Use block body for properties"
,
applyFix
:
true
,
fixAllScope
:
FixAllScope
.
Project
,
blockUntilComplete
:
false
);
VisualStudio
.
PreviewChangesDialog
.
VerifyOpen
(
expectedTitle
,
Helper
.
HangMitigatingTimeout
);
VisualStudio
.
PreviewChangesDialog
.
ClickApplyAndWaitForFeature
(
expectedTitle
,
FeatureAttribute
.
DiagnosticService
);
fixAllScope
:
FixAllScope
.
Project
);
expectedText
=
@"
class C
...
...
src/VisualStudio/IntegrationTest/TestUtilities/InProcess/TextViewWindow_InProc.cs
浏览文件 @
3e4cf945
...
...
@@ -15,6 +15,7 @@
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.Text.Operations
;
using
Microsoft.VisualStudio.Text.Tagging
;
using
Roslyn.Utilities
;
using
OLECMDEXECOPT
=
Microsoft
.
VisualStudio
.
OLE
.
Interop
.
OLECMDEXECOPT
;
using
ThreadHelper
=
Microsoft
.
VisualStudio
.
Shell
.
ThreadHelper
;
...
...
@@ -319,7 +320,7 @@ private async Task<IEnumerable<ISuggestedAction>> GetLightBulbActionsAsync(ILigh
public
void
ApplyLightBulbAction
(
string
actionName
,
FixAllScope
?
fixAllScope
,
bool
blockUntilComplete
)
{
var
lightBulbAction
=
GetLightBulbApplicationAction
(
actionName
,
fixAllScope
);
var
lightBulbAction
=
GetLightBulbApplicationAction
(
actionName
,
fixAllScope
,
blockUntilComplete
);
var
task
=
ThreadHelper
.
JoinableTaskFactory
.
RunAsync
(
async
()
=>
{
await
ThreadHelper
.
JoinableTaskFactory
.
SwitchToMainThreadAsync
();
...
...
@@ -340,7 +341,7 @@ public void ApplyLightBulbAction(string actionName, FixAllScope? fixAllScope, bo
private
void
BeginInvokeExecuteOnActiveView
(
Action
<
IWpfTextView
>
action
)
=>
BeginInvokeOnUIThread
(
GetExecuteOnActionViewCallback
(
action
));
private
Func
<
IWpfTextView
,
Task
>
GetLightBulbApplicationAction
(
string
actionName
,
FixAllScope
?
fixAllScope
)
private
Func
<
IWpfTextView
,
Task
>
GetLightBulbApplicationAction
(
string
actionName
,
FixAllScope
?
fixAllScope
,
bool
willBlockUntilComplete
)
{
return
async
view
=>
{
...
...
@@ -378,6 +379,17 @@ private void BeginInvokeExecuteOnActiveView(Action<IWpfTextView> action)
throw
new
InvalidOperationException
(
$"Unable to find FixAll in
{
fixAllScope
.
ToString
()}
code fix for suggested action '
{
action
.
DisplayText
}
'."
);
}
if
(
willBlockUntilComplete
&&
action
is
FixAllSuggestedAction
fixAllSuggestedAction
&&
fixAllSuggestedAction
.
CodeAction
is
FixSomeCodeAction
fixSomeCodeAction
)
{
// Ensure the preview changes dialog will not be shown. Since the operation 'willBlockUntilComplete',
// the caller would not be able to interact with the preview changes dialog, and the tests would
// either timeout or deadlock.
fixSomeCodeAction
.
GetTestAccessor
().
ShowPreviewChangesDialog
=
false
;
}
if
(
string
.
IsNullOrEmpty
(
actionName
))
{
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录