This code is trying to access the UnconfiguredProject for a given IVsHierarchy.
It first attempts to cast the hierarchy to IVsBrowseObjectContext. It looks like the intention was then to use that if present, otherwise use DTE.
The code incorrectly checks for null (Nothing) to see if the first conversion failed, and only then try DTE. As it was written, it would only check DTE if the first conversion succeeded, meaning that both the first cast and the DTE approach have to work.
By fixing the null check, we avoid calling DTE in the common case.
There is only one caller of this private method and I've reviewed it for correctness.
This code is trying to access the
UnconfiguredProject
for a givenIVsHierarchy
.It first attempts to cast the hierarchy to
IVsBrowseObjectContext
. It looks like the intention was then to use that if present, otherwise use DTE.The code incorrectly checks for null (
Nothing
) to see if the first conversion failed, and only then try DTE. As it was written, it would only check DTE if the first conversion succeeded, meaning that both the first cast and the DTE approach have to work.By fixing the null check, we avoid calling DTE in the common case.
There is only one caller of this private method and I've reviewed it for correctness.
Microsoft Reviewers: Open in CodeFlow