提交 bbb96d00 编写于 作者: S Sam Harwell

Inline local function

上级 f9525105
......@@ -130,7 +130,7 @@ internal partial class PackageInstallerService : AbstractDelayStartedService, IP
var cancellationToken = _tokenSource.Token;
try
{
return await GetPackageSourcesImplAsync(cancellationToken).ConfigureAwait(false);
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
{
......@@ -139,27 +139,21 @@ internal partial class PackageInstallerService : AbstractDelayStartedService, IP
return null;
}
// Local function
async Task<ImmutableArray<PackageSource>> GetPackageSourcesImplAsync(CancellationToken cancellationToken)
try
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
try
{
return _packageSourceProvider.Value.GetSources(includeUnOfficial: true, includeDisabled: false)
.SelectAsArray(r => new PackageSource(r.Key, r.Value));
}
catch (Exception ex) when (ex is InvalidDataException || ex is InvalidOperationException)
{
// These exceptions can happen when the nuget.config file is broken.
return ImmutableArray<PackageSource>.Empty;
}
catch (ArgumentException ae) when (FatalError.ReportWithoutCrash(ae))
{
// This exception can happen when the nuget.config file is broken, e.g. invalid credentials.
// https://github.com/dotnet/roslyn/issues/40857
return ImmutableArray<PackageSource>.Empty;
}
return _packageSourceProvider.Value.GetSources(includeUnOfficial: true, includeDisabled: false)
.SelectAsArray(r => new PackageSource(r.Key, r.Value));
}
catch (Exception ex) when (ex is InvalidDataException || ex is InvalidOperationException)
{
// These exceptions can happen when the nuget.config file is broken.
return ImmutableArray<PackageSource>.Empty;
}
catch (ArgumentException ae) when (FatalError.ReportWithoutCrash(ae))
{
// This exception can happen when the nuget.config file is broken, e.g. invalid credentials.
// https://github.com/dotnet/roslyn/issues/40857
return ImmutableArray<PackageSource>.Empty;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册