Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
854940a4
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,发现更多精彩内容 >>
提交
854940a4
编写于
2月 19, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Check each project independently to see if it denies the reference.
上级
e320cfff
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
21 deletion
+41
-21
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
...Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
+41
-21
未找到文件。
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
浏览文件 @
854940a4
...
...
@@ -1056,55 +1056,75 @@ internal override bool CanAddProjectReference(ProjectId referencingProject, Proj
if
(!
TryGetHierarchy
(
referencingProject
,
out
referencingHierarchy
)
||
!
TryGetHierarchy
(
referencedProject
,
out
referencedHierarchy
))
{
// Couldn't even get a hierarchy for this project. So we have to assume
// that adding a reference is disallowed.
return
false
;
}
var
referencingProjectFlavor3
=
referencingHierarchy
as
IVsProjectFlavorReferences3
;
var
referencedProjectFlavor3
=
referencedHierarchy
as
IVsProjectFlavorReferences3
;
// First we have to see if either project disallows the reference being added.
const
int
ContextFlags
=
(
int
)
__VSQUERYFLAVORREFERENCESCONTEXT
.
VSQUERYFLAVORREFERENCESCONTEXT_RefreshReference
;
if
(
referencingProjectFlavor3
!=
null
&&
referencedProjectFlavor3
!=
null
)
{
const
int
ContextFlags
=
(
int
)
__VSQUERYFLAVORREFERENCESCONTEXT
.
VSQUERYFLAVORREFERENCESCONTEXT_RefreshReference
;
uint
canAddProjectReference
=
(
uint
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_UNKNOWN
;
uint
canBeReferenced
=
(
uint
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_UNKNOWN
;
uint
canAddProjectReference
;
uint
canBeReferenced
;
var
referencingProjectFlavor3
=
referencingHierarchy
as
IVsProjectFlavorReferences3
;
if
(
referencingProjectFlavor3
!=
null
)
{
string
unused
;
if
(
ErrorHandler
.
Failed
(
referencingProjectFlavor3
.
QueryAddProjectReferenceEx
(
referencedHierarchy
,
ContextFlags
,
out
canAddProjectReference
,
out
unused
))
||
ErrorHandler
.
Failed
(
referencedProjectFlavor3
.
QueryCanBeReferencedEx
(
referencingHierarchy
,
ContextFlags
,
out
canBeReferenced
,
out
unused
)))
if
(
ErrorHandler
.
Failed
(
referencingProjectFlavor3
.
QueryAddProjectReferenceEx
(
referencedHierarchy
,
ContextFlags
,
out
canAddProjectReference
,
out
unused
)))
{
// Something went wrong even trying to see if the reference would be allowed.
// Assume it won't be allowed.
return
false
;
}
if
(
canAddProjectReference
==
(
uint
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_DENY
||
canBeReferenced
==
(
uint
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_DENY
)
if
(
canAddProjectReference
==
(
uint
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_DENY
)
{
//
If either of them deny then add a
project reference is not allowed.
//
Adding this
project reference is not allowed.
return
false
;
}
}
if
(
canAddProjectReference
==
(
int
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_ALLOW
||
canBeReferenced
==
(
int
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_ALLOW
)
var
referencedProjectFlavor3
=
referencedHierarchy
as
IVsProjectFlavorReferences3
;
if
(
referencedProjectFlavor3
!=
null
)
{
string
unused
;
if
(
ErrorHandler
.
Failed
(
referencedProjectFlavor3
.
QueryCanBeReferencedEx
(
referencingHierarchy
,
ContextFlags
,
out
canBeReferenced
,
out
unused
)))
{
// At least one allows this, and neither deny. So this is allowed.
return
true
;
// Something went wrong even trying to see if the reference would be allowed.
// Assume it won't be allowed.
return
false
;
}
if
(
canBeReferenced
==
(
uint
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_DENY
)
{
// Adding this project reference is not allowed.
return
false
;
}
}
// Both are unknown if they should allow this. Fall through and use the regular
// matrix check.
// Neither project denied the reference being added. At this point, if either project
// allows the reference to be added, and the other doesn't block it, then we can add
// the reference.
if
(
canAddProjectReference
==
(
int
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_ALLOW
||
canBeReferenced
==
(
int
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_ALLOW
)
{
return
true
;
}
// Normal matrix check for projects that don't implement IVsProjectFlavorReferences3.
// In both directions things are still unknown. Fallback to the reference manager
// to make the determination here.
var
referenceManager
=
GetVsService
<
SVsReferenceManager
,
IVsReferenceManager
>();
if
(
referenceManager
==
null
)
{
// Couldn't get the reference manager. Have to assume it's not allowed.
return
false
;
}
// As long as the reference manager does not deny things, then we allow the
// reference to be added.
var
result
=
referenceManager
.
QueryCanReferenceProject
(
referencingHierarchy
,
referencedHierarchy
);
return
result
==
(
uint
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_ALLOW
||
result
==
(
uint
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_UNKNOWN
;
return
result
!=
(
uint
)
__VSREFERENCEQUERYRESULT
.
REFERENCE_DENY
;
}
/// <summary>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录