Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
04534a7a
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,发现更多精彩内容 >>
提交
04534a7a
编写于
4月 28, 2020
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid showing dialogs in tests
Fixes #43709
上级
7fd07d52
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
15 deletion
+77
-15
src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs
src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs
+21
-0
src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialogViewModel.cs
...ementation/ChangeSignature/AddParameterDialogViewModel.cs
+19
-6
src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureDialogViewModel.cs
...ntation/ChangeSignature/ChangeSignatureDialogViewModel.cs
+15
-2
src/VisualStudio/Core/Test/ChangeSignature/AddParameterViewModelTests.vb
...o/Core/Test/ChangeSignature/AddParameterViewModelTests.vb
+10
-4
src/VisualStudio/Core/Test/ChangeSignature/ChangeSignatureViewModelTests.vb
...ore/Test/ChangeSignature/ChangeSignatureViewModelTests.vb
+12
-3
未找到文件。
src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs
浏览文件 @
04534a7a
...
...
@@ -14,6 +14,7 @@
using
Microsoft.CodeAnalysis.Editor.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Formatting
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Notification
;
using
Microsoft.CodeAnalysis.Options
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.CodeAnalysis.Text.Shared.Extensions
;
...
...
@@ -70,6 +71,26 @@ public TestWorkspace(ExportProvider exportProvider, string? workspaceKind = null
this
.
CanApplyChangeDocument
=
true
;
this
.
IgnoreUnchangeableDocumentsWhenApplyingChanges
=
ignoreUnchangeableDocumentsWhenApplyingChanges
;
if
(
Services
.
GetService
<
INotificationService
>()
is
INotificationServiceCallback
callback
)
{
// Avoid showing dialogs in tests by default
callback
.
NotificationCallback
=
(
message
,
title
,
severity
)
=>
{
var
severityText
=
severity
switch
{
NotificationSeverity
.
Information
=>
"💡"
,
NotificationSeverity
.
Warning
=>
"⚠"
,
_
=>
"❌"
};
var
fullMessage
=
string
.
IsNullOrEmpty
(
title
)
?
message
:
$"
{
title
}
:
{
Environment
.
NewLine
}{
Environment
.
NewLine
}{
message
}
"
;
throw
new
InvalidOperationException
(
$"
{
severityText
}
{
fullMessage
}
"
);
};
}
_backgroundCompiler
=
new
BackgroundCompiler
(
this
);
_backgroundParser
=
new
BackgroundParser
(
this
);
_backgroundParser
.
Start
();
...
...
src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialogViewModel.cs
浏览文件 @
04534a7a
...
...
@@ -4,6 +4,7 @@
#
nullable
enable
using
System.Diagnostics.CodeAnalysis
;
using
System.Threading
;
using
System.Windows
;
using
Microsoft.CodeAnalysis
;
...
...
@@ -121,35 +122,47 @@ public string VerbatimTypeName
}
}
internal
bool
TrySubmit
(
)
internal
bool
CanSubmit
([
NotNullWhen
(
false
)]
out
string
?
message
)
{
if
(
string
.
IsNullOrEmpty
(
VerbatimTypeName
)
||
string
.
IsNullOrEmpty
(
ParameterName
))
{
SendFailureNotification
(
ServicesVSResources
.
A_type_and_name_must_be_provided
)
;
message
=
ServicesVSResources
.
A_type_and_name_must_be_provided
;
return
false
;
}
if
(!
IsParameterTypeSyntacticallyValid
(
VerbatimTypeName
))
{
SendFailureNotification
(
ServicesVSResources
.
Parameter_type_contains_invalid_characters
)
;
message
=
ServicesVSResources
.
Parameter_type_contains_invalid_characters
;
return
false
;
}
if
(!
IsParameterNameValid
(
ParameterName
))
{
SendFailureNotification
(
ServicesVSResources
.
Parameter_name_contains_invalid_characters
)
;
message
=
ServicesVSResources
.
Parameter_name_contains_invalid_characters
;
return
false
;
}
if
(
IsCallsiteRegularValue
&&
CallSiteValue
.
IsNullOrWhiteSpace
())
{
SendFailureNotification
(
ServicesVSResources
.
Enter_a_call_site_value_or_choose_a_different_value_injection_kind
)
;
message
=
ServicesVSResources
.
Enter_a_call_site_value_or_choose_a_different_value_injection_kind
;
return
false
;
}
if
(
IsOptional
&&
DefaultValue
.
IsNullOrWhiteSpace
())
{
SendFailureNotification
(
ServicesVSResources
.
Optional_parameters_must_provide_a_default_value
);
message
=
ServicesVSResources
.
Optional_parameters_must_provide_a_default_value
;
return
false
;
}
message
=
null
;
return
true
;
}
internal
bool
TrySubmit
()
{
if
(!
CanSubmit
(
out
var
message
))
{
SendFailureNotification
(
message
);
return
false
;
}
...
...
src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureDialogViewModel.cs
浏览文件 @
04534a7a
...
...
@@ -8,6 +8,7 @@
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Diagnostics.CodeAnalysis
;
using
System.Linq
;
using
System.Windows
;
using
System.Windows.Controls
;
...
...
@@ -493,7 +494,7 @@ private void Move(List<ParameterViewModel> list, int index, int delta)
NotifyPropertyChanged
(
nameof
(
SignaturePreviewAutomationText
));
}
internal
bool
TrySubmit
(
)
internal
bool
CanSubmit
([
NotNullWhen
(
false
)]
out
string
?
message
)
{
var
canSubmit
=
AllParameters
.
Any
(
p
=>
p
.
IsRemoved
)
||
AllParameters
.
Any
(
p
=>
p
is
AddedParameterViewModel
)
||
...
...
@@ -502,7 +503,19 @@ internal bool TrySubmit()
if
(!
canSubmit
)
{
_notificationService
.
SendNotification
(
ServicesVSResources
.
You_must_change_the_signature
,
severity
:
NotificationSeverity
.
Information
);
message
=
ServicesVSResources
.
You_must_change_the_signature
;
return
false
;
}
message
=
null
;
return
true
;
}
internal
bool
TrySubmit
()
{
if
(!
CanSubmit
(
out
var
message
))
{
_notificationService
.
SendNotification
(
message
,
severity
:
NotificationSeverity
.
Information
);
return
false
;
}
...
...
src/VisualStudio/Core/Test/ChangeSignature/AddParameterViewModelTests.vb
浏览文件 @
04534a7a
...
...
@@ -31,14 +31,18 @@ class MyClass
VerifyOpeningState(viewModel)
viewModel.VerbatimTypeName = "
int
"
Assert.False(viewModel.TrySubmit())
Dim message As String = Nothing
Assert.False(viewModel.CanSubmit(message))
Assert.Equal(ServicesVSResources.A_type_and_name_must_be_provided, message)
viewModel.VerbatimTypeName =
""
viewModel.ParameterName = "
x
"
Assert.False(viewModel.TrySubmit())
Assert.False(viewModel.CanSubmit(message))
Assert.Equal(ServicesVSResources.A_type_and_name_must_be_provided, message)
viewModel.VerbatimTypeName = "
int
"
Assert.False(viewModel.TrySubmit())
Assert.False(viewModel.CanSubmit(message))
Assert.Equal(ServicesVSResources.Enter_a_call_site_value_or_choose_a_different_value_injection_kind, message)
viewModel.CallSiteValue = "
7
"
Assert.True(viewModel.TrySubmit())
...
...
@@ -279,7 +283,9 @@ class MyClass
Assert.False(viewModel.IsCallsiteTodo)
Assert.False(viewModel.IsCallsiteOmitted)
Assert.False(viewModel.TrySubmit)
Dim message As String = Nothing
Assert.False(viewModel.CanSubmit(message))
Assert.Equal(ServicesVSResources.A_type_and_name_must_be_provided, message)
End Sub
Private Function GetViewModelTestStateAsync(
...
...
src/VisualStudio/Core/Test/ChangeSignature/ChangeSignatureViewModelTests.vb
浏览文件 @
04534a7a
...
...
@@ -69,7 +69,9 @@ class MyClass
Assert
.
True
(
viewModel
.
TrySubmit
)
viewModel
.
MoveUp
()
Assert
.
False
(
viewModel
.
TrySubmit
)
Dim
message
As
String
=
Nothing
Assert
.
False
(
viewModel
.
CanSubmit
(
message
))
Assert
.
Equal
(
ServicesVSResources
.
You_must_change_the_signature
,
message
)
VerifyAlteredState
(
viewModelTestState
,
...
...
@@ -357,7 +359,12 @@ class Goo
End
If
If
canCommit
IsNot
Nothing
Then
Assert
.
Equal
(
canCommit
,
viewModel
.
TrySubmit
())
Dim
message
As
String
=
Nothing
Assert
.
Equal
(
canCommit
,
viewModel
.
CanSubmit
(
message
))
If
canCommit
.
Value
Then
Assert
.
True
(
viewModel
.
TrySubmit
())
End
If
End
If
If
canMoveUp
IsNot
Nothing
Then
...
...
@@ -396,7 +403,9 @@ class Goo
Private
Sub
VerifyOpeningState
(
viewModel
As
ChangeSignatureDialogViewModel
,
openingSignatureDisplay
As
String
)
Assert
.
Equal
(
openingSignatureDisplay
,
viewModel
.
TEST_GetSignatureDisplayText
())
Assert
.
False
(
viewModel
.
TrySubmit
)
Dim
message
As
String
=
Nothing
Assert
.
False
(
viewModel
.
CanSubmit
(
message
))
Assert
.
Equal
(
ServicesVSResources
.
You_must_change_the_signature
,
message
)
Assert
.
False
(
viewModel
.
CanMoveUp
)
End
Sub
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录