-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enable assembly resolver to ensure that Start Page
and other icons can be found
#1220
Conversation
Make `AssemblyResolverPackage` auto-load in case `devenv.exe.config` failed to update when extension was installed.
…ributes This makes assembly resolving behave more like when `devenv.exe.config` has been updated with `dependentAssembly` elements.
8c6efd7
to
7b0cc1a
Compare
This should only happen if installer has failed or running unsigned build.
Assembly resolving should be as quick and side effect free as possible. It's best to avoid triggering assembly loads or writing to disk during assembly resolves. This change delays writing to the log until the package is being disposed.
VS 15.3 appears to load this later than it used to and it can no longer be relied on. Loading on UICONTEXT.NoSolution seems to be enough.
@@ -1,7 +1,10 @@ | |||
<ImageManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/VisualStudio/ImageManifestSchema/2014"> | |||
|
|||
<Symbols> | |||
<!-- We need to ensure that `GitHub.VisualStudio` has loaded before any of these resources are used. --> | |||
<!-- This should happen when `AssemblyResolverPackage` auto-loads on `UICONTEXT.NoSolution`. --> | |||
<String Name="Resources" Value="/GitHub.VisualStudio;component/Resources/icons" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems the culprit was actually here. It tries to find an assembly by its simple name before that assembly has been loaded. I think when the Team Explorer
related assemblies get initialized might have changed in VS 15.3. This can cause GitHub.VisualStudio
not to get pre-loaded and the icons fail to load.
There is a possible workaround for this:
microsoft/PTVS@ec1b895
I did a spike to see if this might work for us, but it would involve moving a bunch of resources into GitHub.UI
and fixing a bunch of other issues (not a point fix). This might be worth investigating at some future time.
dependentAssembly
elements in devenv.exe.config
GitHub.VisualStudio.imagemanifest
icons can be found
GitHub.VisualStudio.imagemanifest
icons can be foundStart Page
and other icons can be found
@meaghanlewis, I thought a simple test plan might be useful.
The It would also be good to get a VM with Visual Studio 2017 (15.2) installed on it. I'm not sure how to install older versions, but it must be possible somehow? They keep updating Visual Studio 2017 and things sometimes break. It's possible this was also an issue on Visual Studio 2017 (15.2), but no one noticed. It requires a machine where the user hasn't been using the GitHub extension, which makes it very easy to miss! I'm very interested to see what you find... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a small question and tweak.
if (resolvingAssemblies.Count > 0 || resolvingExceptions.Count > 0) | ||
{ | ||
// Avoid executing any logging code unless there is something to log. | ||
WriteToLog(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we log the resolved assemblies and resolve errors when VS is shutdown rather than when they occur?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a few reasons:
- Since this package is always loaded, I wanted to avoid loading any extra assemblies as VS starts.
- Avoid the possability of recursive assembly resolving (in a previous version there was an issue with
Trace.WriteLine
). - Avoid doing any file creation or writes as VS starts.
I've tried to make it as predictable and light weight as possible. :-)
{ | ||
public class AssemblyResolverPackageTests | ||
{ | ||
class TheResolveDependentAssemblyMethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests aren't being run under ncrunch because this class needs to be public
.
Thanks for the testing notes 👍 I verified this using VS2017 with versions 15.3 and VS 15.0. On a fresh install of an older version of the extension (v2.3.0.24) the GitHub icon was not present, but on updating to the most recent version of the extension (v2.3.2.32) the GitHub icon was present. The icon is present in both 15.3 and 15.0 with a fresh install of the extension from this PR build. The |
Was this with VS2017 15.0? I'm hoping the icon wasn't present on 15.3 until this PR build. 🤞 |
@jcansdale I started with a fresh install of 15.3 and then installed the extension version Next, I did an uninstall/reinstall of 15.3, and installed extension |
Lol, it's complicated! I wouldn't be surprised if this happened with VS 15.0. Did you start with a fresh install of 15.0 or 15.3? 😉
This is the main thing! 😄 👍 |
This PR fixes a few potential issues:
GitHub.VisualStudio.imagemanifest
icons can be founddevenv.exe.config
failed to updateThe most likely scenario is when someone is using using Visual Studio 2017 (15.3) and has never used the extension before. In this case the Start Page icon next to GitHub will be blank. This is unfortunate because it's when we most want people to notice it!
The reason it doesn't appears is because
GitHub.VisualStudio.imagemanifest
references theGitHub.VisualStudio
by its simple name. In order for the icons to be found, theGitHub.VisualStudio
assembly must be loaded before any of them are used. The assembly resolver is in this assembly and will be auto-loaded onUICONTEXT.NoSolution
(which should happen before the icons are needed.Rather than having to maintain a separate list of assemblies that might need resolving, the assembly resolver loads the
ProvideCodeBase
andProvideBindingRedirection
attributes (fromGitHub.VisualStudio
) and resolves according to these rules. The idea is to behave as if thedependentAssembly
elements had been installed.The previous implementation of the assembly resolver would resolve any assembly in the extension folder when there was a full name match. This avoided false matches, but also meant it needed to call
AssemblyName.GetAssemblyName(file)
to see if there was a match.This implementation will only hit the disk if the assembly being resolved has a matching
ProvideCodeBase
orProvideBindingRedirection
attribute. It will only resolve an assembly when there is a full name patch.Fixes #1217