Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
508c2290
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,发现更多精彩内容 >>
提交
508c2290
编写于
4月 21, 2016
作者:
T
Ty Overby
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bail in GetDependenceChain if typesymbol isn't found (#10331)
harden both DetectTypeCircularity and GetDependenceChain
上级
4eb39ed0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
74 addition
and
3 deletion
+74
-3
src/Compilers/CSharp/Test/Symbol/Compilation/SemanticModelAPITests.cs
...s/CSharp/Test/Symbol/Compilation/SemanticModelAPITests.cs
+26
-0
src/Compilers/VisualBasic/Portable/Symbols/BaseTypeAnalysis.vb
...ompilers/VisualBasic/Portable/Symbols/BaseTypeAnalysis.vb
+1
-2
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceMemberContainerTypeSymbol.vb
...ortable/Symbols/Source/SourceMemberContainerTypeSymbol.vb
+5
-1
src/Compilers/VisualBasic/Test/Semantic/Compilation/SemanticModelAPITests.vb
...lBasic/Test/Semantic/Compilation/SemanticModelAPITests.vb
+42
-0
未找到文件。
src/Compilers/CSharp/Test/Symbol/Compilation/SemanticModelAPITests.cs
浏览文件 @
508c2290
...
...
@@ -2101,6 +2101,32 @@ void M(int x)
VerifySpeculativeSemanticModelForMethodBody
(
blockStatement
,
speculativeModel
);
}
[
Fact
()]
[
WorkItem
(
10211
,
"https://github.com/dotnet/roslyn/issues/10211"
)]
public
void
GetDependenceChainRegression_10211_working
()
{
var
compilation
=
CreateCompilation
(
@"
class Parent {}
class Child : Parent {}
"
);
var
semanticModel
=
compilation
.
GetSemanticModel
(
compilation
.
SyntaxTrees
[
0
]);
// Ensure that we don't crash here.
semanticModel
.
GetMethodBodyDiagnostics
();
}
[
Fact
()]
[
WorkItem
(
10211
,
"https://github.com/dotnet/roslyn/issues/10211"
)]
public
void
GetDependenceChainRegression_10211
()
{
var
compilation
=
CreateCompilation
(
@"
class Child : Parent {}
class Parent {}
"
);
var
semanticModel
=
compilation
.
GetSemanticModel
(
compilation
.
SyntaxTrees
[
0
]);
// Ensure that we don't crash here.
semanticModel
.
GetMethodBodyDiagnostics
();
}
private
static
void
VerifySpeculativeSemanticModelForMethodBody
(
BlockSyntax
blockStatement
,
SemanticModel
speculativeModel
)
{
var
localDecl
=
(
LocalDeclarationStatementSyntax
)
blockStatement
.
Statements
[
0
];
...
...
src/Compilers/VisualBasic/Portable/Symbols/BaseTypeAnalysis.vb
浏览文件 @
508c2290
...
...
@@ -187,10 +187,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Private
Function
GetDependenceChain
(
visited
As
HashSet
(
Of
Symbol
),
root
As
SourceNamedTypeSymbol
,
current
As
TypeSymbol
)
As
ConsList
(
Of
DependencyDesc
)
Debug
.
Assert
(
root
.
OriginalDefinition
=
root
,
"root must not be a substitution"
)
If
current
Is
Nothing
Then
If
current
Is
Nothing
OrElse
current
.
Kind
=
SymbolKind
.
ErrorType
Then
Return
Nothing
End
If
...
...
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceMemberContainerTypeSymbol.vb
浏览文件 @
508c2290
...
...
@@ -2230,8 +2230,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Return
True
End
If
' We can not get the relative order of a declaration without a source location
If
typeToTest
.
Locations
.
IsEmpty
Then
Return
True
End
If
' We use simple comparison based on source location
Debug
.
Assert
(
typeToTest
.
Locations
.
Length
>
0
)
Dim
typeToTestLocation
=
typeToTest
.
Locations
(
0
)
Debug
.
Assert
(
Me
.
Locations
.
Length
>
0
)
...
...
src/Compilers/VisualBasic/Test/Semantic/Compilation/SemanticModelAPITests.vb
浏览文件 @
508c2290
...
...
@@ -4061,6 +4061,48 @@ End Class
Assert.Equal(2, treeErrs.Length())
End Sub
<Fact()>
<WorkItem(10211, "
https
:
//
github
.
com
/
dotnet
/
roslyn
/
issues
/
10211
")>
Public Sub GetDependenceChainRegression_10211_working()
Dim source = <compilation>
<file name="
a
.
vb
"><![CDATA[
Public Class Parent
End Class
Public Class Child
Inherits Parent
End Class
]]></file>
</compilation>
Dim compilation = CreateCompilationWithoutReferences(source)
Dim semanticModel = compilation.GetSemanticModel(compilation.SyntaxTrees(0))
' Ensuring that this doesn't throw
semanticModel.GetMethodBodyDiagnostics()
End Sub
<Fact()>
<WorkItem(10211, "
https
:
//
github
.
com
/
dotnet
/
roslyn
/
issues
/
10211
")>
Public Sub GetDependenceChainRegression_10211()
Dim source = <compilation>
<file name="
a
.
vb
"><![CDATA[
Public Class Child
Inherits Parent
End Class
Public Class Parent
End Class
]]></file>
</compilation>
Dim compilation = CreateCompilationWithoutReferences(source)
Dim semanticModel = compilation.GetSemanticModel(compilation.SyntaxTrees(0))
' Ensuring that this doesn't throw
semanticModel.GetMethodBodyDiagnostics()
End Sub
<WorkItem(859721, "
http
:
//
vstfdevdiv
:
8080
/
DevDiv2
/
DevDiv
/
_workitems
/
edit
/
859721
")>
<Fact()>
Public Sub TestMethodBodyDiagnostics()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录