Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
20926a8c
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,发现更多精彩内容 >>
提交
20926a8c
编写于
12月 15, 2016
作者:
A
AlekseyTs
提交者:
GitHub
12月 15, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15886 from AlekseyTs/Issue15732
Do not mark argument values as bad due to issues with names.
上级
cf920d44
05755b38
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
98 addition
and
8 deletion
+98
-8
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
+0
-4
src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs
src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs
+6
-1
src/Compilers/CSharp/Test/Semantic/Semantics/NamedAndOptionalTests.cs
...s/CSharp/Test/Semantic/Semantics/NamedAndOptionalTests.cs
+5
-1
src/Compilers/CSharp/Test/Semantic/Semantics/OutVarTests.cs
src/Compilers/CSharp/Test/Semantic/Semantics/OutVarTests.cs
+78
-0
src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs
...lers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs
+9
-2
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
浏览文件 @
20926a8c
...
...
@@ -2374,8 +2374,6 @@ internal GlobalExpressionVariable LookupDeclaredField(SyntaxNode node, string id
hadError
=
true
;
}
boundArgumentExpression
=
ToBadExpression
(
boundArgumentExpression
);
}
result
.
Names
.
Add
(
nameColonSyntax
.
Name
);
...
...
@@ -2390,8 +2388,6 @@ internal GlobalExpressionVariable LookupDeclaredField(SyntaxNode node, string id
hadError
=
true
;
}
boundArgumentExpression
=
ToBadExpression
(
boundArgumentExpression
);
result
.
Names
.
Add
(
null
);
}
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs
浏览文件 @
20926a8c
...
...
@@ -2135,7 +2135,12 @@ static void M()
}"
;
CreateCompilationWithMscorlib
(
source
).
VerifyDiagnostics
(
// (7,13): error CS1740: Named argument 'arg' cannot be specified multiple times
Diagnostic
(
ErrorCode
.
ERR_DuplicateNamedArgument
,
"arg"
).
WithArguments
(
"arg"
).
WithLocation
(
7
,
13
));
// arg: null);
Diagnostic
(
ErrorCode
.
ERR_DuplicateNamedArgument
,
"arg"
).
WithArguments
(
"arg"
).
WithLocation
(
7
,
13
),
// (5,9): error CS1501: No overload for method 'M' takes 3 arguments
// M("",
Diagnostic
(
ErrorCode
.
ERR_BadArgCount
,
"M"
).
WithArguments
(
"M"
,
"3"
).
WithLocation
(
5
,
9
)
);
}
[
WorkItem
(
543820
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543820"
)]
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/NamedAndOptionalTests.cs
浏览文件 @
20926a8c
...
...
@@ -174,7 +174,11 @@ public void M()
Diagnostic
(
ErrorCode
.
ERR_BadNamedArgument
,
"optParam3"
).
WithArguments
(
"Foo"
,
"optParam3"
).
WithLocation
(
37
,
15
),
// (39,30): error CS1738: Named argument specifications must appear after all fixed arguments have been specified
// c.Foo(optArg1: 3333, 11111);
Diagnostic
(
ErrorCode
.
ERR_NamedArgumentSpecificationBeforeFixedArgument
,
"11111"
).
WithLocation
(
39
,
30
));
Diagnostic
(
ErrorCode
.
ERR_NamedArgumentSpecificationBeforeFixedArgument
,
"11111"
).
WithLocation
(
39
,
30
),
// (39,15): error CS1739: The best overload for 'Foo' does not have a parameter named 'optArg1'
// c.Foo(optArg1: 3333, 11111);
Diagnostic
(
ErrorCode
.
ERR_BadNamedArgument
,
"optArg1"
).
WithArguments
(
"Foo"
,
"optArg1"
).
WithLocation
(
39
,
15
)
);
}
[
Fact
]
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/OutVarTests.cs
浏览文件 @
20926a8c
...
...
@@ -18058,6 +18058,84 @@ static int Test1(out int x)
Assert.Equal("System.Int32", model.GetTypeInfo(yRef).Type.ToTestDisplayString());
}
[Fact]
[WorkItem(15732, "https://github.com/dotnet/roslyn/issues/15732")]
public void LocalVariableTypeInferenceAndOutVar_06()
{
var text = @"
public class Cls
{
public static void Main()
{
Test1(x: 1, out var y);
System.Console.WriteLine(y);
}
static void Test1(int x, ref int y)
{
}
}";
var compilation = CreateCompilationWithMscorlib(text,
options: TestOptions.ReleaseExe,
parseOptions: TestOptions.Regular);
compilation.VerifyDiagnostics(
// (6,21): error CS1738: Named argument specifications must appear after all fixed arguments have been specified
// Test1(x: 1, out var y);
Diagnostic(ErrorCode.ERR_NamedArgumentSpecificationBeforeFixedArgument, "out var y").WithLocation(6, 21),
// (6,25): error CS1620: Argument 2 must be passed with the 'ref' keyword
// Test1(x: 1, out var y);
Diagnostic(ErrorCode.ERR_BadArgRef, "var y").WithArguments("2", "ref").WithLocation(6, 25)
);
var tree = compilation.SyntaxTrees.Single();
var model = compilation.GetSemanticModel(tree);
var yDecl = GetDeclaration(tree, "y");
VerifyModelForOutVar(model, yDecl, GetReferences(tree, "y").ToArray());
}
[Fact]
[WorkItem(15732, "https://github.com/dotnet/roslyn/issues/15732")]
public void LocalVariableTypeInferenceAndOutVar_07()
{
var text = @"
public class Cls
{
public static void Main()
{
int x = 0;
Test1(y: ref x, y: out var y);
System.Console.WriteLine(y);
}
static void Test1(int x, ref int y)
{
}
}";
var compilation = CreateCompilationWithMscorlib(text,
options: TestOptions.ReleaseExe,
parseOptions: TestOptions.Regular);
compilation.VerifyDiagnostics(
// (7,25): error CS1740: Named argument 'y' cannot be specified multiple times
// Test1(y: ref x, y: out var y);
Diagnostic(ErrorCode.ERR_DuplicateNamedArgument, "y").WithArguments("y").WithLocation(7, 25),
// (7,9): error CS7036: There is no argument given that corresponds to the required formal parameter 'x' of 'Cls.Test1(int, ref int)'
// Test1(y: ref x, y: out var y);
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "Test1").WithArguments("x", "Cls.Test1(int, ref int)").WithLocation(7, 9)
);
var tree = compilation.SyntaxTrees.Single();
var model = compilation.GetSemanticModel(tree);
var yDecl = GetDeclaration(tree, "y");
var yRef = GetReferences(tree, "y").ToArray();
Assert.Equal(3, yRef.Length);
Assert.Equal("System.Console.WriteLine(y)", yRef[2].Parent.Parent.Parent.ToString());
VerifyModelForOutVar(model, yDecl, yRef[2]);
}
[Fact, WorkItem(13219, "https://github.com/dotnet/roslyn/issues/13219")]
public void IndexingDynamic()
{
src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs
浏览文件 @
20926a8c
...
...
@@ -15738,8 +15738,15 @@ public static int Main()
public static void Test(int age , string Name)
{ }
}";
DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text,
new ErrorDescription[] { new ErrorDescription { Code = 1740, Line = 6, Column = 29 } });
var compilation = CSharpTestBase.CreateCompilationWithMscorlib(text);
compilation.VerifyDiagnostics(
// (6,29): error CS1740: Named argument 'Name' cannot be specified multiple times
// Test(Name: "5", Name: "");
Diagnostic(ErrorCode.ERR_DuplicateNamedArgument, "Name").WithArguments("Name").WithLocation(6, 29),
// (6,13): error CS7036: There is no argument given that corresponds to the required formal parameter 'age' of 'C.Test(int, string)'
// Test(Name: "5", Name: "");
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "Test").WithArguments("age", "C.Test(int, string)").WithLocation(6, 13)
);
}
[Fact]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录