You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Visual Studio Package Management UI, Visual Studio Package Manager Console
Current Behavior
src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/ProjectServices/VsProjectBuildProperties.cs tries to get MSBuild properties from IVsBuildPropertyStorage, and if it's unable to get the property (even if the API returns a code saying the property does not exist), NuGet then tries DTE.Project.Properties.Item(string). However, DTE throws an InvalidArgumentException when the property does not exist in the project.
While the exception is caught, it has two problems:
There's a minor perf problem. Not only are we pointlessly requesting a property we already know doesn't exist, but throwing and catching exceptions has non-trivial overhead, which is why many .NET APIs have Try* methods.
VS extension authors (which includes the NuGet team and everyone in Microsoft writing components that ship in VS) have these first chance exceptions appear in Visual Studio's debugging diagnostics view when debugging VS. This has even affected me personally, when trying to debug some bug fix or new feature, and it's difficult to figure out which exceptions are relevant to my scenario, and which exceptions are just noise.
Several times internal partners, including the VS perf team, have opened bugs on NuGet for throwing these exceptions, despite the fact that DTE is actually throwing them, due to technicalities of how COM interop work.
Desired Behavior
NuGet should only use DTE.Project.Properties when the project system doesn't support IVsBuildPropertyStorage.
Additional Context
This change has medium risk, as it makes the assumption that project systems that implement IVsbuildPropertyStorage have done so correctly, and that using DTE.Project.Properties.Item(string) will also not find the property. It's out of the NuGet team's control whether or project systems implement themselves correctly, and since NuGet has been doing this fallback behaviour "forever", if NuGet changes and this exposes a project system bug, it will appear as a NuGet regression.
NuGet Product(s) Affected
Visual Studio Package Management UI, Visual Studio Package Manager Console
Current Behavior
src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/ProjectServices/VsProjectBuildProperties.cs
tries to get MSBuild properties fromIVsBuildPropertyStorage
, and if it's unable to get the property (even if the API returns a code saying the property does not exist), NuGet then triesDTE.Project.Properties.Item(string)
. However, DTE throws anInvalidArgumentException
when the property does not exist in the project.While the exception is caught, it has two problems:
Try*
methods.Several times internal partners, including the VS perf team, have opened bugs on NuGet for throwing these exceptions, despite the fact that DTE is actually throwing them, due to technicalities of how COM interop work.
Desired Behavior
NuGet should only use
DTE.Project.Properties
when the project system doesn't supportIVsBuildPropertyStorage
.Additional Context
This change has medium risk, as it makes the assumption that project systems that implement
IVsbuildPropertyStorage
have done so correctly, and that usingDTE.Project.Properties.Item(string)
will also not find the property. It's out of the NuGet team's control whether or project systems implement themselves correctly, and since NuGet has been doing this fallback behaviour "forever", if NuGet changes and this exposes a project system bug, it will appear as a NuGet regression.Internal issue
The text was updated successfully, but these errors were encountered: