Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
7bae6740
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,发现更多精彩内容 >>
提交
7bae6740
编写于
3月 01, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Report exceptions we encounter in the package search update service.
上级
d0882623
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
40 deletion
+43
-40
src/Features/Core/Portable/Shared/Utilities/IOUtilities.cs
src/Features/Core/Portable/Shared/Utilities/IOUtilities.cs
+12
-17
src/VisualStudio/Core/Def/Packaging/PackageSearchService.Update.cs
...lStudio/Core/Def/Packaging/PackageSearchService.Update.cs
+14
-7
src/VisualStudio/Core/Def/Packaging/PackageSearchService.cs
src/VisualStudio/Core/Def/Packaging/PackageSearchService.cs
+5
-4
src/VisualStudio/Core/Test/Packaging/PackageSearchServiceTests.vb
...alStudio/Core/Test/Packaging/PackageSearchServiceTests.vb
+12
-12
未找到文件。
src/Features/Core/Portable/Shared/Utilities/IOUtilities.cs
浏览文件 @
7bae6740
...
...
@@ -23,26 +23,21 @@ public static T PerformIO<T>(Func<T> function, T defaultValue = default(T))
{
return
function
();
}
catch
(
IOException
)
{
}
catch
(
SecurityException
)
{
}
catch
(
ArgumentException
)
{
}
catch
(
UnauthorizedAccessException
)
{
}
catch
(
NotSupportedException
)
{
}
catch
(
InvalidOperationException
)
catch
(
Exception
e
)
when
(
IsNormalIOException
(
e
))
{
}
return
defaultValue
;
}
public
static
bool
IsNormalIOException
(
Exception
e
)
{
return
e
is
IOException
||
e
is
SecurityException
||
e
is
ArgumentException
||
e
is
UnauthorizedAccessException
||
e
is
NotSupportedException
||
e
is
InvalidOperationException
;
}
}
}
}
\ No newline at end of file
src/VisualStudio/Core/Def/Packaging/PackageSearchService.Update.cs
浏览文件 @
7bae6740
...
...
@@ -62,7 +62,7 @@ internal partial class PackageSearchService
private
readonly
IPackageSearchRemoteControlService
_remoteControlService
;
private
readonly
IPackageSearchPatchService
_patchService
;
private
readonly
IPackageSearchDatabaseFactoryService
_databaseFactoryService
;
private
readonly
Func
<
Exception
,
bool
>
_
s
wallowException
;
private
readonly
Func
<
Exception
,
bool
>
_
reportAndS
wallowException
;
public
void
Dispose
()
{
...
...
@@ -212,7 +212,7 @@ private async Task<TimeSpan> UpdateDatabaseInBackgroundWorkerAsync()
// Just allow our caller to handle this (they will use this to stop their loop).
throw
;
}
catch
(
Exception
e
)
when
(
_service
.
_
s
wallowException
(
e
))
catch
(
Exception
e
)
when
(
_service
.
_
reportAndS
wallowException
(
e
))
{
// Something bad happened (IO Exception, network exception etc.).
// ask our caller to try updating again a minute from now.
...
...
@@ -222,7 +222,7 @@ private async Task<TimeSpan> UpdateDatabaseInBackgroundWorkerAsync()
// down.
var
delay
=
_service
.
_delayService
.
UpdateFailedDelay
;
_service
.
LogException
(
e
,
$"Error occurred updating. Retrying update in
{
delay
}
"
);
return
_service
.
_delayService
.
UpdateFailedD
elay
;
return
d
elay
;
}
}
...
...
@@ -346,7 +346,7 @@ private async Task<TimeSpan> PatchLocalDatabaseAsync()
{
database
=
CreateAndSetInMemoryDatabase
(
databaseBytes
);
}
catch
(
Exception
e
)
when
(
_service
.
_
s
wallowException
(
e
))
catch
(
Exception
e
)
when
(
_service
.
_
reportAndS
wallowException
(
e
))
{
_service
.
LogException
(
e
,
"Error creating database from local copy. Downloading full database"
);
return
await
DownloadFullDatabaseAsync
().
ConfigureAwait
(
false
);
...
...
@@ -395,7 +395,7 @@ private async Task<TimeSpan> ProcessPatchXElementAsync(XElement patchElement, by
// Fall through and download full database.
}
catch
(
Exception
e
)
when
(
_service
.
_
s
wallowException
(
e
))
catch
(
Exception
e
)
when
(
_service
.
_
reportAndS
wallowException
(
e
))
{
_service
.
LogException
(
e
,
"Error occurred while processing patch element. Downloading full database"
);
// Fall through and download full database.
...
...
@@ -560,10 +560,17 @@ private async Task RepeatIOAsync(Action action)
try
{
action
();
return
;
}
catch
(
Exception
e
)
when
(
_service
.
_swallowException
(
e
))
catch
(
Exception
e
)
{
// Normal IO exception. Don't bother reporting it. We don't want to get
// lots of hits just because we couldn't write a file because of something
// like an anti-virus tool lockign the file.
if
(!
IOUtilities
.
IsNormalIOException
(
e
))
{
_service
.
_reportAndSwallowException
(
e
);
}
var
delay
=
_service
.
_delayService
.
FileWriteDelay
;
_service
.
LogException
(
e
,
$"Operation failed. Trying again after
{
delay
}
"
);
await
Task
.
Delay
(
delay
,
_service
.
_cancellationToken
).
ConfigureAwait
(
false
);
...
...
src/VisualStudio/Core/Def/Packaging/PackageSearchService.cs
浏览文件 @
7bae6740
...
...
@@ -11,6 +11,7 @@
using
Microsoft.CodeAnalysis.Elfie.Model
;
using
Microsoft.CodeAnalysis.Elfie.Model.Structures
;
using
Microsoft.CodeAnalysis.Elfie.Model.Tree
;
using
Microsoft.CodeAnalysis.ErrorReporting
;
using
Microsoft.CodeAnalysis.Packaging
;
using
Microsoft.Internal.VisualStudio.Shell.Interop
;
using
Microsoft.VisualStudio.Settings
;
...
...
@@ -41,8 +42,8 @@ public PackageSearchService(VSShell.SVsServiceProvider serviceProvider, IPackage
new
PatchService
(),
new
DatabaseFactoryService
(),
new
ShellSettingsManager
(
serviceProvider
).
GetApplicationDataFolder
(
ApplicationDataFolder
.
LocalSettings
),
//
swallow all exceptions
e
=>
true
,
//
Report all exceptions we encounter, but don't crash on them.
FatalError
.
ReportWithoutCrash
,
new
CancellationTokenSource
())
{
installerService
.
PackageSourcesChanged
+=
OnPackageSourcesChanged
;
...
...
@@ -73,7 +74,7 @@ private static IPackageSearchRemoteControlService CreateRemoteControlService(VSS
IPackageSearchPatchService
patchService
,
IPackageSearchDatabaseFactoryService
databaseFactoryService
,
string
localSettingsDirectory
,
Func
<
Exception
,
bool
>
s
wallowException
,
Func
<
Exception
,
bool
>
reportAndS
wallowException
,
CancellationTokenSource
cancellationTokenSource
)
{
if
(
remoteControlService
==
null
)
...
...
@@ -89,7 +90,7 @@ private static IPackageSearchRemoteControlService CreateRemoteControlService(VSS
_remoteControlService
=
remoteControlService
;
_patchService
=
patchService
;
_databaseFactoryService
=
databaseFactoryService
;
_
swallowException
=
s
wallowException
;
_
reportAndSwallowException
=
reportAndS
wallowException
;
_cacheDirectoryInfo
=
new
DirectoryInfo
(
Path
.
Combine
(
localSettingsDirectory
,
"PackageCache"
,
string
.
Format
(
Invariant
(
$"Format
{
_dataFormatVersion
}
"
))));
...
...
src/VisualStudio/Core/Test/Packaging/PackageSearchServiceTests.vb
浏览文件 @
7bae6740
...
...
@@ -43,7 +43,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
Nothing
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
service
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -73,7 +73,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
Nothing
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
service
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -110,7 +110,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
Nothing
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
searchService
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -144,7 +144,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
Nothing
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
searchService
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -192,7 +192,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
Nothing
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
searchService
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -235,7 +235,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
factoryMock
.
Object
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
searchService
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -282,7 +282,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
factoryMock
.
Object
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
searchService
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -340,7 +340,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
factoryMock
.
Object
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
searchService
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -385,7 +385,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
databaseFactoryMock
.
Object
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
searchService
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -438,7 +438,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
databaseFactoryMock
.
Object
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
searchService
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -497,7 +497,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
Nothing
,
databaseFactoryService
:
=
databaseFactoryMock
.
Object
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
searchService
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
@@ -552,7 +552,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Packaging
patchService
:
=
patchMock
.
Object
,
databaseFactoryService
:
=
databaseFactoryMock
.
Object
,
localSettingsDirectory
:
=
"TestDirectory"
,
s
wallowException
:
=
s_allButMoqExceptions
,
reportAndS
wallowException
:
=
s_allButMoqExceptions
,
cancellationTokenSource
:
=
cancellationTokenSource
)
Await
searchService
.
UpdateSourceInBackgroundAsync
(
PackageSearchService
.
NugetOrgSource
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录