Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
eeb689ef
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,发现更多精彩内容 >>
提交
eeb689ef
编写于
2月 01, 2016
作者:
G
Gen Lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reimplement IOperation's Descendants extension methods using OperationWalker
And fixed some test failure caused by this.
上级
c134d49a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
33 deletion
+47
-33
src/Compilers/CSharp/Test/Semantic/Diagnostics/OperationAnalyzerTests.cs
...Sharp/Test/Semantic/Diagnostics/OperationAnalyzerTests.cs
+8
-8
src/Compilers/Core/Portable/Compilation/OperationExtensions.cs
...ompilers/Core/Portable/Compilation/OperationExtensions.cs
+30
-12
src/Compilers/VisualBasic/Test/Semantic/Diagnostics/OperationAnalyzerTests.vb
...Basic/Test/Semantic/Diagnostics/OperationAnalyzerTests.vb
+9
-13
未找到文件。
src/Compilers/CSharp/Test/Semantic/Diagnostics/OperationAnalyzerTests.cs
浏览文件 @
eeb689ef
...
...
@@ -135,9 +135,7 @@ public void M1(int z)
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"Bexley"
).
WithLocation
(
7
,
17
),
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"M1(y + d)"
).
WithLocation
(
10
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
InvalidStatementDescriptor
.
Id
,
"goto;"
).
WithLocation
(
11
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"goto;"
).
WithLocation
(
11
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
InvalidExpressionDescriptor
.
Id
,
""
).
WithLocation
(
11
,
13
),
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
""
).
WithLocation
(
11
,
13
)
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"goto;"
).
WithLocation
(
11
,
9
)
);
}
...
...
@@ -1092,6 +1090,7 @@ class C
public void OnMumble(System.EventArgs args)
{
Mumble += new MumbleEventHandler(Mumbler);
Mumble += (s, a) => {};
Mumble(this, args);
object o = Mumble;
MumbleEventHandler d = Mumbler;
...
...
@@ -1108,11 +1107,12 @@ private void Mumbler(object sender, System.EventArgs args)
.
VerifyAnalyzerDiagnostics
(
new
DiagnosticAnalyzer
[]
{
new
MemberReferenceAnalyzer
()
},
null
,
null
,
false
,
Diagnostic
(
MemberReferenceAnalyzer
.
HandlerAddedDescriptor
.
Id
,
"Mumble += new MumbleEventHandler(Mumbler)"
).
WithLocation
(
10
,
9
),
Diagnostic
(
MemberReferenceAnalyzer
.
MethodBindingDescriptor
.
Id
,
"Mumbler"
).
WithLocation
(
10
,
42
),
Diagnostic
(
MemberReferenceAnalyzer
.
EventReferenceDescriptor
.
Id
,
"Mumble"
).
WithLocation
(
11
,
9
),
Diagnostic
(
MemberReferenceAnalyzer
.
EventReferenceDescriptor
.
Id
,
"Mumble"
).
WithLocation
(
12
,
20
),
Diagnostic
(
MemberReferenceAnalyzer
.
MethodBindingDescriptor
.
Id
,
"Mumbler"
).
WithLocation
(
13
,
32
),
Diagnostic
(
MemberReferenceAnalyzer
.
HandlerRemovedDescriptor
.
Id
,
"Mumble -= new MumbleEventHandler(Mumbler)"
).
WithLocation
(
15
,
9
),
Diagnostic
(
MemberReferenceAnalyzer
.
MethodBindingDescriptor
.
Id
,
"Mumbler"
).
WithLocation
(
15
,
42
)
Diagnostic
(
MemberReferenceAnalyzer
.
HandlerAddedDescriptor
.
Id
,
"Mumble += (s, a) => {}"
).
WithLocation
(
11
,
9
),
Diagnostic
(
MemberReferenceAnalyzer
.
EventReferenceDescriptor
.
Id
,
"Mumble"
).
WithLocation
(
12
,
9
),
Diagnostic
(
MemberReferenceAnalyzer
.
EventReferenceDescriptor
.
Id
,
"Mumble"
).
WithLocation
(
13
,
20
),
Diagnostic
(
MemberReferenceAnalyzer
.
MethodBindingDescriptor
.
Id
,
"Mumbler"
).
WithLocation
(
14
,
32
),
Diagnostic
(
MemberReferenceAnalyzer
.
HandlerRemovedDescriptor
.
Id
,
"Mumble -= new MumbleEventHandler(Mumbler)"
).
WithLocation
(
16
,
9
),
Diagnostic
(
MemberReferenceAnalyzer
.
MethodBindingDescriptor
.
Id
,
"Mumbler"
).
WithLocation
(
16
,
42
)
);
}
...
...
src/Compilers/Core/Portable/Compilation/OperationExtensions.cs
浏览文件 @
eeb689ef
...
...
@@ -16,28 +16,27 @@ public static class OperationExtensions
{
public
static
IEnumerable
<
IOperation
>
Descendants
(
this
IOperation
operation
)
{
var
searchable
=
operation
as
IOperationSearchable
;
if
(
searchable
!=
null
)
{
return
searchable
.
Descendants
();
}
else
if
(
operation
==
null
)
{
return
SpecializedCollections
.
EmptyEnumerable
<
IOperation
>();
}
var
list
=
new
List
<
IOperation
>();
var
collector
=
new
OperationCollector
(
list
);
collector
.
Visit
(
operation
);
list
.
RemoveAt
(
0
);
return
list
;
}
public
static
IEnumerable
<
IOperation
>
DescendantsAndSelf
(
this
IOperation
operation
)
{
var
searchable
=
operation
as
IOperationSearchable
;
if
(
searchable
!=
null
)
{
return
searchable
.
DescendantsAndSelf
();
}
else
if
(
operation
==
null
)
{
return
SpecializedCollections
.
EmptyEnumerable
<
IOperation
>();
}
var
list
=
new
List
<
IOperation
>();
var
collector
=
new
OperationCollector
(
list
);
collector
.
Visit
(
operation
);
return
list
;
}
public
static
IOperation
GetRootOperation
(
this
ISymbol
symbol
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
...
...
@@ -52,6 +51,25 @@ public static IOperation GetRootOperation(this ISymbol symbol, CancellationToken
return
null
;
}
}
private
sealed
class
OperationCollector
:
OperationWalker
{
private
readonly
List
<
IOperation
>
_list
;
public
OperationCollector
(
List
<
IOperation
>
list
)
{
_list
=
list
;
}
public
override
void
Visit
(
IOperation
operation
)
{
if
(
operation
!=
null
)
{
_list
.
Add
(
operation
);
}
base
.
Visit
(
operation
);
}
}
}
internal
interface
ISymbolWithOperation
...
...
src/Compilers/VisualBasic/Test/Semantic/Diagnostics/OperationAnalyzerTests.vb
浏览文件 @
eeb689ef
...
...
@@ -123,18 +123,12 @@ End Class
comp
.
VerifyAnalyzerDiagnostics
({
New
BadStuffTestAnalyzer
},
Nothing
,
Nothing
,
False
,
Diagnostic
(
BadStuffTestAnalyzer
.
InvalidExpressionDescriptor
.
Id
,
"Framitz()"
).
WithLocation
(
3
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"Framitz()"
).
WithLocation
(
3
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
InvalidExpressionDescriptor
.
Id
,
"Framitz"
).
WithLocation
(
3
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"Framitz"
).
WithLocation
(
3
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
InvalidExpressionDescriptor
.
Id
,
"Bexley()"
).
WithLocation
(
4
,
28
),
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"Bexley()"
).
WithLocation
(
4
,
28
),
Diagnostic
(
BadStuffTestAnalyzer
.
InvalidExpressionDescriptor
.
Id
,
"Bexley"
).
WithLocation
(
4
,
28
),
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"Bexley"
).
WithLocation
(
4
,
28
),
Diagnostic
(
BadStuffTestAnalyzer
.
InvalidExpressionDescriptor
.
Id
,
"M1(d)"
).
WithLocation
(
7
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"M1(d)"
).
WithLocation
(
7
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
InvalidStatementDescriptor
.
Id
,
"Goto"
).
WithLocation
(
8
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"Goto"
).
WithLocation
(
8
,
9
),
Diagnostic
(
BadStuffTestAnalyzer
.
InvalidExpressionDescriptor
.
Id
,
""
).
WithLocation
(
8
,
13
),
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
""
).
WithLocation
(
8
,
13
))
Diagnostic
(
BadStuffTestAnalyzer
.
IsInvalidDescriptor
.
Id
,
"Goto"
).
WithLocation
(
8
,
9
))
End
Sub
<
Fact
>
...
...
@@ -1145,6 +1139,8 @@ Class C
Public
Sub
OnMumble
(
args
As
System
.
EventArgs
)
AddHandler
Mumble
,
New
MumbleEventHandler
(
AddressOf
Mumbler
)
AddHandler
Mumble
,
New
MumbleEventHandler
(
Sub
(
s
As
Object
,
a
As
System
.
EventArgs
)
End
Sub
)
RaiseEvent
Mumble
(
Me
,
args
)
' Dim o As object = AddressOf Mumble
Dim
d
As
MumbleEventHandler
=
AddressOf
Mumbler
...
...
@@ -1163,13 +1159,13 @@ End Class
comp
.
VerifyDiagnostics
()
comp
.
VerifyAnalyzerDiagnostics
({
New
MemberReferenceAnalyzer
},
Nothing
,
Nothing
,
False
,
Diagnostic
(
MemberReferenceAnalyzer
.
HandlerAddedDescriptor
.
Id
,
"AddHandler Mumble, New MumbleEventHandler(AddressOf Mumbler)"
).
WithLocation
(
7
,
9
),
Diagnostic
(
MemberReferenceAnalyzer
.
EventReferenceDescriptor
.
Id
,
"Mumble"
).
WithLocation
(
7
,
20
),
Diagnostic
(
MemberReferenceAnalyzer
.
MethodBindingDescriptor
.
Id
,
"AddressOf Mumbler"
).
WithLocation
(
7
,
51
),
Diagnostic
(
MemberReferenceAnalyzer
.
FieldReferenceDescriptor
.
Id
,
"Mumble"
).
WithLocation
(
8
,
20
),
Diagnostic
(
MemberReferenceAnalyzer
.
MethodBindingDescriptor
.
Id
,
"AddressOf Mumbler"
).
WithLocation
(
10
,
39
),
Diagnostic
(
MemberReferenceAnalyzer
.
HandlerRemovedDescriptor
.
Id
,
"RemoveHandler Mumble, AddressOf Mumbler"
).
WithLocation
(
12
,
9
),
Diagnostic
(
MemberReferenceAnalyzer
.
EventReferenceDescriptor
.
Id
,
"Mumble"
).
WithLocation
(
12
,
23
),
Diagnostic
(
MemberReferenceAnalyzer
.
MethodBindingDescriptor
.
Id
,
"AddressOf Mumbler"
).
WithLocation
(
12
,
31
))
Diagnostic
(
"HandlerAdded"
,
"AddHandler Mumble, New MumbleEventHandler(Sub(s As Object, a As System.EventArgs)
End Sub)"
).
WithLocation
(
8
,
9
),
Diagnostic
(
MemberReferenceAnalyzer
.
FieldReferenceDescriptor
.
Id
,
"Mumble"
).
WithLocation
(
10
,
20
),
Diagnostic
(
MemberReferenceAnalyzer
.
MethodBindingDescriptor
.
Id
,
"AddressOf Mumbler"
).
WithLocation
(
12
,
39
),
Diagnostic
(
MemberReferenceAnalyzer
.
HandlerRemovedDescriptor
.
Id
,
"RemoveHandler Mumble, AddressOf Mumbler"
).
WithLocation
(
14
,
9
),
Diagnostic
(
MemberReferenceAnalyzer
.
MethodBindingDescriptor
.
Id
,
"AddressOf Mumbler"
).
WithLocation
(
14
,
31
))
End
Sub
<
Fact
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录