Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
73553c7c
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,发现更多精彩内容 >>
提交
73553c7c
编写于
8月 08, 2016
作者:
J
John Hamby
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Instrument implicit constructors for VB.
上级
112e1a41
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
156 addition
and
3 deletion
+156
-3
src/Compilers/VisualBasic/Portable/Lowering/Instrumentation/DynamicAnalysisInjector.vb
...table/Lowering/Instrumentation/DynamicAnalysisInjector.vb
+7
-3
src/Compilers/VisualBasic/Test/Emit/Emit/DynamicAnalysis/DynamicAnalysisResourceTests.vb
...Emit/Emit/DynamicAnalysis/DynamicAnalysisResourceTests.vb
+65
-0
src/Compilers/VisualBasic/Test/Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.vb
.../Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.vb
+84
-0
未找到文件。
src/Compilers/VisualBasic/Portable/Lowering/Instrumentation/DynamicAnalysisInjector.vb
浏览文件 @
73553c7c
...
@@ -30,7 +30,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
...
@@ -30,7 +30,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Public
Shared
Function
TryCreate
(
method
As
MethodSymbol
,
methodBody
As
BoundStatement
,
methodBodyFactory
As
SyntheticBoundNodeFactory
,
diagnostics
As
DiagnosticBag
,
debugDocumentProvider
As
DebugDocumentProvider
,
previous
As
Instrumenter
)
As
DynamicAnalysisInjector
Public
Shared
Function
TryCreate
(
method
As
MethodSymbol
,
methodBody
As
BoundStatement
,
methodBodyFactory
As
SyntheticBoundNodeFactory
,
diagnostics
As
DiagnosticBag
,
debugDocumentProvider
As
DebugDocumentProvider
,
previous
As
Instrumenter
)
As
DynamicAnalysisInjector
' Do not instrument implicitly-declared methods.
' Do not instrument implicitly-declared methods.
If
Not
method
.
IsImplicitlyDeclared
Then
If
Not
method
.
IsImplicitlyDeclared
OrElse
method
.
IsAnyConstructor
Then
Dim
createPayload
As
MethodSymbol
=
GetCreatePayload
(
methodBodyFactory
.
Compilation
,
methodBody
.
Syntax
,
diagnostics
)
Dim
createPayload
As
MethodSymbol
=
GetCreatePayload
(
methodBodyFactory
.
Compilation
,
methodBody
.
Syntax
,
diagnostics
)
' Do not instrument any methods if CreatePayload is not present.
' Do not instrument any methods if CreatePayload is not present.
...
@@ -70,7 +70,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
...
@@ -70,7 +70,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' The first point indicates entry into the method and has the span of the method definition.
' The first point indicates entry into the method and has the span of the method definition.
Dim
bodySyntax
As
VisualBasicSyntaxNode
=
methodBody
.
Syntax
Dim
bodySyntax
As
VisualBasicSyntaxNode
=
methodBody
.
Syntax
_methodEntryInstrumentation
=
AddAnalysisPoint
(
bodySyntax
,
SkipAttributes
(
bodySyntax
),
methodBodyFactory
)
If
Not
method
.
IsImplicitlyDeclared
Then
_methodEntryInstrumentation
=
AddAnalysisPoint
(
bodySyntax
,
SkipAttributes
(
bodySyntax
),
methodBodyFactory
)
End
If
End
Sub
End
Sub
Public
Overrides
Function
CreateBlockPrologue
(
trueOriginal
As
BoundBlock
,
original
As
BoundBlock
,
ByRef
synthesizedLocal
As
LocalSymbol
)
As
BoundStatement
Public
Overrides
Function
CreateBlockPrologue
(
trueOriginal
As
BoundBlock
,
original
As
BoundBlock
,
ByRef
synthesizedLocal
As
LocalSymbol
)
As
BoundStatement
...
@@ -106,7 +108,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
...
@@ -106,7 +108,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim
prologueStatements
As
ArrayBuilder
(
Of
BoundStatement
)
=
ArrayBuilder
(
Of
BoundStatement
).
GetInstance
(
If
(
previousPrologue
Is
Nothing
,
3
,
4
))
Dim
prologueStatements
As
ArrayBuilder
(
Of
BoundStatement
)
=
ArrayBuilder
(
Of
BoundStatement
).
GetInstance
(
If
(
previousPrologue
Is
Nothing
,
3
,
4
))
prologueStatements
.
Add
(
payloadInitialization
)
prologueStatements
.
Add
(
payloadInitialization
)
prologueStatements
.
Add
(
payloadIf
)
prologueStatements
.
Add
(
payloadIf
)
prologueStatements
.
Add
(
_methodEntryInstrumentation
)
If
_methodEntryInstrumentation
IsNot
Nothing
Then
prologueStatements
.
Add
(
_methodEntryInstrumentation
)
End
If
If
previousPrologue
IsNot
Nothing
Then
If
previousPrologue
IsNot
Nothing
Then
prologueStatements
.
Add
(
previousPrologue
)
prologueStatements
.
Add
(
previousPrologue
)
End
If
End
If
...
...
src/Compilers/VisualBasic/Test/Emit/Emit/DynamicAnalysis/DynamicAnalysisResourceTests.vb
浏览文件 @
73553c7c
...
@@ -587,6 +587,71 @@ End Class
...
@@ -587,6 +587,71 @@ End Class
New
SpanResult
(
37
,
8
,
37
,
18
,
"_z = a + b"
))
New
SpanResult
(
37
,
8
,
37
,
18
,
"_z = a + b"
))
End
Sub
End
Sub
<
Fact
>
Public
Sub
TestImplicitConstructorSpans
()
Dim
testSource
As
XElement
=
<
file
name
=
"c.vb"
>
<
!
[
CDATA
[
Module
Program
Private
x
As
Integer
Public
Sub
Main
()
' Method 0
TestMain
()
End
Sub
Sub
TestMain
()
' Method 1
Dim
local
As
New
C
()
End
Sub
End
Module
Class
C
Shared
Function
Init
()
As
Integer
' Method 4
Return
33
End
Function
Private
_x
As
Integer
=
Init
()
Private
_y
As
Integer
=
Init
()
+
12
Private
Shared
s_x
As
Integer
=
Init
()
Private
Shared
s_y
As
Integer
=
Init
()
+
153
Private
Shared
s_z
As
Integer
=
144
End
Class
]]
>
</
file
>
Dim
source
As
Xml
.
Linq
.
XElement
=
<
compilation
></
compilation
>
source
.
Add
(
testSource
)
source
.
Add
(
InstrumentationHelperSource
)
Dim
c
=
CompilationUtils
.
CreateCompilationWithMscorlibAndVBRuntime
(
source
)
Dim
peImage
=
c
.
EmitToArray
(
EmitOptions
.
Default
.
WithInstrument
(
"Test.Flag"
))
Dim
PEReader
As
New
PEReader
(
peImage
)
Dim
reader
=
DynamicAnalysisDataReader
.
TryCreateFromPE
(
PEReader
,
"<DynamicAnalysisData>"
)
VerifyDocuments
(
reader
,
reader
.
Documents
,
"'c.vb'"
,
"'a.vb'"
)
Dim
sourceLines
As
String
()
=
testSource
.
ToString
().
Split
(
vbLf
(
0
))
VerifySpans
(
reader
,
reader
.
Methods
(
0
),
sourceLines
,
New
SpanResult
(
3
,
4
,
5
,
11
,
"Public Sub Main()"
),
New
SpanResult
(
4
,
8
,
4
,
18
,
"TestMain()"
))
VerifySpans
(
reader
,
reader
.
Methods
(
1
),
sourceLines
,
New
SpanResult
(
7
,
4
,
9
,
11
,
"Sub TestMain()"
),
New
SpanResult
(
8
,
21
,
8
,
28
,
"New C()"
))
VerifySpans
(
reader
,
reader
.
Methods
(
4
),
sourceLines
,
New
SpanResult
(
13
,
4
,
15
,
16
,
"Shared Function Init() As Integer"
),
New
SpanResult
(
14
,
8
,
14
,
17
,
"Return 33"
))
VerifySpans
(
reader
,
reader
.
Methods
(
2
),
sourceLines
,
' implicit shared constructor
New
SpanResult
(
19
,
36
,
19
,
42
,
"Init()"
),
New
SpanResult
(
20
,
36
,
20
,
48
,
"Init() + 153"
),
New
SpanResult
(
21
,
36
,
21
,
39
,
"144"
))
VerifySpans
(
reader
,
reader
.
Methods
(
3
),
sourceLines
,
' implicit default constructor
New
SpanResult
(
17
,
28
,
17
,
34
,
"Init()"
),
New
SpanResult
(
18
,
28
,
18
,
39
,
"Init() + 12"
))
End
Sub
<
Fact
>
<
Fact
>
Public
Sub
TestDynamicAnalysisResourceMissingWhenInstrumentationFlagIsDisabled
()
Public
Sub
TestDynamicAnalysisResourceMissingWhenInstrumentationFlagIsDisabled
()
Dim
source
As
Xml
.
Linq
.
XElement
=
<
compilation
></
compilation
>
Dim
source
As
Xml
.
Linq
.
XElement
=
<
compilation
></
compilation
>
...
...
src/Compilers/VisualBasic/Test/Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.vb
浏览文件 @
73553c7c
...
@@ -1223,6 +1223,7 @@ True
...
@@ -1223,6 +1223,7 @@ True
CompileAndVerify
(
source
,
expectedOutput
)
CompileAndVerify
(
source
,
expectedOutput
)
End
Sub
End
Sub
<
Fact
>
<
Fact
>
Public
Sub
TestFieldInitializerSpans
()
Public
Sub
TestFieldInitializerSpans
()
Dim
testSource
As
XElement
=
<
file
name
=
"c.vb"
>
Dim
testSource
As
XElement
=
<
file
name
=
"c.vb"
>
...
@@ -1327,6 +1328,89 @@ True
...
@@ -1327,6 +1328,89 @@ True
CompileAndVerify
(
source
,
expectedOutput
)
CompileAndVerify
(
source
,
expectedOutput
)
End
Sub
End
Sub
<
Fact
>
Public
Sub
TestImplicitConstructorSpans
()
Dim
testSource
As
XElement
=
<
file
name
=
"c.vb"
>
<
!
[
CDATA
[
Module
Program
Private
x
As
Integer
Public
Sub
Main
()
' Method 1
TestMain
()
Microsoft
.
CodeAnalysis
.
Runtime
.
Instrumentation
.
FlushPayload
()
End
Sub
Sub
TestMain
()
' Method 2
Dim
local
As
New
C
()
Dim
x
As
Integer
=
local
.
_x
+
C
.
s_x
End
Sub
End
Module
Class
C
' Method 3 is the implicit shared constructor.
' Method 4 is the implicit instance constructor.
Shared
Function
Init
()
As
Integer
' Method 5
Return
33
End
Function
Public
_x
As
Integer
=
Init
()
Public
_y
As
Integer
=
Init
()
+
12
Public
Shared
s_x
As
Integer
=
Init
()
Public
Shared
s_y
As
Integer
=
Init
()
+
153
Public
Shared
s_z
As
Integer
=
144
End
Class
]]
>
</
file
>
Dim
source
As
Xml
.
Linq
.
XElement
=
<
compilation
></
compilation
>
source
.
Add
(
testSource
)
source
.
Add
(
InstrumentationHelperSource
)
Dim
expectedOutput
As
XCData
=
<
!
[
CDATA
[
Flushing
Method
1
File
1
True
True
True
Method
2
File
1
True
True
True
Method
3
File
1
True
True
True
Method
4
File
1
True
True
Method
5
File
1
True
True
Method
8
File
1
True
True
False
True
True
True
True
True
True
True
True
True
]]
>
CompileAndVerify
(
source
,
expectedOutput
)
End
Sub
<
Fact
>
<
Fact
>
Public
Sub
MissingMethodNeededForAnaysis
()
Public
Sub
MissingMethodNeededForAnaysis
()
Dim
testSource
As
XElement
=
<
file
name
=
"c.vb"
>
Dim
testSource
As
XElement
=
<
file
name
=
"c.vb"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录