Skip to content

Commit

Permalink
VsPackageInstallerServices should not post ProjectNotNominatedExcepti…
Browse files Browse the repository at this point in the history
…on faults
  • Loading branch information
zivkan committed Sep 21, 2022
1 parent 0e8abff commit 533cd85
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using NuGet.Configuration;
using NuGet.PackageManagement;
using NuGet.PackageManagement.VisualStudio;
using NuGet.PackageManagement.VisualStudio.Exceptions;
using NuGet.Packaging;
using NuGet.Packaging.PackageExtraction;
using NuGet.Packaging.Signing;
Expand Down Expand Up @@ -126,6 +127,10 @@ public IEnumerable<IVsPackageMetadata> GetInstalledPackages()
return packages;
});
}
catch (ProjectNotNominatedException)
{
throw;
}
catch (Exception exception)
{
_telemetryProvider.PostFault(exception, typeof(VsPackageInstallerServices).FullName);
Expand Down Expand Up @@ -266,6 +271,10 @@ public IEnumerable<IVsPackageMetadata> GetInstalledPackages(Project project)
return packages;
});
}
catch (ProjectNotNominatedException)
{
throw;
}
catch (Exception exception)
{
_telemetryProvider.PostFault(exception, typeof(VsPackageInstallerServices).FullName);
Expand Down Expand Up @@ -351,6 +360,10 @@ private bool IsPackageInstalled(Project project, string packageId, NuGetVersion

return PackageServiceUtilities.IsPackageInList(installedPackageReferences, packageId, nugetVersion);
}
catch (ProjectNotNominatedException)
{
throw;
}
catch (Exception exception)
{
await _telemetryProvider.PostFaultAsync(exception, typeof(VsPackageInstallerServices).FullName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public interface IVsPackageInstallerServices
/// <param name="project">The project to check for NuGet package.</param>
/// <param name="id">The id of the package to check.</param>
/// <returns><c>true</c> if the package is install. <c>false</c> otherwise.</returns>
/// <exception cref="InvalidOperationException">A "project not nominated" exception will be thrown if the project is asynchronous and the project system has not yet told NuGet about the project.
/// You can use <see cref="IVsNuGetProjectUpdateEvents"/> or Microsoft.VisualStudio.OperationProgress to be notified when the project is ready.</exception>
[Obsolete("This method can cause UI delays if called on the UI thread. Use INuGetProjectService.GetInstalledPackagesAsync in the NuGet.VisualStudio.Contracts package instead, and check the specific package you're interested in")]
bool IsPackageInstalled(Project project, string id);

Expand All @@ -41,6 +43,8 @@ public interface IVsPackageInstallerServices
/// <param name="id">The id of the package to check.</param>
/// <param name="version">The version of the package to check.</param>
/// <returns><c>true</c> if the package is install. <c>false</c> otherwise.</returns>
/// <exception cref="InvalidOperationException">A "project not nominated" exception will be thrown if the project is asynchronous and the project system has not yet told NuGet about the project.
/// You can use <see cref="IVsNuGetProjectUpdateEvents"/> or Microsoft.VisualStudio.OperationProgress to be notified when the project is ready.</exception>
[Obsolete("This method can cause UI delays if called on the UI thread. Use INuGetProjectService.GetInstalledPackagesAsync in the NuGet.VisualStudio.Contracts package instead, and check the specific package you're interested in")]
bool IsPackageInstalled(Project project, string id, SemanticVersion version);

Expand All @@ -56,13 +60,17 @@ public interface IVsPackageInstallerServices
/// when client project compiles against this assembly, the compiler would attempt to bind against
/// the other overload which accepts SemanticVersion and would require client project to reference NuGet.Core.
/// </remarks>
/// <exception cref="InvalidOperationException">A "project not nominated" exception will be thrown if the project is asynchronous and the project system has not yet told NuGet about the project.
/// You can use <see cref="IVsNuGetProjectUpdateEvents"/> or Microsoft.VisualStudio.OperationProgress to be notified when the project is ready.</exception>
[Obsolete("This method can cause UI delays if called on the UI thread. Use INuGetProjectService.GetInstalledPackagesAsync in the NuGet.VisualStudio.Contracts package instead, and check the specific package you're interested in")]
bool IsPackageInstalledEx(Project project, string id, string versionString);

/// <summary>
/// Get the list of NuGet packages installed in the specified project.
/// </summary>
/// <param name="project">The project to get NuGet packages from.</param>
/// <exception cref="InvalidOperationException">A "project not nominated" exception will be thrown if the project is asynchronous and the project system has not yet told NuGet about the project.
/// You can use <see cref="IVsNuGetProjectUpdateEvents"/> or Microsoft.VisualStudio.OperationProgress to be notified when the project is ready.</exception>
[Obsolete("This method can cause UI delays if called on the UI thread. Use INuGetProjectService.GetInstalledPackagesAsync in the NuGet.VisualStudio.Contracts package instead")]
IEnumerable<IVsPackageMetadata> GetInstalledPackages(Project project);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public class HttpSourceAuthenticationHandler : DelegatingHandler
private readonly HttpClientHandler _clientHandler;
private readonly ICredentialService _credentialService;

#pragma warning disable CA2213 // Disposable fields should be disposed
private readonly SemaphoreSlim _httpClientLock = new SemaphoreSlim(1, 1);
#pragma warning restore CA2213 // Disposable fields should be disposed
private Dictionary<string, AmbientAuthenticationState> _authStates = new Dictionary<string, AmbientAuthenticationState>();
private HttpSourceCredentials _credentials;

Expand Down

0 comments on commit 533cd85

Please sign in to comment.