Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
31e62fbe
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,发现更多精彩内容 >>
提交
31e62fbe
编写于
1月 06, 2018
作者:
C
Charles Stoner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Skip pseudo-variables with use-site errors
上级
d3de5b2b
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
86 addition
and
0 deletion
+86
-0
src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationContext.cs
...or/CSharp/Source/ExpressionCompiler/CompilationContext.cs
+5
-0
src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs
...onEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs
+40
-0
src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationContext.vb
...sualBasic/Source/ExpressionCompiler/CompilationContext.vb
+4
-0
src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/LocalsTests.vb
...luator/VisualBasic/Test/ExpressionCompiler/LocalsTests.vb
+37
-0
未找到文件。
src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/CompilationContext.cs
浏览文件 @
31e62fbe
...
...
@@ -331,6 +331,11 @@ private static string GetNextMethodName(ArrayBuilder<MethodSymbol> builder)
_currentFrame
,
sourceAssembly
,
alias
);
// Skip pseudo-variables with errors.
if
(
local
.
GetUseSiteDiagnostic
()?.
Severity
==
DiagnosticSeverity
.
Error
)
{
continue
;
}
var
methodName
=
GetNextMethodName
(
methodBuilder
);
var
syntax
=
SyntaxFactory
.
IdentifierName
(
SyntaxFactory
.
MissingToken
(
SyntaxKind
.
IdentifierToken
));
var
aliasMethod
=
this
.
CreateMethod
(
...
...
src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs
浏览文件 @
31e62fbe
...
...
@@ -3856,6 +3856,46 @@ static void DummySequencePoint()
});
}
/// <summary>
/// CompileGetLocals should skip locals with errors.
/// </summary>
[
WorkItem
(
535899
,
"https://devdiv.visualstudio.com/DevDiv/_workitems?id=535899"
)]
[
Fact
]
public
void
SkipPseudoVariablesWithUseSiteErrors
()
{
var
source
=
@"class C
{
static void M(object x)
{
object y;
}
}"
;
var
compilation0
=
CreateStandardCompilation
(
source
,
options
:
TestOptions
.
DebugDll
);
WithRuntimeInstance
(
compilation0
,
runtime
=>
{
var
context
=
CreateMethodContext
(
runtime
,
"C.M"
);
var
aliases
=
ImmutableArray
.
Create
(
ReturnValueAlias
(
1
,
"UnknownType, UnknownAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
));
var
locals
=
ArrayBuilder
<
LocalAndMethod
>.
GetInstance
();
string
typeName
;
var
diagnostics
=
DiagnosticBag
.
GetInstance
();
var
testData
=
new
CompilationTestData
();
context
.
CompileGetLocals
(
locals
,
argumentsOnly
:
false
,
aliases
:
aliases
,
diagnostics
:
diagnostics
,
typeName
:
out
typeName
,
testData
:
testData
);
diagnostics
.
Verify
();
diagnostics
.
Free
();
Assert
.
Equal
(
locals
.
Count
,
2
);
VerifyLocal
(
testData
,
typeName
,
locals
[
0
],
"<>m0"
,
"x"
);
VerifyLocal
(
testData
,
typeName
,
locals
[
1
],
"<>m1"
,
"y"
);
locals
.
Free
();
});
}
private
static
void
GetLocals
(
RuntimeInstance
runtime
,
string
methodName
,
bool
argumentsOnly
,
ArrayBuilder
<
LocalAndMethod
>
locals
,
int
count
,
out
string
typeName
,
out
CompilationTestData
testData
)
{
var
context
=
CreateMethodContext
(
runtime
,
methodName
);
...
...
src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/CompilationContext.vb
浏览文件 @
31e62fbe
...
...
@@ -242,6 +242,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator
Dim
methodName
=
GetNextMethodName
(
methodBuilder
)
Dim
syntax
=
SyntaxFactory
.
IdentifierName
(
SyntaxFactory
.
MissingToken
(
SyntaxKind
.
IdentifierToken
))
Dim
local
=
PlaceholderLocalSymbol
.
Create
(
typeNameDecoder
,
_currentFrame
,
[
alias
]
)
' Skip pseudo-variables with errors.
If
local
.
GetUseSiteErrorInfo
()
?
.
Severity
=
DiagnosticSeverity
.
Error
Then
Continue
For
End
If
Dim
aliasMethod
=
Me
.
CreateMethod
(
container
,
methodName
,
...
...
src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/LocalsTests.vb
浏览文件 @
31e62fbe
...
...
@@ -3284,6 +3284,43 @@ End Class"
End
Sub
)
End
Sub
''' <summary>
''' CompileGetLocals should skip locals with errors.
''' </summary>
<
WorkItem
(
535899
,
"https://devdiv.visualstudio.com/DevDiv/_workitems?id=535899"
)
>
<
Fact
>
Public
Sub
SkipPseudoVariablesWithUseSiteErrors
()
Const
source
=
"Class C
Shared Sub M(x As Object)
Dim y As Object
End Sub
End Class"
Dim
comp
=
CreateCompilationWithMscorlib
({
source
},
options
:
=
TestOptions
.
DebugDll
)
WithRuntimeInstance
(
comp
,
Sub
(
runtime
)
Dim
context
=
CreateMethodContext
(
runtime
,
"C.M"
)
Dim
aliases
=
ImmutableArray
.
Create
(
ReturnValueAlias
(
1
,
"UnknownType, UnknownAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
))
Dim
locals
=
ArrayBuilder
(
Of
LocalAndMethod
).
GetInstance
()
Dim
typeName
As
String
=
Nothing
Dim
diagnostics
=
DiagnosticBag
.
GetInstance
()
Dim
testData
=
New
CompilationTestData
()
context
.
CompileGetLocals
(
locals
,
argumentsOnly
:
=
False
,
aliases
:
=
aliases
,
diagnostics
:
=
diagnostics
,
typeName
:
=
typeName
,
testData
:
=
testData
)
diagnostics
.
Verify
()
diagnostics
.
Free
()
Assert
.
Equal
(
2
,
locals
.
Count
)
VerifyLocal
(
testData
,
typeName
,
locals
(
0
),
"<>m0"
,
"x"
)
VerifyLocal
(
testData
,
typeName
,
locals
(
1
),
"<>m1"
,
"y"
)
locals
.
Free
()
End
Sub
)
End
Sub
Private
Shared
Sub
GetLocals
(
runtime
As
RuntimeInstance
,
methodName
As
String
,
argumentsOnly
As
Boolean
,
locals
As
ArrayBuilder
(
Of
LocalAndMethod
),
count
As
Integer
,
ByRef
typeName
As
String
,
ByRef
testData
As
CompilationTestData
)
Dim
context
=
CreateMethodContext
(
runtime
,
methodName
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录