Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1e5f1aa3
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,发现更多精彩内容 >>
提交
1e5f1aa3
编写于
5月 19, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move to a single proxy type.
上级
35449fa6
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
62 addition
and
124 deletion
+62
-124
src/VisualStudio/Core/Def/Packaging/IPackageInstallerProxy.cs
...VisualStudio/Core/Def/Packaging/IPackageInstallerProxy.cs
+0
-15
src/VisualStudio/Core/Def/Packaging/IPackageServicesProxy.cs
src/VisualStudio/Core/Def/Packaging/IPackageServicesProxy.cs
+14
-2
src/VisualStudio/Core/Def/Packaging/IPackageSourceProviderProxy.cs
...lStudio/Core/Def/Packaging/IPackageSourceProviderProxy.cs
+0
-15
src/VisualStudio/Core/Def/Packaging/IPackageUninstallerProxy.cs
...sualStudio/Core/Def/Packaging/IPackageUninstallerProxy.cs
+0
-15
src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs
...udio/Core/Def/Packaging/PackageInstallerServiceFactory.cs
+35
-67
src/VisualStudio/Core/Def/ServicesVisualStudio.csproj
src/VisualStudio/Core/Def/ServicesVisualStudio.csproj
+1
-4
src/VisualStudio/Core/Def/SymbolSearch/AbstractDelayStartedService.cs
...udio/Core/Def/SymbolSearch/AbstractDelayStartedService.cs
+12
-6
未找到文件。
src/VisualStudio/Core/Def/Packaging/IPackageInstallerProxy.cs
已删除
100644 → 0
浏览文件 @
35449fa6
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
EnvDTE
;
namespace
Microsoft.VisualStudio.LanguageServices.Packaging
{
// Wrapper types to ensure we delay load the nuget libraries.
internal
interface
IPackageInstallerProxy
{
void
InstallPackage
(
string
source
,
Project
project
,
string
packageId
,
string
version
,
bool
ignoreDependencies
);
}
}
src/VisualStudio/Core/Def/Packaging/IPackage
Installer
ServicesProxy.cs
→
src/VisualStudio/Core/Def/Packaging/IPackageServicesProxy.cs
浏览文件 @
1e5f1aa3
...
...
@@ -9,11 +9,22 @@
namespace
Microsoft.VisualStudio.LanguageServices.Packaging
{
// Wrapper types to ensure we delay load the nuget libraries.
internal
interface
IPackage
Installer
ServicesProxy
internal
interface
IPackageServicesProxy
{
event
EventHandler
SourcesChanged
;
/// <summary>
/// This method just forwards along <see cref="IVsPackageSourceProvider.GetSources(bool, bool)"/>
/// </summary>
IEnumerable
<
KeyValuePair
<
string
,
string
>>
GetSources
(
bool
includeUnOfficial
,
bool
includeDisabled
);
IEnumerable
<
PackageMetadata
>
GetInstalledPackages
(
Project
project
);
bool
IsPackageInstalled
(
Project
project
,
string
id
);
void
InstallPackage
(
string
source
,
Project
project
,
string
packageId
,
string
version
,
bool
ignoreDependencies
);
void
UninstallPackage
(
Project
project
,
string
packageId
,
bool
removeDependencies
);
}
internal
class
PackageMetadata
...
...
@@ -27,4 +38,5 @@ public PackageMetadata(string id, string versionString)
VersionString
=
versionString
;
}
}
}
\ No newline at end of file
}
src/VisualStudio/Core/Def/Packaging/IPackageSourceProviderProxy.cs
已删除
100644 → 0
浏览文件 @
35449fa6
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Microsoft.VisualStudio.LanguageServices.Packaging
{
// Wrapper types to ensure we delay load the nuget libraries.
internal
interface
IPackageSourceProviderProxy
{
event
EventHandler
SourcesChanged
;
IEnumerable
<
KeyValuePair
<
string
,
string
>>
GetSources
(
bool
includeUnOfficial
,
bool
includeDisabled
);
}
}
src/VisualStudio/Core/Def/Packaging/IPackageUninstallerProxy.cs
已删除
100644 → 0
浏览文件 @
35449fa6
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
EnvDTE
;
namespace
Microsoft.VisualStudio.LanguageServices.Packaging
{
// Wrapper types to ensure we delay load the nuget libraries.
internal
interface
IPackageUninstallerProxy
{
void
UninstallPackage
(
Project
project
,
string
packageId
,
bool
removeDependencies
);
}
}
src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs
浏览文件 @
1e5f1aa3
...
...
@@ -42,11 +42,9 @@ internal partial class PackageInstallerService : AbstractDelayStartedService, IP
private
readonly
VisualStudioWorkspaceImpl
_workspace
;
private
readonly
IVsEditorAdaptersFactoryService
_editorAdaptersFactoryService
;
// We refer to projc
private
IPackageInstallerServicesProxy
_packageInstallerServices
;
private
IPackageInstallerProxy
_packageInstaller
;
private
IPackageUninstallerProxy
_packageUninstaller
;
private
IPackageSourceProviderProxy
_packageSourceProvider
;
// We refer to the package services through proxy types so that we can
// delay loading their DLLs until we actually need them.
private
IPackageServicesProxy
_packageServices
;
private
CancellationTokenSource
_tokenSource
=
new
CancellationTokenSource
();
...
...
@@ -75,11 +73,7 @@ internal partial class PackageInstallerService : AbstractDelayStartedService, IP
public
event
EventHandler
PackageSourcesChanged
;
public
bool
IsEnabled
=>
_packageInstallerServices
!=
null
&&
_packageInstallerServices
!=
null
&&
_packageUninstaller
!=
null
&&
_packageSourceProvider
!=
null
;
public
bool
IsEnabled
=>
_packageServices
!=
null
;
protected
override
void
EnableService
()
{
...
...
@@ -99,14 +93,12 @@ protected override void EnableService()
return
;
}
_packageInstallerServices
=
new
PackageInstallerServicesProxy
(
packageInstallerServices
);
_packageInstaller
=
new
PackageInstallerProxy
(
packageInstaller
);
_packageUninstaller
=
new
PackageUninstallerProxy
(
packageUninstaller
);
_packageSourceProvider
=
new
PackageSourceProviderProxy
(
packageSourceProvider
);
_packageServices
=
new
PackageServicesProxy
(
packageInstallerServices
,
packageInstaller
,
packageUninstaller
,
packageSourceProvider
);
// Start listening to additional events workspace changes.
_workspace
.
WorkspaceChanged
+=
OnWorkspaceChanged
;
_packageS
ourceProvider
.
SourcesChanged
+=
OnSourceProviderSourcesChanged
;
_packageS
ervices
.
SourcesChanged
+=
OnSourceProviderSourcesChanged
;
}
protected
override
void
StopWorking
()
...
...
@@ -120,7 +112,7 @@ protected override void StopWorking()
// Stop listening to workspace changes.
_workspace
.
WorkspaceChanged
-=
OnWorkspaceChanged
;
_packageS
ourceProvider
.
SourcesChanged
-=
OnSourceProviderSourcesChanged
;
_packageS
ervices
.
SourcesChanged
-=
OnSourceProviderSourcesChanged
;
}
protected
override
void
StartWorking
()
...
...
@@ -145,7 +137,7 @@ private void OnSourceProviderSourcesChanged(object sender, EventArgs e)
this
.
AssertIsForeground
();
PackageSources
=
_packageS
ourceProvider
.
GetSources
(
includeUnOfficial
:
true
,
includeDisabled
:
false
)
PackageSources
=
_packageS
ervices
.
GetSources
(
includeUnOfficial
:
true
,
includeDisabled
:
false
)
.
Select
(
r
=>
new
PackageSource
(
r
.
Key
,
r
.
Value
))
.
ToImmutableArrayOrEmpty
();
...
...
@@ -165,7 +157,7 @@ private void OnSourceProviderSourcesChanged(object sender, EventArgs e)
// The 'workspace == _workspace' line is probably not necessary. However, we include
// it just to make sure that someone isn't trying to install a package into a workspace
// other than the VisualStudioWorkspace.
if
(
workspace
==
_workspace
&&
_workspace
!=
null
&&
_package
Installer
Services
!=
null
)
if
(
workspace
==
_workspace
&&
_workspace
!=
null
&&
_packageServices
!=
null
)
{
var
projectId
=
documentId
.
ProjectId
;
var
dte
=
_workspace
.
GetVsService
<
SDTE
,
EnvDTE
.
DTE
>();
...
...
@@ -196,10 +188,10 @@ private void OnSourceProviderSourcesChanged(object sender, EventArgs e)
{
try
{
if
(!
_package
Installer
Services
.
IsPackageInstalled
(
dteProject
,
packageName
))
if
(!
_packageServices
.
IsPackageInstalled
(
dteProject
,
packageName
))
{
dte
.
StatusBar
.
Text
=
string
.
Format
(
ServicesVSResources
.
Installing_0
,
packageName
);
_package
Installer
.
InstallPackage
(
source
,
dteProject
,
packageName
,
versionOpt
,
ignoreDependencies
:
false
);
_package
Services
.
InstallPackage
(
source
,
dteProject
,
packageName
,
versionOpt
,
ignoreDependencies
:
false
);
var
installedVersion
=
GetInstalledVersion
(
packageName
,
dteProject
);
dte
.
StatusBar
.
Text
=
string
.
Format
(
ServicesVSResources
.
Installing_0_completed
,
...
...
@@ -237,13 +229,13 @@ private static string GetStatusBarText(string packageName, string installedVersi
try
{
if
(
_package
Installer
Services
.
IsPackageInstalled
(
dteProject
,
packageName
))
if
(
_packageServices
.
IsPackageInstalled
(
dteProject
,
packageName
))
{
dte
.
StatusBar
.
Text
=
string
.
Format
(
ServicesVSResources
.
Uninstalling_0
,
packageName
);
var
installedVersion
=
GetInstalledVersion
(
packageName
,
dteProject
);
_package
Uninstaller
.
UninstallPackage
(
dteProject
,
packageName
,
removeDependencies
:
true
);
_package
Services
.
UninstallPackage
(
dteProject
,
packageName
,
removeDependencies
:
true
);
dte
.
StatusBar
.
Text
=
string
.
Format
(
ServicesVSResources
.
Uninstalling_0_completed
,
dte
.
StatusBar
.
Text
=
string
.
Format
(
ServicesVSResources
.
Uninstalling_0_completed
,
GetStatusBarText
(
packageName
,
installedVersion
));
return
true
;
...
...
@@ -272,7 +264,7 @@ private string GetInstalledVersion(string packageName, EnvDTE.Project dteProject
try
{
var
installedPackages
=
_package
Installer
Services
.
GetInstalledPackages
(
dteProject
);
var
installedPackages
=
_packageServices
.
GetInstalledPackages
(
dteProject
);
var
metadata
=
installedPackages
.
FirstOrDefault
(
m
=>
m
.
Id
==
packageName
);
return
metadata
?.
VersionString
;
}
...
...
@@ -343,7 +335,7 @@ private void ProcessBatchedChangesOnForeground(CancellationToken cancellationTok
}
// If we've been disconnected, then there's no point proceeding.
if
(
_workspace
==
null
||
_package
Installer
Services
==
null
)
if
(
_workspace
==
null
||
_packageServices
==
null
)
{
return
;
}
...
...
@@ -418,7 +410,7 @@ private void ProcessProjectChange(Solution solution, ProjectId projectId)
// Calling into nuget. Assume they may fail for any reason.
try
{
var
installedPackageMetadata
=
_package
Installer
Services
.
GetInstalledPackages
(
dteProject
);
var
installedPackageMetadata
=
_packageServices
.
GetInstalledPackages
(
dteProject
);
installedPackages
.
AddRange
(
installedPackageMetadata
.
Select
(
m
=>
new
KeyValuePair
<
string
,
string
>(
m
.
Id
,
m
.
VersionString
)));
}
catch
(
Exception
e
)
when
(
FatalError
.
ReportWithoutCrash
(
e
))
...
...
@@ -577,83 +569,59 @@ public uint GetTokens(uint dwMaxTokens, IVsSearchToken[] rgpSearchTokens)
}
}
private
class
Package
InstallerServicesProxy
:
IPackageInstaller
ServicesProxy
private
class
Package
ServicesProxy
:
IPackage
ServicesProxy
{
private
readonly
IVsPackageInstallerServices
_underlying
;
private
readonly
IVsPackageInstaller
_packageInstaller
;
private
readonly
IVsPackageInstallerServices
_packageInstallerServices
;
private
readonly
IVsPackageSourceProvider
_packageSourceProvider
;
private
readonly
IVsPackageUninstaller
_packageUninstaller
;
public
Package
InstallerServicesProxy
(
IVsPackageInstallerServices
packageInstallerServices
)
public
Package
ServicesProxy
(
IVsPackageInstallerServices
packageInstallerServices
,
IVsPackageInstaller
packageInstaller
,
IVsPackageUninstaller
packageUninstaller
,
IVsPackageSourceProvider
packageSourceProvider
)
{
_underlying
=
packageInstallerServices
;
_packageInstallerServices
=
packageInstallerServices
;
_packageInstaller
=
packageInstaller
;
_packageUninstaller
=
packageUninstaller
;
_packageSourceProvider
=
packageSourceProvider
;
}
public
IEnumerable
<
PackageMetadata
>
GetInstalledPackages
(
EnvDTE
.
Project
project
)
{
return
_
underlying
.
GetInstalledPackages
(
project
)
return
_
packageInstallerServices
.
GetInstalledPackages
(
project
)
.
Select
(
m
=>
new
PackageMetadata
(
m
.
Id
,
m
.
VersionString
))
.
ToList
();
}
public
bool
IsPackageInstalled
(
EnvDTE
.
Project
project
,
string
id
)
{
return
_underlying
.
IsPackageInstalled
(
project
,
id
);
}
}
private
class
PackageInstallerProxy
:
IPackageInstallerProxy
{
private
IVsPackageInstaller
_underlying
;
public
PackageInstallerProxy
(
IVsPackageInstaller
packageInstaller
)
{
_underlying
=
packageInstaller
;
return
_packageInstallerServices
.
IsPackageInstalled
(
project
,
id
);
}
public
void
InstallPackage
(
string
source
,
EnvDTE
.
Project
project
,
string
packageId
,
string
version
,
bool
ignoreDependencies
)
{
_underlying
.
InstallPackage
(
source
,
project
,
packageId
,
version
,
ignoreDependencies
);
}
}
private
class
PackageSourceProviderProxy
:
IPackageSourceProviderProxy
{
private
IVsPackageSourceProvider
_underlying
;
public
PackageSourceProviderProxy
(
IVsPackageSourceProvider
packageSourceProvider
)
{
this
.
_underlying
=
packageSourceProvider
;
_packageInstaller
.
InstallPackage
(
source
,
project
,
packageId
,
version
,
ignoreDependencies
);
}
public
event
EventHandler
SourcesChanged
{
add
{
_
underlying
.
SourcesChanged
+=
value
;
_
packageSourceProvider
.
SourcesChanged
+=
value
;
}
remove
{
_
underlying
.
SourcesChanged
-=
value
;
_
packageSourceProvider
.
SourcesChanged
-=
value
;
}
}
public
IEnumerable
<
KeyValuePair
<
string
,
string
>>
GetSources
(
bool
includeUnOfficial
,
bool
includeDisabled
)
{
return
_underlying
.
GetSources
(
includeUnOfficial
,
includeDisabled
);
}
}
private
class
PackageUninstallerProxy
:
IPackageUninstallerProxy
{
private
IVsPackageUninstaller
_underlying
;
public
PackageUninstallerProxy
(
IVsPackageUninstaller
packageUninstaller
)
{
_underlying
=
packageUninstaller
;
return
_packageSourceProvider
.
GetSources
(
includeUnOfficial
,
includeDisabled
);
}
public
void
UninstallPackage
(
EnvDTE
.
Project
project
,
string
packageId
,
bool
removeDependencies
)
{
_
underlying
.
UninstallPackage
(
project
,
packageId
,
removeDependencies
);
_
packageUninstaller
.
UninstallPackage
(
project
,
packageId
,
removeDependencies
);
}
}
}
...
...
src/VisualStudio/Core/Def/ServicesVisualStudio.csproj
浏览文件 @
1e5f1aa3
...
...
@@ -155,10 +155,7 @@
<Compile
Include=
"Implementation\Workspace\VisualStudioProjectCacheHostServiceFactory.cs"
/>
<Compile
Include=
"IRoslynTelemetrySetup.cs"
/>
<Compile
Include=
"Packaging\Interop\SVsRemoteControlService.cs"
/>
<Compile
Include=
"Packaging\IPackageInstallerProxy.cs"
/>
<Compile
Include=
"Packaging\IPackageInstallerServicesProxy.cs"
/>
<Compile
Include=
"Packaging\IPackageSourceProviderProxy.cs"
/>
<Compile
Include=
"Packaging\IPackageUninstallerProxy.cs"
/>
<Compile
Include=
"Packaging\IPackageServicesProxy.cs"
/>
<Compile
Include=
"SymbolSearch\AbstractDelayStartedService.cs"
/>
<Compile
Include=
"SymbolSearch\IAddReferenceDatabaseWrapper.cs"
/>
<Compile
Include=
"SymbolSearch\IDatabaseFactoryService.cs"
/>
...
...
src/VisualStudio/Core/Def/SymbolSearch/AbstractDelayStartedService.cs
浏览文件 @
1e5f1aa3
...
...
@@ -10,9 +10,15 @@
namespace
Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
/// <summary>
/// Base type for services that we want to delay running until certain criteria is met.
/// For example, we don't want to run the <see cref="SymbolSearchService"/> core codepath
/// if the user has not enabled the features that need it. That helps us avoid loading
/// dlls unnecessarily and bloating the VS memory space.
/// </summary>
internal
abstract
class
AbstractDelayStartedService
:
ForegroundThreadAffinitizedObject
{
pr
otected
readonly
List
<
string
>
R
egisteredLanguageNames
=
new
List
<
string
>();
pr
ivate
readonly
List
<
string
>
_r
egisteredLanguageNames
=
new
List
<
string
>();
protected
readonly
Workspace
Workspace
;
...
...
@@ -50,8 +56,8 @@ internal void Connect(string languageName)
return
;
}
this
.
R
egisteredLanguageNames
.
Add
(
languageName
);
if
(
this
.
R
egisteredLanguageNames
.
Count
==
1
)
this
.
_r
egisteredLanguageNames
.
Add
(
languageName
);
if
(
this
.
_r
egisteredLanguageNames
.
Count
==
1
)
{
// Register to hear about option changing.
var
optionsService
=
Workspace
.
Services
.
GetService
<
IOptionService
>();
...
...
@@ -66,7 +72,7 @@ private void OnOptionChanged(object sender, EventArgs e)
{
this
.
AssertIsForeground
();
if
(!
R
egisteredLanguageNames
.
Any
(
IsRegisteredForLanguage
))
if
(!
_r
egisteredLanguageNames
.
Any
(
IsRegisteredForLanguage
))
{
// The feature is not enabled for any registered languages.
return
;
...
...
@@ -101,8 +107,8 @@ internal void Disconnect(string languageName)
return
;
}
R
egisteredLanguageNames
.
Remove
(
languageName
);
if
(
R
egisteredLanguageNames
.
Count
==
0
)
_r
egisteredLanguageNames
.
Remove
(
languageName
);
if
(
_r
egisteredLanguageNames
.
Count
==
0
)
{
if
(
_enabled
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录