Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET
Roslyn
提交
ab544702
R
Roslyn
项目概览
dotNET
/
Roslyn
通知
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,发现更多精彩内容 >>
提交
ab544702
编写于
2月 20, 2020
作者:
R
Rikki Gibson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix test gap and delete outdated prototype comment
上级
99c25e68
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
84 addition
and
5 deletion
+84
-5
src/Compilers/CSharp/Portable/Symbols/Source/SourceMethodSymbolWithAttributes.cs
...rtable/Symbols/Source/SourceMethodSymbolWithAttributes.cs
+0
-3
src/Compilers/CSharp/Test/Semantic/Semantics/LocalFunctionTests.cs
...lers/CSharp/Test/Semantic/Semantics/LocalFunctionTests.cs
+55
-2
src/Compilers/CSharp/Test/Semantic/Semantics/LookupTests.cs
src/Compilers/CSharp/Test/Semantic/Semantics/LookupTests.cs
+29
-0
未找到文件。
src/Compilers/CSharp/Portable/Symbols/Source/SourceMethodSymbolWithAttributes.cs
浏览文件 @
ab544702
...
...
@@ -971,9 +971,6 @@ internal override bool HasSpecialName
internal
sealed
override
bool
IsDirectlyExcludedFromCodeCoverage
=>
GetDecodedWellKnownAttributeData
()?.
HasExcludeFromCodeCoverageAttribute
==
true
;
// PROTOTYPE(local-function-attributes): security-related properties perhaps should be
// overridden in SynthesizedMethodBaseSymbol in order to work with local functions
internal
override
bool
RequiresSecurityObject
{
get
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/LocalFunctionTests.cs
浏览文件 @
ab544702
...
...
@@ -370,7 +370,8 @@ static void M()
[
InlineData
(
"[return: A] void local() { }"
)]
[
InlineData
(
"void local([A] int i) { }"
)]
[
InlineData
(
"void local<[A]T>() {}"
)]
public
void
LocalFunctionAttribute_SpeculativeSemanticModel
(
string
localFunction
)
[
InlineData
(
"[A] int x = 123;"
)]
public
void
LocalFunctionAttribute_SpeculativeSemanticModel
(
string
statement
)
{
string
text
=
$@"
using System;
...
...
@@ -380,7 +381,7 @@ class C
{{
static
void
M
()
{{
{
localFunction
}
{
statement
}
}}
}}
"
;
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
text
);
...
...
@@ -410,6 +411,58 @@ static void M()
Assert
.
Equal
(
attrType
,
info
.
Symbol
);
}
[
Theory
]
[
InlineData
(
@"[Attr(42, Name = ""hello"")] void local() { }"
)]
[
InlineData
(
@"[return: Attr(42, Name = ""hello"")] void local() { }"
)]
[
InlineData
(
@"void local([Attr(42, Name = ""hello"")] int i) { }"
)]
[
InlineData
(
@"void local<[Attr(42, Name = ""hello"")]T>() {}"
)]
[
InlineData
(
@"[Attr(42, Name = ""hello"")] int x = 123;"
)]
public
void
LocalFunctionAttribute_Argument_SemanticModel
(
string
statement
)
{
var
text
=
$@"
class Attr
{{
public
Attr
(
int
id
)
{{
}}
public
string
Name
{{
get
;
set
;
}}
}}
class C
{{
static
void
M
()
{{
{
statement
}
}}
}}
"
;
var
tree
=
SyntaxFactory
.
ParseSyntaxTree
(
text
,
options
:
TestOptions
.
RegularPreview
);
var
comp
=
CreateCompilation
(
tree
);
var
model
=
comp
.
GetSemanticModel
(
tree
,
ignoreAccessibility
:
true
);
validate
(
model
,
tree
);
var
newTree
=
SyntaxFactory
.
ParseSyntaxTree
(
text
+
" "
,
options
:
TestOptions
.
RegularPreview
);
var
mMethod
=
(
MethodDeclarationSyntax
)
newTree
.
FindNodeOrTokenByKind
(
SyntaxKind
.
MethodDeclaration
,
occurrence
:
1
).
AsNode
();
Assert
.
True
(
model
.
TryGetSpeculativeSemanticModelForMethodBody
(
mMethod
.
Body
.
SpanStart
,
mMethod
,
out
var
newModel
));
validate
(
newModel
,
newTree
);
static
void
validate
(
SemanticModel
model
,
SyntaxTree
tree
)
{
var
attributeSyntax
=
tree
.
GetRoot
().
DescendantNodes
().
OfType
<
AttributeSyntax
>().
Single
();
var
attrArgs
=
attributeSyntax
.
ArgumentList
.
Arguments
;
var
attrArg0
=
attrArgs
[
0
].
Expression
;
Assert
.
Null
(
model
.
GetSymbolInfo
(
attrArg0
).
Symbol
);
var
argType0
=
model
.
GetTypeInfo
(
attrArg0
).
Type
;
Assert
.
Equal
(
SpecialType
.
System_Int32
,
argType0
.
SpecialType
);
var
attrArg1
=
attrArgs
[
1
].
Expression
;
Assert
.
Null
(
model
.
GetSymbolInfo
(
attrArg1
).
Symbol
);
var
argType1
=
model
.
GetTypeInfo
(
attrArg1
).
Type
;
Assert
.
Equal
(
SpecialType
.
System_String
,
argType1
.
SpecialType
);
}
}
[
Fact
]
public
void
LocalFunctionAttribute_OnFunction
()
{
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/LookupTests.cs
浏览文件 @
ab544702
...
...
@@ -1066,6 +1066,35 @@ static void local1(int z)
Assert
.
Contains
(
"System.Int32 y"
,
lookupSymbols
);
}
[
Fact
]
public
void
LookupInsideIncompleteStatementAttribute
()
{
var
testSrc
=
@"
using System;
class Program
{
const int w = 0451;
void M()
{
int x = 42;
const int y = 123;
[ObsoleteAttribute(/*pos*/
int
}
}
"
;
var
lookupNames
=
GetLookupNames
(
testSrc
);
var
lookupSymbols
=
GetLookupSymbols
(
testSrc
).
Select
(
e
=>
e
.
ToTestDisplayString
()).
ToList
();
Assert
.
Contains
(
"w"
,
lookupNames
);
Assert
.
Contains
(
"y"
,
lookupNames
);
Assert
.
Contains
(
"System.Int32 Program.w"
,
lookupSymbols
);
Assert
.
Contains
(
"System.Int32 y"
,
lookupSymbols
);
}
[
WorkItem
(
541909
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541909"
)]
[
Fact
]
public
void
LookupFromRangeVariableAfterFromClause
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录