Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
dba06e31
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,发现更多精彩内容 >>
未验证
提交
dba06e31
编写于
4月 20, 2018
作者:
J
Jason Malinowski
提交者:
GitHub
4月 20, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26215 from jasonmalinowski/fix-sharedproject-contexts
Make sure we always subscribe to shared hierarchy eventing
上级
f076f791
8270b0f2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
33 deletion
+56
-33
src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractProject.cs
.../Core/Def/Implementation/ProjectSystem/AbstractProject.cs
+10
-32
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectTracker.cs
...mplementation/ProjectSystem/VisualStudioProjectTracker.cs
+4
-1
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
...Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
+42
-0
未找到文件。
src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractProject.cs
浏览文件 @
dba06e31
...
...
@@ -52,7 +52,6 @@ internal abstract partial class AbstractProject : ForegroundThreadAffinitizedObj
private
readonly
Dictionary
<
string
,
IVisualStudioHostDocument
>
_documentMonikers
=
new
Dictionary
<
string
,
IVisualStudioHostDocument
>(
StringComparer
.
OrdinalIgnoreCase
);
private
readonly
Dictionary
<
string
,
VisualStudioAnalyzer
>
_analyzers
=
new
Dictionary
<
string
,
VisualStudioAnalyzer
>(
StringComparer
.
OrdinalIgnoreCase
);
private
readonly
Dictionary
<
DocumentId
,
IVisualStudioHostDocument
>
_additionalDocuments
=
new
Dictionary
<
DocumentId
,
IVisualStudioHostDocument
>();
private
readonly
Dictionary
<
DocumentId
,
List
<(
IVsHierarchy
hierarchy
,
uint
cookie
)>>
_hierarchyEventSinks
=
new
Dictionary
<
DocumentId
,
List
<(
IVsHierarchy
hierarchy
,
uint
cookie
)>>();
/// <summary>
/// The list of files which have been added to the project but we aren't tracking since they
...
...
@@ -866,31 +865,16 @@ private static void OnDocumentOpened(object sender, bool isCurrentContext)
if
(
project
.
PushingChangesToWorkspace
)
{
project
.
ProjectTracker
.
NotifyWorkspace
(
workspace
=>
workspace
.
OnDocumentOpened
(
document
.
Id
,
document
.
GetOpenTextBuffer
().
AsTextContainer
(),
isCurrentContext
));
project
.
ProjectTracker
.
NotifyWorkspace
(
workspace
=>
{
workspace
.
OnDocumentOpened
(
document
.
Id
,
document
.
GetOpenTextBuffer
().
AsTextContainer
(),
isCurrentContext
);
(
workspace
as
VisualStudioWorkspaceImpl
)?.
ConnectToSharedHierarchyEvents
(
document
);
});
}
else
{
StartPushingToWorkspaceAndNotifyOfOpenDocuments
(
project
);
}
var
itemId
=
document
.
GetItemId
();
if
(
itemId
!=
(
uint
)
VSConstants
.
VSITEMID
.
Nil
)
{
var
sharedHierarchy
=
LinkedFileUtilities
.
GetSharedHierarchyForItem
(
project
.
Hierarchy
,
itemId
);
if
(
sharedHierarchy
!=
null
)
{
project
.
ProjectTracker
.
NotifyWorkspace
(
workspace
=>
{
var
eventSink
=
new
HierarchyEventsSink
((
VisualStudioWorkspaceImpl
)
workspace
,
sharedHierarchy
,
document
.
Id
);
if
(
ErrorHandler
.
Succeeded
(
sharedHierarchy
.
AdviseHierarchyEvents
(
eventSink
,
out
var
cookie
)))
{
project
.
_hierarchyEventSinks
.
MultiAdd
(
document
.
Id
,
(
sharedHierarchy
,
cookie
));
}
});
}
}
}
private
static
void
OnDocumentClosing
(
object
sender
,
bool
updateActiveContext
)
...
...
@@ -905,16 +889,6 @@ private static void OnDocumentClosing(object sender, bool updateActiveContext)
{
projectTracker
.
NotifyWorkspace
(
workspace
=>
workspace
.
OnDocumentClosed
(
document
.
Id
,
document
.
Loader
,
updateActiveContext
));
}
if
(
project
.
_hierarchyEventSinks
.
TryGetValue
(
document
.
Id
,
out
var
subscribedSinks
))
{
foreach
(
var
subscribedSink
in
subscribedSinks
)
{
subscribedSink
.
hierarchy
.
UnadviseHierarchyEvents
(
subscribedSink
.
cookie
);
}
project
.
_hierarchyEventSinks
.
Remove
(
document
.
Id
);
}
}
private
static
void
OnDocumentUpdatedOnDisk
(
object
sender
,
EventArgs
e
)
...
...
@@ -1067,7 +1041,11 @@ internal void AddDocument(IVisualStudioHostDocument document, bool isCurrentCont
if
(
document
.
IsOpen
)
{
this
.
ProjectTracker
.
NotifyWorkspace
(
workspace
=>
workspace
.
OnDocumentOpened
(
document
.
Id
,
document
.
GetOpenTextBuffer
().
AsTextContainer
(),
isCurrentContext
));
this
.
ProjectTracker
.
NotifyWorkspace
(
workspace
=>
{
workspace
.
OnDocumentOpened
(
document
.
Id
,
document
.
GetOpenTextBuffer
().
AsTextContainer
(),
isCurrentContext
);
(
workspace
as
VisualStudioWorkspaceImpl
)?.
ConnectToSharedHierarchyEvents
(
document
);
});
}
}
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectTracker.cs
浏览文件 @
dba06e31
...
...
@@ -316,10 +316,13 @@ void addToInOrderToPush(AbstractProject project)
if
(
document
.
IsOpen
)
{
NotifyWorkspace
(
workspace
=>
{
workspace
.
OnDocumentOpened
(
document
.
Id
,
document
.
GetOpenTextBuffer
().
AsTextContainer
(),
isCurrentContext
:
LinkedFileUtilities
.
IsCurrentContextHierarchy
(
document
,
_runningDocumentTable
)));
isCurrentContext
:
LinkedFileUtilities
.
IsCurrentContextHierarchy
(
document
,
_runningDocumentTable
));
(
workspace
as
VisualStudioWorkspaceImpl
)?.
ConnectToSharedHierarchyEvents
(
document
);
});
}
}
}
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
浏览文件 @
dba06e31
...
...
@@ -51,6 +51,8 @@ internal abstract partial class VisualStudioWorkspaceImpl : VisualStudioWorkspac
private
readonly
Lazy
<
ForegroundThreadAffinitizedObject
>
_foregroundObject
=
new
Lazy
<
ForegroundThreadAffinitizedObject
>(()
=>
new
ForegroundThreadAffinitizedObject
());
private
readonly
Dictionary
<
DocumentId
,
List
<(
IVsHierarchy
hierarchy
,
uint
cookie
)>>
_hierarchyEventSinks
=
new
Dictionary
<
DocumentId
,
List
<(
IVsHierarchy
hierarchy
,
uint
cookie
)>>();
/// <summary>
/// The <see cref="DeferredInitializationState"/> that consists of the <see cref="VisualStudioProjectTracker" />
/// and other UI-initialized types. It will be created as long as a single project has been created.
...
...
@@ -981,6 +983,46 @@ internal void UpdateDocumentContextIfContainsDocument(IVsHierarchy sharedHierarc
OnDocumentContextUpdated
(
documentId
);
}
internal
void
ConnectToSharedHierarchyEvents
(
IVisualStudioHostDocument
document
)
{
Contract
.
ThrowIfFalse
(
document
.
IsOpen
);
var
project
=
document
.
Project
;
var
itemId
=
document
.
GetItemId
();
if
(
itemId
!=
(
uint
)
VSConstants
.
VSITEMID
.
Nil
)
{
var
sharedHierarchy
=
LinkedFileUtilities
.
GetSharedHierarchyForItem
(
project
.
Hierarchy
,
itemId
);
if
(
sharedHierarchy
!=
null
)
{
ProjectTracker
.
NotifyWorkspace
(
workspace
=>
{
var
eventSink
=
new
HierarchyEventsSink
((
VisualStudioWorkspaceImpl
)
workspace
,
sharedHierarchy
,
document
.
Id
);
if
(
ErrorHandler
.
Succeeded
(
sharedHierarchy
.
AdviseHierarchyEvents
(
eventSink
,
out
var
cookie
)))
{
_hierarchyEventSinks
.
MultiAdd
(
document
.
Id
,
(
sharedHierarchy
,
cookie
));
}
});
}
}
}
protected
override
void
OnDocumentClosing
(
DocumentId
documentId
)
{
base
.
OnDocumentClosing
(
documentId
);
if
(
_hierarchyEventSinks
.
TryGetValue
(
documentId
,
out
var
subscribedSinks
))
{
foreach
(
var
subscribedSink
in
subscribedSinks
)
{
subscribedSink
.
hierarchy
.
UnadviseHierarchyEvents
(
subscribedSink
.
cookie
);
}
_hierarchyEventSinks
.
Remove
(
documentId
);
}
}
/// <summary>
/// Finds the <see cref="DocumentId"/> related to the given <see cref="DocumentId"/> that
/// is in the current context. For regular files (non-shared and non-linked) and closed
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录