Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
21798af6
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,发现更多精彩内容 >>
提交
21798af6
编写于
4月 29, 2020
作者:
J
Jason Malinowski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add some unit tests to confirm some behavior around metadata reference conversion
上级
ad16d1ce
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
97 addition
and
1 deletion
+97
-1
src/VisualStudio/Core/Test/ProjectSystemShim/VisualStudioProjectTests/MetadataToProjectReferenceConversionTests.vb
...ProjectTests/MetadataToProjectReferenceConversionTests.vb
+97
-1
未找到文件。
src/VisualStudio/Core/Test/ProjectSystemShim/VisualStudioProjectTests/MetadataToProjectReferenceConversionTests.vb
浏览文件 @
21798af6
...
...
@@ -2,7 +2,7 @@
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports
System.
Threading
Imports
System.
Collections.Immutable
Imports
Microsoft.CodeAnalysis
Imports
Microsoft.CodeAnalysis.Test.Utilities
Imports
Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Framework
...
...
@@ -138,5 +138,101 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Task
.
WaitAll
(
task1
,
task2
)
End
Using
End
Sub
<
WpfFact
>
Public
Sub
AddingAndRemovingTwoReferencesWithDifferentPropertiesConvertsCorrectly
()
Using
environment
=
New
TestEnvironment
()
Dim
referencingProject
=
environment
.
ProjectFactory
.
CreateAndAddToWorkspace
(
"referencingProject"
,
LanguageNames
.
CSharp
)
Dim
referencedProject
=
environment
.
ProjectFactory
.
CreateAndAddToWorkspace
(
"referencedProject"
,
LanguageNames
.
CSharp
)
Const
ReferencePath
=
"C:\project.dll"
referencingProject
.
AddMetadataReference
(
ReferencePath
,
New
MetadataReferenceProperties
(
aliases
:
=
ImmutableArray
.
Create
(
"alias1"
)))
referencedProject
.
OutputFilePath
=
ReferencePath
Dim
getReferencingProject
=
Function
()
environment
.
Workspace
.
CurrentSolution
.
GetProject
(
referencingProject
.
Id
)
' The alias should have flowed through correctly
Assert
.
Equal
(
"alias1"
,
Assert
.
Single
(
Assert
.
Single
(
getReferencingProject
().
ProjectReferences
).
Aliases
))
referencingProject
.
AddMetadataReference
(
ReferencePath
,
New
MetadataReferenceProperties
(
aliases
:
=
ImmutableArray
.
Create
(
"alias2"
)))
Assert
.
Equal
(
2
,
getReferencingProject
().
ProjectReferences
.
Count
())
referencingProject
.
RemoveMetadataReference
(
ReferencePath
,
New
MetadataReferenceProperties
(
aliases
:
=
ImmutableArray
.
Create
(
"alias2"
)))
' Should be back to the single reference again
Assert
.
Equal
(
"alias1"
,
Assert
.
Single
(
Assert
.
Single
(
getReferencingProject
().
ProjectReferences
).
Aliases
))
referencingProject
.
RemoveMetadataReference
(
ReferencePath
,
New
MetadataReferenceProperties
(
aliases
:
=
ImmutableArray
.
Create
(
"alias1"
)))
Assert
.
Empty
(
getReferencingProject
().
ProjectReferences
)
End
Using
End
Sub
<
WpfTheory
>
<
CombinatorialData
>
Public
Sub
MetadataReferenceBeingAddedWhileOutputPathUpdateInInterleavedBatches
(
closeReferencedProjectBatchFirst
As
Boolean
)
Using
environment
=
New
TestEnvironment
()
Dim
referencingProject
=
environment
.
ProjectFactory
.
CreateAndAddToWorkspace
(
"referencingProject"
,
LanguageNames
.
CSharp
)
Dim
referencedProject
=
environment
.
ProjectFactory
.
CreateAndAddToWorkspace
(
"referencedProject"
,
LanguageNames
.
CSharp
)
Dim
referencingProjectBatch
=
referencingProject
.
CreateBatchScope
()
Dim
referencedProjectBatch
=
referencedProject
.
CreateBatchScope
()
Const
ReferencePath
=
"C:\project.dll"
' Set the OutputFilePath first -- we don't expect this to be visible to other projects until the batch is closed
referencedProject
.
OutputFilePath
=
ReferencePath
referencingProject
.
AddMetadataReference
(
ReferencePath
,
MetadataReferenceProperties
.
Assembly
)
If
closeReferencedProjectBatchFirst
Then
referencedProjectBatch
.
Dispose
()
referencingProjectBatch
.
Dispose
()
Else
referencingProjectBatch
.
Dispose
()
referencedProjectBatch
.
Dispose
()
End
If
' Either way, we should have a single project reference
Dim
getReferencingProject
=
Function
()
environment
.
Workspace
.
CurrentSolution
.
GetProject
(
referencingProject
.
Id
)
Assert
.
Single
(
getReferencingProject
().
ProjectReferences
)
Assert
.
Empty
(
getReferencingProject
().
MetadataReferences
)
End
Using
End
Sub
<
WpfTheory
>
<
CombinatorialData
>
Public
Sub
MetadataReferenceBeingRemovedAndReAddedWhileOutputPathUpdateInInterleavedBatches
(
closeReferencedProjectBatchFirst
As
Boolean
)
Using
environment
=
New
TestEnvironment
()
Dim
referencingProject
=
environment
.
ProjectFactory
.
CreateAndAddToWorkspace
(
"referencingProject"
,
LanguageNames
.
CSharp
)
Dim
referencedProject
=
environment
.
ProjectFactory
.
CreateAndAddToWorkspace
(
"referencedProject"
,
LanguageNames
.
CSharp
)
Const
ReferencePath
=
"C:\project.dll"
referencingProject
.
AddMetadataReference
(
ReferencePath
,
MetadataReferenceProperties
.
Assembly
.
WithAliases
(
ImmutableArray
.
Create
(
"temporary"
)))
Dim
getReferencingProject
=
Function
()
environment
.
Workspace
.
CurrentSolution
.
GetProject
(
referencingProject
.
Id
)
Dim
referencingProjectBatch
=
referencingProject
.
CreateBatchScope
()
Dim
referencedProjectBatch
=
referencedProject
.
CreateBatchScope
()
' Set the OutputFilePath second -- we don't expect this to be visible to other projects until the batch is closed
referencedProject
.
OutputFilePath
=
ReferencePath
referencingProject
.
RemoveMetadataReference
(
ReferencePath
,
MetadataReferenceProperties
.
Assembly
.
WithAliases
(
ImmutableArray
.
Create
(
"temporary"
)))
referencingProject
.
AddMetadataReference
(
ReferencePath
,
MetadataReferenceProperties
.
Assembly
)
If
closeReferencedProjectBatchFirst
Then
referencedProjectBatch
.
Dispose
()
referencingProjectBatch
.
Dispose
()
Else
referencingProjectBatch
.
Dispose
()
referencedProjectBatch
.
Dispose
()
End
If
' Either way, we should have a single project reference
Assert
.
Single
(
getReferencingProject
().
ProjectReferences
)
Assert
.
Empty
(
getReferencingProject
().
MetadataReferences
)
End
Using
End
Sub
End
Class
End
Namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录