Skip to content

Commit

Permalink
VsPackageInstallerServices should not post ProjectNotNominatedExcepti…
Browse files Browse the repository at this point in the history
…on faults (#4814)
  • Loading branch information
zivkan authored Sep 28, 2022
1 parent d0e9194 commit 17b52a9
Show file tree
Hide file tree
Showing 2 changed files with 21 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 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 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 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 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

0 comments on commit 17b52a9

Please sign in to comment.