Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a4a5ffdc
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,发现更多精彩内容 >>
提交
a4a5ffdc
编写于
5月 12, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid loading the Elfie dll until the user actualy enables the search feature.
上级
acfc0f93
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
23 deletion
+22
-23
src/VisualStudio/Core/Def/SymbolSearch/SymbolSearchService.Update.cs
...tudio/Core/Def/SymbolSearch/SymbolSearchService.Update.cs
+13
-14
src/VisualStudio/Core/Def/SymbolSearch/SymbolSearchService.cs
...VisualStudio/Core/Def/SymbolSearch/SymbolSearchService.cs
+9
-9
未找到文件。
src/VisualStudio/Core/Def/SymbolSearch/SymbolSearchService.Update.cs
浏览文件 @
a4a5ffdc
...
...
@@ -44,8 +44,6 @@ internal partial class SymbolSearchService
private
const
string
MicrosoftAssemblyReferencesName
=
"MicrosoftAssemblyReferences"
;
private
static
readonly
LinkedList
<
string
>
s_log
=
new
LinkedList
<
string
>();
private
readonly
int
_dataFormatVersion
=
AddReferenceDatabase
.
TextFileFormatVersion
;
/// <summary>
/// Cancellation support for the task we use to keep the local database up to date.
/// When VS shuts down it will dispose us. We'll cancel the task at that point.
...
...
@@ -58,9 +56,6 @@ internal partial class SymbolSearchService
private
readonly
ConcurrentDictionary
<
string
,
object
>
_sourceToUpdateSentinel
=
new
ConcurrentDictionary
<
string
,
object
>();
private
readonly
DirectoryInfo
_cacheDirectoryInfo
;
//private readonly FileInfo _databaseFileInfo;
// Interfaces that abstract out the external functionality we need. Used so we can easily
// mock behavior during tests.
private
readonly
IPackageInstallerService
_installerService
;
...
...
@@ -70,6 +65,7 @@ internal partial class SymbolSearchService
private
readonly
IRemoteControlService
_remoteControlService
;
private
readonly
IPatchService
_patchService
;
private
readonly
IDatabaseFactoryService
_databaseFactoryService
;
private
readonly
string
_localSettingsDirectory
;
private
readonly
Func
<
Exception
,
bool
>
_reportAndSwallowException
;
public
void
Dispose
()
...
...
@@ -125,23 +121,26 @@ internal Task UpdateSourceInBackgroundAsync(string source)
// We were the first ones to try to update this source. Spawn off a task to do
// the updating.
return
new
Updater
(
this
,
source
).
UpdateInBackgroundAsync
();
return
new
Updater
(
this
,
source
,
_localSettingsDirectory
).
UpdateInBackgroundAsync
();
}
private
class
Updater
{
private
readonly
SymbolSearchService
_service
;
private
readonly
string
_source
;
private
readonly
DirectoryInfo
_cacheDirectoryInfo
;
private
readonly
FileInfo
_databaseFileInfo
;
public
Updater
(
SymbolSearchService
service
,
string
source
)
public
Updater
(
SymbolSearchService
service
,
string
source
,
string
localSettingsDirectory
)
{
_service
=
service
;
_source
=
source
;
var
fileName
=
ConvertToFileName
(
source
);
_cacheDirectoryInfo
=
new
DirectoryInfo
(
Path
.
Combine
(
localSettingsDirectory
,
"PackageCache"
,
string
.
Format
(
Invariant
(
$"Format
{
AddReferenceDatabase
.
TextFileFormatVersion
}
"
))));
_databaseFileInfo
=
new
FileInfo
(
Path
.
Combine
(
_
service
.
_cacheDirectoryInfo
.
FullName
,
fileName
+
".txt"
));
Path
.
Combine
(
_
cacheDirectoryInfo
.
FullName
,
ConvertToFileName
(
source
)
+
".txt"
));
}
/// <summary>
...
...
@@ -254,12 +253,12 @@ private void CleanCacheDirectory()
_service
.
LogInfo
(
"Cleaning cache directory"
);
// (intentionally not wrapped in IOUtilities. If this throws we want to restart).
if
(!
_service
.
_ioService
.
Exists
(
_
service
.
_
cacheDirectoryInfo
))
if
(!
_service
.
_ioService
.
Exists
(
_cacheDirectoryInfo
))
{
_service
.
LogInfo
(
"Creating cache directory"
);
// (intentionally not wrapped in IOUtilities. If this throws we want to restart).
_service
.
_ioService
.
Create
(
_
service
.
_
cacheDirectoryInfo
);
_service
.
_ioService
.
Create
(
_cacheDirectoryInfo
);
_service
.
LogInfo
(
"Cache directory created"
);
}
...
...
@@ -268,7 +267,7 @@ private void CleanCacheDirectory()
private
async
Task
<
TimeSpan
>
DownloadFullDatabaseAsync
()
{
var
serverPath
=
Invariant
(
$"Elfie_V
{
_service
.
_data
FormatVersion
}
/Latest.xml"
);
var
serverPath
=
Invariant
(
$"Elfie_V
{
AddReferenceDatabase
.
TextFile
FormatVersion
}
/Latest.xml"
);
_service
.
LogInfo
(
$"Downloading and processing full database:
{
serverPath
}
"
);
...
...
@@ -332,7 +331,7 @@ private async Task WriteDatabaseFile(byte[] bytes)
()
=>
{
var
guidString
=
Guid
.
NewGuid
().
ToString
();
var
tempFilePath
=
Path
.
Combine
(
_
service
.
_
cacheDirectoryInfo
.
FullName
,
guidString
+
".tmp"
);
var
tempFilePath
=
Path
.
Combine
(
_cacheDirectoryInfo
.
FullName
,
guidString
+
".tmp"
);
_service
.
LogInfo
(
$"Temp file path:
{
tempFilePath
}
"
);
...
...
@@ -402,7 +401,7 @@ private async Task<TimeSpan> PatchLocalDatabaseAsync()
var
databaseVersion
=
database
.
DatabaseVersion
;
// Now attempt to download and apply patch file.
var
serverPath
=
Invariant
(
$"Elfie_V
{
_service
.
_data
FormatVersion
}
/
{
database
.
DatabaseVersion
}
_Patch.xml"
);
var
serverPath
=
Invariant
(
$"Elfie_V
{
AddReferenceDatabase
.
TextFile
FormatVersion
}
/
{
database
.
DatabaseVersion
}
_Patch.xml"
);
_service
.
LogInfo
(
"Downloading and processing patch file: "
+
serverPath
);
...
...
src/VisualStudio/Core/Def/SymbolSearch/SymbolSearchService.cs
浏览文件 @
a4a5ffdc
...
...
@@ -36,7 +36,8 @@ internal partial class SymbolSearchService :
ISymbolSearchService
,
IDisposable
{
private
ConcurrentDictionary
<
string
,
AddReferenceDatabase
>
_sourceToDatabase
=
new
ConcurrentDictionary
<
string
,
AddReferenceDatabase
>();
// Value is typed as 'object' so we don't load the elfie dll until actually necessary.
private
ConcurrentDictionary
<
string
,
object
>
_sourceToDatabase
=
new
ConcurrentDictionary
<
string
,
object
>();
public
SymbolSearchService
(
VSShell
.
SVsServiceProvider
serviceProvider
,
...
...
@@ -104,12 +105,9 @@ private static IRemoteControlService CreateRemoteControlService(VSShell.SVsServi
_remoteControlService
=
remoteControlService
;
_patchService
=
patchService
;
_databaseFactoryService
=
databaseFactoryService
;
_localSettingsDirectory
=
localSettingsDirectory
;
_reportAndSwallowException
=
reportAndSwallowException
;
_cacheDirectoryInfo
=
new
DirectoryInfo
(
Path
.
Combine
(
localSettingsDirectory
,
"PackageCache"
,
string
.
Format
(
Invariant
(
$"Format
{
_dataFormatVersion
}
"
))));
// _databaseFileInfo = new FileInfo(Path.Combine(_cacheDirectoryInfo.FullName, "NuGetCache.txt"));
_cancellationTokenSource
=
cancellationTokenSource
;
_cancellationToken
=
_cancellationTokenSource
.
Token
;
}
...
...
@@ -117,13 +115,14 @@ private static IRemoteControlService CreateRemoteControlService(VSShell.SVsServi
public
IEnumerable
<
PackageWithTypeResult
>
FindPackagesWithType
(
string
source
,
string
name
,
int
arity
,
CancellationToken
cancellationToken
)
{
AddReferenceDatabase
database
;
if
(!
_sourceToDatabase
.
TryGetValue
(
source
,
out
database
))
object
databaseObj
;
if
(!
_sourceToDatabase
.
TryGetValue
(
source
,
out
database
Obj
))
{
// Don't have a database to search.
yield
break
;
}
var
database
=
databaseObj
as
AddReferenceDatabase
;
if
(
name
==
"var"
)
{
// never find anything named 'var'.
...
...
@@ -190,13 +189,14 @@ private static IRemoteControlService CreateRemoteControlService(VSShell.SVsServi
string
name
,
int
arity
,
CancellationToken
cancellationToken
)
{
// Our reference assembly data is stored in the nuget.org DB.
AddReferenceDatabase
database
;
if
(!
_sourceToDatabase
.
TryGetValue
(
NugetOrgSource
,
out
database
))
object
databaseObj
;
if
(!
_sourceToDatabase
.
TryGetValue
(
NugetOrgSource
,
out
database
Obj
))
{
// Don't have a database to search.
yield
break
;
}
var
database
=
(
AddReferenceDatabase
)
databaseObj
;
if
(
name
==
"var"
)
{
// never find anything named 'var'.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录