Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1d62e48d
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,发现更多精彩内容 >>
未验证
提交
1d62e48d
编写于
12月 14, 2018
作者:
J
Jason Malinowski
提交者:
GitHub
12月 14, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #31766 from jasonmalinowski/fix-handling-of-duplicate-project-names
Remove assumption that project names are unique
上级
5ffaf4f3
a231f1cd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
23 deletion
+43
-23
src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractLanguageService`2.IVsContainedLanguageFactory.cs
.../AbstractLanguageService`2.IVsContainedLanguageFactory.cs
+1
-1
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProject.cs
...e/Def/Implementation/ProjectSystem/VisualStudioProject.cs
+2
-4
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectFactory.cs
...mplementation/ProjectSystem/VisualStudioProjectFactory.cs
+10
-8
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
...Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
+30
-10
未找到文件。
src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractLanguageService`2.IVsContainedLanguageFactory.cs
浏览文件 @
1d62e48d
...
...
@@ -60,7 +60,7 @@ private VisualStudioProject FindMatchingProject(IVsHierarchy hierarchy, uint ite
return
null
;
}
return
this
.
Workspace
.
GetProject
ForUniqueName
(
projectName
);
return
this
.
Workspace
.
GetProject
WithHierarchyAndName
(
hierarchy
,
projectName
);
}
public
int
GetLanguage
(
IVsHierarchy
hierarchy
,
uint
itemid
,
IVsTextBufferCoordinator
bufferCoordinator
,
out
IVsContainedLanguage
language
)
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProject.cs
浏览文件 @
1d62e48d
...
...
@@ -19,7 +19,6 @@ internal sealed class VisualStudioProject
{
private
readonly
VisualStudioWorkspaceImpl
_workspace
;
private
readonly
HostDiagnosticUpdateSource
_hostDiagnosticUpdateSource
;
private
readonly
string
_projectUniqueName
;
/// <summary>
/// Provides dynamic source files for files added through <see cref="AddDynamicSourceFile" />.
...
...
@@ -119,7 +118,7 @@ internal sealed class VisualStudioProject
ImmutableArray
<
Lazy
<
IDynamicFileInfoProvider
,
FileExtensionsMetadata
>>
dynamicFileInfoProviders
,
HostDiagnosticUpdateSource
hostDiagnosticUpdateSource
,
ProjectId
id
,
string
projectUnique
Name
,
string
display
Name
,
string
language
,
string
directoryNameOpt
)
{
...
...
@@ -129,8 +128,7 @@ internal sealed class VisualStudioProject
Id
=
id
;
Language
=
language
;
_displayName
=
projectUniqueName
;
_projectUniqueName
=
projectUniqueName
;
_displayName
=
displayName
;
if
(
directoryNameOpt
!=
null
)
{
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectFactory.cs
浏览文件 @
1d62e48d
...
...
@@ -31,33 +31,35 @@ internal sealed class VisualStudioProjectFactory
_hostDiagnosticUpdateSource
=
hostDiagnosticUpdateSource
;
}
public
VisualStudioProject
CreateAndAddToWorkspace
(
string
project
Unique
Name
,
string
language
)
public
VisualStudioProject
CreateAndAddToWorkspace
(
string
project
System
Name
,
string
language
)
{
return
CreateAndAddToWorkspace
(
project
Unique
Name
,
language
,
new
VisualStudioProjectCreationInfo
());
return
CreateAndAddToWorkspace
(
project
System
Name
,
language
,
new
VisualStudioProjectCreationInfo
());
}
public
VisualStudioProject
CreateAndAddToWorkspace
(
string
project
Unique
Name
,
string
language
,
VisualStudioProjectCreationInfo
creationInfo
)
public
VisualStudioProject
CreateAndAddToWorkspace
(
string
project
System
Name
,
string
language
,
VisualStudioProjectCreationInfo
creationInfo
)
{
// HACK: Fetch this service to ensure it's still created on the UI thread; once this is moved off we'll need to fix up it's constructor to be free-threaded.
_visualStudioWorkspaceImpl
.
Services
.
GetRequiredService
<
VisualStudioMetadataReferenceManager
>();
var
id
=
ProjectId
.
CreateNewId
(
project
Unique
Name
);
var
id
=
ProjectId
.
CreateNewId
(
project
System
Name
);
var
directoryNameOpt
=
creationInfo
.
FilePath
!=
null
?
Path
.
GetDirectoryName
(
creationInfo
.
FilePath
)
:
null
;
var
project
=
new
VisualStudioProject
(
_visualStudioWorkspaceImpl
,
_dynamicFileInfoProviders
,
_hostDiagnosticUpdateSource
,
id
,
projectUniqueName
,
language
,
directoryNameOpt
);
// We will use the project system name as the default display name of the project
var
project
=
new
VisualStudioProject
(
_visualStudioWorkspaceImpl
,
_dynamicFileInfoProviders
,
_hostDiagnosticUpdateSource
,
id
,
displayName
:
projectSystemName
,
language
,
directoryNameOpt
);
var
versionStamp
=
creationInfo
.
FilePath
!=
null
?
VersionStamp
.
Create
(
File
.
GetLastWriteTimeUtc
(
creationInfo
.
FilePath
))
:
VersionStamp
.
Create
();
var
assemblyName
=
creationInfo
.
AssemblyName
??
project
Unique
Name
;
var
assemblyName
=
creationInfo
.
AssemblyName
??
project
System
Name
;
_visualStudioWorkspaceImpl
.
AddProjectToInternalMaps
(
project
,
creationInfo
.
Hierarchy
,
creationInfo
.
ProjectGuid
,
project
Unique
Name
);
_visualStudioWorkspaceImpl
.
AddProjectToInternalMaps
(
project
,
creationInfo
.
Hierarchy
,
creationInfo
.
ProjectGuid
,
project
System
Name
);
_visualStudioWorkspaceImpl
.
ApplyChangeToWorkspace
(
w
=>
{
var
projectInfo
=
ProjectInfo
.
Create
(
id
,
versionStamp
,
name
:
project
Unique
Name
,
name
:
project
System
Name
,
assemblyName
:
assemblyName
,
language
:
language
,
filePath
:
creationInfo
.
FilePath
,
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
浏览文件 @
1d62e48d
...
...
@@ -61,7 +61,7 @@ internal abstract partial class VisualStudioWorkspaceImpl : VisualStudioWorkspac
private
ImmutableDictionary
<
ProjectId
,
IVsHierarchy
>
_projectToHierarchyMap
=
ImmutableDictionary
<
ProjectId
,
IVsHierarchy
>.
Empty
;
private
ImmutableDictionary
<
ProjectId
,
Guid
>
_projectToGuidMap
=
ImmutableDictionary
<
ProjectId
,
Guid
>.
Empty
;
private
ImmutableDictionary
<
string
,
VisualStudioProject
>
_projectUniqueNameToProjectMap
=
ImmutableDictionary
<
string
,
VisualStudioProject
>.
Empty
;
private
Dictionary
<
string
,
List
<
VisualStudioProject
>>
_projectSystemNameToProjectsMap
=
new
Dictionary
<
string
,
List
<
VisualStudioProject
>>()
;
/// <summary>
/// A set of documents that were added by <see cref="VisualStudioProject.AddSourceTextContainer"/>, and aren't otherwise
...
...
@@ -129,13 +129,13 @@ public void CheckForOpenDocuments(ImmutableArray<string> newFileNames)
_openFileTrackerOpt
?.
CheckForFilesBeingOpen
(
newFileNames
);
}
internal
void
AddProjectToInternalMaps
(
VisualStudioProject
project
,
IVsHierarchy
hierarchy
,
Guid
guid
,
string
project
Unique
Name
)
internal
void
AddProjectToInternalMaps
(
VisualStudioProject
project
,
IVsHierarchy
hierarchy
,
Guid
guid
,
string
project
System
Name
)
{
lock
(
_gate
)
{
_projectToHierarchyMap
=
_projectToHierarchyMap
.
Add
(
project
.
Id
,
hierarchy
);
_projectToGuidMap
=
_projectToGuidMap
.
Add
(
project
.
Id
,
guid
);
_project
UniqueNameToProjectMap
=
_projectUniqueNameToProjectMap
.
Add
(
projectUnique
Name
,
project
);
_project
SystemNameToProjectsMap
.
MultiAdd
(
projectSystem
Name
,
project
);
}
}
...
...
@@ -181,10 +181,26 @@ internal ContainedDocument TryGetContainedDocument(DocumentId documentId)
return
ContainedDocument
.
TryGetContainedDocument
(
documentId
);
}
internal
VisualStudioProject
GetProject
ForUniqueName
(
string
projectName
)
internal
VisualStudioProject
GetProject
WithHierarchyAndName
(
IVsHierarchy
hierarchy
,
string
projectName
)
{
// This doesn't take a lock since _projectNameToProjectMap is immutable
return
_projectUniqueNameToProjectMap
.
GetValueOrDefault
(
projectName
,
defaultValue
:
null
);
lock
(
_gate
)
{
if
(
_projectSystemNameToProjectsMap
.
TryGetValue
(
projectName
,
out
var
projects
))
{
foreach
(
var
project
in
projects
)
{
if
(
_projectToHierarchyMap
.
TryGetValue
(
project
.
Id
,
out
var
projectHierarchy
))
{
if
(
projectHierarchy
==
hierarchy
)
{
return
project
;
}
}
}
}
}
return
null
;
}
[
Obsolete
(
"This is a compatibility shim for Live Unit Testing; please do not use it."
)]
...
...
@@ -1330,12 +1346,16 @@ protected internal override void OnProjectRemoved(ProjectId projectId)
_projectToGuidMap
=
_projectToGuidMap
.
Remove
(
projectId
);
_projectToHierarchyMap
=
_projectToHierarchyMap
.
Remove
(
projectId
);
foreach
(
var
pair
in
_projectUniqueNameToProject
Map
)
foreach
(
var
(
projectName
,
projects
)
in
_projectSystemNameToProjects
Map
)
{
if
(
p
air
.
Value
.
Id
==
projectId
)
if
(
p
rojects
.
RemoveAll
(
p
=>
p
.
Id
==
projectId
)
>
0
)
{
_projectUniqueNameToProjectMap
=
_projectUniqueNameToProjectMap
.
Remove
(
pair
.
Key
);
break
;
if
(
projects
.
Count
==
0
)
{
_projectSystemNameToProjectsMap
.
Remove
(
projectName
);
}
return
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录