Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
306c2b8a
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,发现更多精彩内容 >>
提交
306c2b8a
编写于
2月 21, 2018
作者:
M
Martin Strecker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added tests for different invocation styles.
上级
5ad0dab4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
206 addition
and
0 deletion
+206
-0
src/EditorFeatures/CSharpTest/AddParameter/AddParameterTests.cs
...itorFeatures/CSharpTest/AddParameter/AddParameterTests.cs
+206
-0
未找到文件。
src/EditorFeatures/CSharpTest/AddParameter/AddParameterTests.cs
浏览文件 @
306c2b8a
...
...
@@ -1929,5 +1929,211 @@ public class T
await
TestInRegularAndScriptAsync
(
code
,
fix
,
index
:
1
);
}
[
WorkItem
(
21446
,
"https://github.com/dotnet/roslyn/issues/21446"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddParameter
)]
public
async
Task
TestInvocation_InvocationStyles_Positional_MoreThanOneArgumentToMuch
()
{
var
code
=
@"
class C
{
void M() { }
void Test()
{
[|M|](1, 2, 3, 4);
}
}"
;
var
fix0
=
@"
class C
{
void M(int v) { }
void Test()
{
M(1, 2, 3, 4);
}
}"
;
await
TestActionCountAsync
(
code
,
1
);
await
TestInRegularAndScriptAsync
(
code
,
fix0
,
index
:
0
);
}
[
WorkItem
(
21446
,
"https://github.com/dotnet/roslyn/issues/21446"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddParameter
)]
public
async
Task
TestInvocation_InvocationStyles_Positional_WithOptionalParam
()
{
// The fix places new parameter after optional parameters (which is not allowed)
// I don't see what we can do about it without also changing the call site.
// error CS1501: No overload for method 'M' takes 2 arguments
var
code
=
@"
class C
{
void M(int i = 1) { }
void Test()
{
[|M|](1, 2);
}
}"
;
// error CS1737: Optional parameters must appear after all required parameters
var
fix0
=
@"
class C
{
void M(int i = 1, int v) { }
void Test()
{
M(1, 2);
}
}"
;
await
TestInRegularAndScriptAsync
(
code
,
fix0
,
index
:
0
);
}
[
WorkItem
(
21446
,
"https://github.com/dotnet/roslyn/issues/21446"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddParameter
)]
public
async
Task
TestInvocation_InvocationStyles_Positional_WithParams
()
{
// error CS1503: Argument 1: cannot convert from 'string' to 'int'
var
code
=
@"
class C
{
void M(params int[] ints) { }
void Test()
{
M([|""text""|]);
}
}"
;
var
fix0
=
@"
class C
{
void M(string v, params int[] ints) { }
void Test()
{
M(""text"");
}
}"
;
await
TestInRegularAndScriptAsync
(
code
,
fix0
,
index
:
0
);
}
[
WorkItem
(
21446
,
"https://github.com/dotnet/roslyn/issues/21446"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddParameter
)]
public
async
Task
TestInvocation_InvocationStyles_Named_WithTypemissmatch
()
{
// error CS1503: Argument 1: cannot convert from 'string' to 'int'
var
code
=
@"
class C
{
void M(int i) { }
void Test()
{
M(i: [|""text""|]);
}
}"
;
await
TestMissingInRegularAndScriptAsync
(
code
);
}
[
WorkItem
(
21446
,
"https://github.com/dotnet/roslyn/issues/21446"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddParameter
)]
public
async
Task
TestInvocation_InvocationStyles_NamedAndPositional1
()
{
// error CS1739: The best overload for 'M' does not have a parameter named 'i2'
var
code
=
@"
class C
{
void M(int i1, string s) { }
void Test()
{
M(1, s: ""text"", [|i2|]: 0);
}
}"
;
var
fix0
=
@"
class C
{
void M(int i1, string s, int i2) { }
void Test()
{
M(1, s: ""text"", i2: 0);
}
}"
;
await
TestInRegularAndScriptAsync
(
code
,
fix0
,
index
:
0
);
}
[
WorkItem
(
21446
,
"https://github.com/dotnet/roslyn/issues/21446"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddParameter
)]
public
async
Task
TestInvocation_InvocationStyles_NamedAndPositional2
()
{
// CS1744 is not yet a supported diagnostic (just declaring the diagnostic as supported does not work)
// error CS1744: Named argument 's' specifies a parameter for which a positional argument has already been given
var
code
=
@"
class C
{
void M(string s) { }
void Test()
{
M(1, [|s|]: ""text"");
}
}"
;
await
TestMissingInRegularAndScriptAsync
(
code
);
}
[
WorkItem
(
21446
,
"https://github.com/dotnet/roslyn/issues/21446"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddParameter
)]
public
async
Task
TestInvocation_InvocationStyles_Incomplete_1
()
{
// error CS1501: No overload for method 'M' takes 1 arguments
var
code
=
@"
class C
{
void M() { }
void Test()
{
[|M|](1
}
}"
;
var
fix0
=
@"
class C
{
void M(int v) { }
void Test()
{
M(1
}
}"
;
await
TestInRegularAndScriptAsync
(
code
,
fix0
,
index
:
0
);
}
[
WorkItem
(
21446
,
"https://github.com/dotnet/roslyn/issues/21446"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddParameter
)]
public
async
Task
TestInvocation_InvocationStyles_Incomplete_2
()
{
// error CS1503: Argument 1: cannot convert from 'string' to 'int'
var
code
=
@"
class C
{
void M(int v) { }
void Test()
{
[|M|](""text"", 1
"
;
var
fix0
=
@"
class C
{
void M(string v1, int v) { }
void Test()
{
M(""text"", 1
"
;
await
TestInRegularAndScriptAsync
(
code
,
fix0
,
index
:
0
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录