Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1fee560e
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,发现更多精彩内容 >>
提交
1fee560e
编写于
9月 03, 2015
作者:
D
Dustin Campbell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for RemoveHandler statements in IMethodXML generation
上级
aec42746
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
357 addition
and
11 deletion
+357
-11
src/VisualStudio/Core/Test/CodeModel/MethodXML/MethodXMLTests_VBStatements.vb
...e/Test/CodeModel/MethodXML/MethodXMLTests_VBStatements.vb
+335
-0
src/VisualStudio/VisualBasic/Impl/CodeModel/MethodXML/MethodXmlBuilder.vb
.../VisualBasic/Impl/CodeModel/MethodXML/MethodXmlBuilder.vb
+22
-11
未找到文件。
src/VisualStudio/Core/Test/CodeModel/MethodXML/MethodXMLTests_VBStatements.vb
浏览文件 @
1fee560e
...
...
@@ -340,5 +340,340 @@ End Class
Test
(
definition
,
expected
)
End
Sub
<
ConditionalFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModelMethodXml
)
>
Public
Sub
VBStatements_RemoveHandler1
()
Dim
definition
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
AssemblyName
=
"Test"
>
<
CompilationOptions
RootNamespace
=
"N"
/>
<
Document
>
Imports
System
Class
C
Event
E
As
EventHandler
Sub
Handler
(
sender
As
Object
,
e
As
EventArgs
)
End
Sub
$$
Sub
M
()
RemoveHandler
E
,
AddressOf
Handler
End
Sub
End
Class
</
Document
>
</
Project
>
</
Workspace
>
Dim
expected
=
<
Block
>
<
ExpressionStatement
line
=
"10"
>
<
Expression
>
<
MethodCall
>
<
Expression
>
<
NameRef
variablekind
=
"method"
name
=
"remove_E"
>
<
Expression
>
<
ThisReference
/>
</
Expression
>
</
NameRef
>
</
Expression
>
<
Type
implicit
=
"yes"
>
N
.
C
,
Test
,
Version
=
0.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
null
</
Type
>
<
Argument
>
<
Expression
>
<
NewDelegate
name
=
"Handler"
>
<
Type
implicit
=
"yes"
>
System
.
EventHandler
,
mscorlib
,
Version
=
4.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
b77a5c561934e089
</
Type
>
<
Expression
>
<
ThisReference
/>
</
Expression
>
<
Type
implicit
=
"yes"
>
N
.
C
,
Test
,
Version
=
0.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
null
</
Type
>
</
NewDelegate
>
</
Expression
>
</
Argument
>
</
MethodCall
>
</
Expression
>
</
ExpressionStatement
>
</
Block
>
Test
(
definition
,
expected
)
End
Sub
<
ConditionalFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModelMethodXml
)
>
Public
Sub
VBStatements_RemoveHandler2
()
Dim
definition
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
AssemblyName
=
"Test"
>
<
CompilationOptions
RootNamespace
=
"N"
/>
<
Document
>
Imports
System
Class
B
Event
E
As
EventHandler
End
Class
Class
C
Dim
b
As
New
B
Sub
Handler
(
sender
As
Object
,
e
As
EventArgs
)
End
Sub
$$
Sub
M
()
RemoveHandler
b
.
E
,
AddressOf
Handler
End
Sub
End
Class
</
Document
>
</
Project
>
</
Workspace
>
Dim
expected
=
<
Block
>
<
ExpressionStatement
line
=
"14"
>
<
Expression
>
<
MethodCall
>
<
Expression
>
<
NameRef
variablekind
=
"method"
name
=
"remove_E"
>
<
Expression
>
<
NameRef
variablekind
=
"field"
name
=
"b"
fullname
=
"N.C.b"
>
<
Expression
>
<
ThisReference
/>
</
Expression
>
</
NameRef
>
</
Expression
>
</
NameRef
>
</
Expression
>
<
Type
implicit
=
"yes"
>
N
.
B
,
Test
,
Version
=
0.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
null
</
Type
>
<
Argument
>
<
Expression
>
<
NewDelegate
name
=
"Handler"
>
<
Type
implicit
=
"yes"
>
System
.
EventHandler
,
mscorlib
,
Version
=
4.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
b77a5c561934e089
</
Type
>
<
Expression
>
<
ThisReference
/>
</
Expression
>
<
Type
implicit
=
"yes"
>
N
.
C
,
Test
,
Version
=
0.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
null
</
Type
>
</
NewDelegate
>
</
Expression
>
</
Argument
>
</
MethodCall
>
</
Expression
>
</
ExpressionStatement
>
</
Block
>
Test
(
definition
,
expected
)
End
Sub
<
ConditionalFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModelMethodXml
)
>
Public
Sub
VBStatements_RemoveHandler3
()
Dim
definition
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
AssemblyName
=
"Test"
>
<
CompilationOptions
RootNamespace
=
"N"
/>
<
Document
>
Imports
System
Class
B
Event
E
As
EventHandler
Sub
Handler
(
sender
As
Object
,
e
As
EventArgs
)
End
Sub
End
Class
Class
C
Dim
b
As
New
B
$$
Sub
M
()
RemoveHandler
b
.
E
,
AddressOf
b
.
Handler
End
Sub
End
Class
</
Document
>
</
Project
>
</
Workspace
>
Dim
expected
=
<
Block
>
<
ExpressionStatement
line
=
"14"
>
<
Expression
>
<
MethodCall
>
<
Expression
>
<
NameRef
variablekind
=
"method"
name
=
"remove_E"
>
<
Expression
>
<
NameRef
variablekind
=
"field"
name
=
"b"
fullname
=
"N.C.b"
>
<
Expression
>
<
ThisReference
/>
</
Expression
>
</
NameRef
>
</
Expression
>
</
NameRef
>
</
Expression
>
<
Type
implicit
=
"yes"
>
N
.
B
,
Test
,
Version
=
0.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
null
</
Type
>
<
Argument
>
<
Expression
>
<
NewDelegate
name
=
"Handler"
>
<
Type
implicit
=
"yes"
>
System
.
EventHandler
,
mscorlib
,
Version
=
4.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
b77a5c561934e089
</
Type
>
<
Expression
>
<
NameRef
variablekind
=
"field"
name
=
"b"
fullname
=
"N.C.b"
>
<
Expression
>
<
ThisReference
/>
</
Expression
>
</
NameRef
>
</
Expression
>
<
Type
implicit
=
"yes"
>
N
.
B
,
Test
,
Version
=
0.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
null
</
Type
>
</
NewDelegate
>
</
Expression
>
</
Argument
>
</
MethodCall
>
</
Expression
>
</
ExpressionStatement
>
</
Block
>
Test
(
definition
,
expected
)
End
Sub
<
ConditionalFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModelMethodXml
)
>
Public
Sub
VBStatements_RemoveHandler4
()
Dim
definition
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
AssemblyName
=
"Test"
>
<
CompilationOptions
RootNamespace
=
"N"
/>
<
Document
>
Imports
System
Class
A
Event
E
As
EventHandler
End
Class
Class
B
Property
A
As
New
A
Sub
Handler
(
sender
As
Object
,
e
As
EventArgs
)
End
Sub
End
Class
Class
C
Dim
b
As
New
B
$$
Sub
M
()
RemoveHandler
b
.
A
.
E
,
AddressOf
b
.
Handler
End
Sub
End
Class
</
Document
>
</
Project
>
</
Workspace
>
Dim
expected
=
<
Block
>
<
ExpressionStatement
line
=
"18"
>
<
Expression
>
<
MethodCall
>
<
Expression
>
<
NameRef
variablekind
=
"method"
name
=
"remove_E"
>
<
Expression
>
<
NameRef
variablekind
=
"property"
name
=
"A"
fullname
=
"N.B.A"
>
<
Expression
>
<
NameRef
variablekind
=
"field"
name
=
"b"
fullname
=
"N.C.b"
>
<
Expression
>
<
ThisReference
/>
</
Expression
>
</
NameRef
>
</
Expression
>
</
NameRef
>
</
Expression
>
</
NameRef
>
</
Expression
>
<
Type
implicit
=
"yes"
>
N
.
A
,
Test
,
Version
=
0.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
null
</
Type
>
<
Argument
>
<
Expression
>
<
NewDelegate
name
=
"Handler"
>
<
Type
implicit
=
"yes"
>
System
.
EventHandler
,
mscorlib
,
Version
=
4.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
b77a5c561934e089
</
Type
>
<
Expression
>
<
NameRef
variablekind
=
"field"
name
=
"b"
fullname
=
"N.C.b"
>
<
Expression
>
<
ThisReference
/>
</
Expression
>
</
NameRef
>
</
Expression
>
<
Type
implicit
=
"yes"
>
N
.
B
,
Test
,
Version
=
0.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
null
</
Type
>
</
NewDelegate
>
</
Expression
>
</
Argument
>
</
MethodCall
>
</
Expression
>
</
ExpressionStatement
>
</
Block
>
Test
(
definition
,
expected
)
End
Sub
<
ConditionalFact
(
GetType
(
x86
)),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeModelMethodXml
)
>
Public
Sub
VBStatements_RemoveHandler5
()
Dim
definition
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
AssemblyName
=
"Test"
>
<
CompilationOptions
RootNamespace
=
"N"
/>
<
Document
>
Imports
System
Class
A
Sub
Handler
(
sender
As
Object
,
e
As
EventArgs
)
End
Sub
End
Class
Class
B
Property
A
As
New
A
Event
E
As
EventHandler
End
Class
Class
C
Dim
b
As
New
B
$$
Sub
M
()
RemoveHandler
b
.
E
,
AddressOf
b
.
A
.
Handler
End
Sub
End
Class
</
Document
>
</
Project
>
</
Workspace
>
Dim
expected
=
<
Block
>
<
ExpressionStatement
line
=
"18"
>
<
Expression
>
<
MethodCall
>
<
Expression
>
<
NameRef
variablekind
=
"method"
name
=
"remove_E"
>
<
Expression
>
<
NameRef
variablekind
=
"field"
name
=
"b"
fullname
=
"N.C.b"
>
<
Expression
>
<
ThisReference
/>
</
Expression
>
</
NameRef
>
</
Expression
>
</
NameRef
>
</
Expression
>
<
Type
implicit
=
"yes"
>
N
.
B
,
Test
,
Version
=
0.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
null
</
Type
>
<
Argument
>
<
Expression
>
<
NewDelegate
name
=
"Handler"
>
<
Type
implicit
=
"yes"
>
System
.
EventHandler
,
mscorlib
,
Version
=
4.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
b77a5c561934e089
</
Type
>
<
Expression
>
<
NameRef
variablekind
=
"property"
name
=
"A"
fullname
=
"N.B.A"
>
<
Expression
>
<
NameRef
variablekind
=
"field"
name
=
"b"
fullname
=
"N.C.b"
>
<
Expression
>
<
ThisReference
/>
</
Expression
>
</
NameRef
>
</
Expression
>
</
NameRef
>
</
Expression
>
<
Type
implicit
=
"yes"
>
N
.
A
,
Test
,
Version
=
0.0
.
0.0,
Culture
=
neutral
,
PublicKeyToken
=
null
</
Type
>
</
NewDelegate
>
</
Expression
>
</
Argument
>
</
MethodCall
>
</
Expression
>
</
ExpressionStatement
>
</
Block
>
Test
(
definition
,
expected
)
End
Sub
End
Class
End
Namespace
\ No newline at end of file
src/VisualStudio/VisualBasic/Impl/CodeModel/MethodXML/MethodXmlBuilder.vb
浏览文件 @
1fee560e
...
...
@@ -40,8 +40,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.CodeModel.MethodXm
success
=
TryGenerateCall
(
DirectCast
(
statement
,
CallStatementSyntax
))
Case
SyntaxKind
.
ExpressionStatement
success
=
TryGenerateExpressionStatement
(
DirectCast
(
statement
,
ExpressionStatementSyntax
))
Case
SyntaxKind
.
AddHandlerStatement
success
=
TryGenerateAddHandlerStatement
(
DirectCast
(
statement
,
AddRemoveHandlerStatementSyntax
))
Case
SyntaxKind
.
AddHandlerStatement
,
SyntaxKind
.
RemoveHandlerStatement
success
=
TryGenerateAddOrRemoveHandlerStatement
(
DirectCast
(
statement
,
AddRemoveHandlerStatementSyntax
))
End
Select
If
Not
success
Then
...
...
@@ -114,20 +115,30 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.CodeModel.MethodXm
End
Using
End
Function
Private
Function
TryGenerateAddHandlerStatement
(
addHandlerStatement
As
AddRemoveHandlerStatementSyntax
)
As
Boolean
Private
Function
TryGenerateAdd
OrRemove
HandlerStatement
(
addHandlerStatement
As
AddRemoveHandlerStatementSyntax
)
As
Boolean
' AddHandler statements are represented as invocations of an event's add_* method.
' RemoveHandler statements are represented as invocations of an event's remove_* method.
Dim
eventExpression
=
addHandlerStatement
.
EventExpression
Dim
eventSymbol
=
TryCast
(
SemanticModel
.
GetSymbolInfo
(
eventExpression
).
Symbol
,
IEventSymbol
)
Dim
eventAccessor
As
IMethodSymbol
If
addHandlerStatement
.
Kind
()
=
SyntaxKind
.
AddHandlerStatement
Then
eventAccessor
=
eventSymbol
?
.
AddMethod
ElseIf
addHandlerStatement
.
Kind
()
=
SyntaxKind
.
RemoveHandlerStatement
eventAccessor
=
eventSymbol
?
.
RemoveMethod
Else
eventAccessor
=
Nothing
End
If
If
eventAccessor
Is
Nothing
Then
Return
False
End
If
Using
ExpressionStatementTag
(
GetLineNumber
(
addHandlerStatement
))
Using
ExpressionTag
()
Using
MethodCallTag
()
Dim
eventExpression
=
addHandlerStatement
.
EventExpression
Dim
eventSymbol
=
TryCast
(
SemanticModel
.
GetSymbolInfo
(
eventExpression
).
Symbol
,
IEventSymbol
)
If
eventSymbol
?
.
AddMethod
Is
Nothing
Then
Return
False
End
If
If
Not
TryGenerateExpression
(
eventExpression
,
eventSymbol
.
AddMethod
,
generateAttributes
:
=
True
)
Then
If
Not
TryGenerateExpression
(
eventExpression
,
eventAccessor
,
generateAttributes
:
=
True
)
Then
Return
False
End
If
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录