Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
20b9d140
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,发现更多精彩内容 >>
提交
20b9d140
编写于
7月 13, 2015
作者:
A
Andrew Casey
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3925 from amcasey/DuplicateTrees
ReplaceSyntaxTree should throw on duplicate
上级
b6e09b1a
0f905f42
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
8 deletion
+19
-8
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
...ompilers/CSharp/Portable/Compilation/CSharpCompilation.cs
+7
-1
src/Compilers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs
...ers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs
+3
-6
src/Compilers/VisualBasic/Portable/Compilation/VisualBasicCompilation.vb
...isualBasic/Portable/Compilation/VisualBasicCompilation.vb
+6
-1
src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb
...ualBasic/Test/Semantic/Compilation/CompilationAPITests.vb
+3
-0
未找到文件。
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
浏览文件 @
20b9d140
...
@@ -709,7 +709,7 @@ public new CSharpCompilation AddSyntaxTrees(IEnumerable<SyntaxTree> trees)
...
@@ -709,7 +709,7 @@ public new CSharpCompilation AddSyntaxTrees(IEnumerable<SyntaxTree> trees)
ref
bool
referenceDirectivesChanged
)
ref
bool
referenceDirectivesChanged
)
{
{
var
lazyRoot
=
new
Lazy
<
RootSingleNamespaceDeclaration
>(()
=>
DeclarationTreeBuilder
.
ForTree
(
tree
,
options
.
ScriptClassName
??
""
,
isSubmission
));
var
lazyRoot
=
new
Lazy
<
RootSingleNamespaceDeclaration
>(()
=>
DeclarationTreeBuilder
.
ForTree
(
tree
,
options
.
ScriptClassName
??
""
,
isSubmission
));
declMap
=
declMap
.
SetItem
(
tree
,
lazyRoot
);
declMap
=
declMap
.
Add
(
tree
,
lazyRoot
);
// Callers are responsible for checking for existing entries.
declTable
=
declTable
.
AddRootDeclaration
(
lazyRoot
);
declTable
=
declTable
.
AddRootDeclaration
(
lazyRoot
);
referenceDirectivesChanged
=
referenceDirectivesChanged
||
tree
.
HasReferenceDirectives
();
referenceDirectivesChanged
=
referenceDirectivesChanged
||
tree
.
HasReferenceDirectives
();
}
}
...
@@ -829,6 +829,12 @@ public new CSharpCompilation ReplaceSyntaxTree(SyntaxTree oldTree, SyntaxTree ne
...
@@ -829,6 +829,12 @@ public new CSharpCompilation ReplaceSyntaxTree(SyntaxTree oldTree, SyntaxTree ne
}
}
var
declMap
=
_rootNamespaces
;
var
declMap
=
_rootNamespaces
;
if
(
declMap
.
ContainsKey
(
newTree
))
{
throw
new
ArgumentException
(
CSharpResources
.
SyntaxTreeAlreadyPresent
,
nameof
(
newTree
));
}
var
declTable
=
_declarationTable
;
var
declTable
=
_declarationTable
;
bool
referenceDirectivesChanged
=
false
;
bool
referenceDirectivesChanged
=
false
;
...
...
src/Compilers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs
浏览文件 @
20b9d140
...
@@ -452,6 +452,9 @@ public static int Foo()
...
@@ -452,6 +452,9 @@ public static int Foo()
// add again and verify that it throws
// add again and verify that it throws
Assert
.
Throws
<
ArgumentException
>(()
=>
comp
.
AddSyntaxTrees
(
t1
));
Assert
.
Throws
<
ArgumentException
>(()
=>
comp
.
AddSyntaxTrees
(
t1
));
// replace with existing and verify that it throws
Assert
.
Throws
<
ArgumentException
>(()
=>
comp
.
ReplaceSyntaxTree
(
t1
,
comp
.
SyntaxTrees
[
0
]));
// SyntaxTrees have reference equality. This removal should fail.
// SyntaxTrees have reference equality. This removal should fail.
Assert
.
Throws
<
ArgumentException
>(()
=>
comp
=
comp
.
RemoveSyntaxTrees
(
SyntaxFactory
.
ParseSyntaxTree
(
s1
)));
Assert
.
Throws
<
ArgumentException
>(()
=>
comp
=
comp
.
RemoveSyntaxTrees
(
SyntaxFactory
.
ParseSyntaxTree
(
s1
)));
Assert
.
Equal
(
4
,
comp
.
SyntaxTrees
.
Length
);
Assert
.
Equal
(
4
,
comp
.
SyntaxTrees
.
Length
);
...
@@ -1656,12 +1659,6 @@ class C { }", options: TestOptions.Script);
...
@@ -1656,12 +1659,6 @@ class C { }", options: TestOptions.Script);
var
ars
=
arc
.
ReplaceSyntaxTree
(
tc
,
ts
);
var
ars
=
arc
.
ReplaceSyntaxTree
(
tc
,
ts
);
Assert
.
False
(
arc
.
ReferenceManagerEquals
(
ars
));
Assert
.
False
(
arc
.
ReferenceManagerEquals
(
ars
));
var
ar3
=
arc
.
ReplaceSyntaxTree
(
tc
,
ta
);
Assert
.
True
(
arc
.
ReferenceManagerEquals
(
ar3
));
var
as1
=
ars
.
ReplaceSyntaxTree
(
tr
,
ts
);
Assert
.
False
(
ars
.
ReferenceManagerEquals
(
as1
));
}
}
private
sealed
class
EvolvingTestReference
:
PortableExecutableReference
private
sealed
class
EvolvingTestReference
:
PortableExecutableReference
...
...
src/Compilers/VisualBasic/Portable/Compilation/VisualBasicCompilation.vb
浏览文件 @
20b9d140
...
@@ -877,7 +877,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
...
@@ -877,7 +877,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
)
)
Dim
entry
=
New
DeclarationTableEntry
(
New
Lazy
(
Of
RootSingleNamespaceDeclaration
)(
Function
()
ForTree
(
tree
,
compilationOptions
,
isSubmission
)),
isEmbedded
:
=
False
)
Dim
entry
=
New
DeclarationTableEntry
(
New
Lazy
(
Of
RootSingleNamespaceDeclaration
)(
Function
()
ForTree
(
tree
,
compilationOptions
,
isSubmission
)),
isEmbedded
:
=
False
)
declMap
=
declMap
.
Add
(
tree
,
entry
)
declMap
=
declMap
.
Add
(
tree
,
entry
)
' Callers are responsible for checking for existing entries.
declTable
=
declTable
.
AddRootDeclaration
(
entry
)
declTable
=
declTable
.
AddRootDeclaration
(
entry
)
referenceDirectivesChanged
=
referenceDirectivesChanged
OrElse
tree
.
HasReferenceDirectives
referenceDirectivesChanged
=
referenceDirectivesChanged
OrElse
tree
.
HasReferenceDirectives
End
Sub
End
Sub
...
@@ -989,6 +989,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
...
@@ -989,6 +989,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
If
End
If
Dim
declMap
=
_rootNamespaces
Dim
declMap
=
_rootNamespaces
If
declMap
.
ContainsKey
(
vbNewTree
)
Then
Throw
New
ArgumentException
(
VBResources
.
SyntaxTreeAlreadyPresent
,
NameOf
(
newTree
))
End
If
Dim
declTable
=
_declarationTable
Dim
declTable
=
_declarationTable
Dim
referenceDirectivesChanged
=
False
Dim
referenceDirectivesChanged
=
False
...
...
src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb
浏览文件 @
20b9d140
...
@@ -423,6 +423,9 @@ End Namespace
...
@@ -423,6 +423,9 @@ End Namespace
comp
=
comp
.
AddSyntaxTrees
(
t1
).
ReplaceSyntaxTree
(
t1
,
t1
)
comp
=
comp
.
AddSyntaxTrees
(
t1
).
ReplaceSyntaxTree
(
t1
,
t1
)
Assert
.
Equal
(
3
,
comp
.
SyntaxTrees
.
Length
)
Assert
.
Equal
(
3
,
comp
.
SyntaxTrees
.
Length
)
' Replace with existing and verify that it throws
Assert
.
Throws
(
Of
ArgumentException
)(
Sub
()
comp
.
ReplaceSyntaxTree
(
t1
,
comp
.
SyntaxTrees
(
0
)))
Assert
.
Throws
(
Of
ArgumentException
)(
Sub
()
comp
.
AddSyntaxTrees
(
t1
))
Assert
.
Throws
(
Of
ArgumentException
)(
Sub
()
comp
.
AddSyntaxTrees
(
t1
))
' SyntaxTrees have reference equality. This removal should fail.
' SyntaxTrees have reference equality. This removal should fail.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录