Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

IChangesExt service returned is always null

$
0
0

I'm trying to add Git support to my Visual Studio 2015 extension Diff All Files.  I have everything working properly for the TFVC Team Explorer pages, and am trying to now have my extension show up on the Git Changes and Git History pages as well.  In order to be able to detect the pending changes on the Git Changes page I need to get a handle to the IChangesExt service.  This page shows how to do it, but for some reason it does not work for me; I always just get a null value returned back, and not the expected IChangesExt instance.

Here's the relevant code snippets from that site:

Microsoft.TeamFoundation.Controls.ITeamExplorer teamExplorer;
teamExplorer = base.GetService(typeof(Microsoft.TeamFoundation.Controls.ITeamExplorer)) as Microsoft.TeamFoundation.Controls.ITeamExplorer;

Microsoft.TeamFoundation.Controls.ITeamExplorerPage teamExplorerPage;
Microsoft.TeamFoundation.Git.Controls.Extensibility.IChangesExt changesExt;

teamExplorerPage = teamExplorer.NavigateToPage(new Guid(pageGuid), null);
changesExt = teamExplorerPage.GetExtensibilityService(typeof(Microsoft.TeamFoundation.Git.Controls.Extensibility.IChangesExt)) as Microsoft.TeamFoundation.Git.Controls.Extensibility.IChangesExt;

My code is slightly different, since my code executes automatically when the Git Changes window is opened I don't need to do the teamExplorer.NavigateToPage() call.  Instead I use teamExplorer.CurrentPage, which I can see in the debugger is actually the Git Changes page (GitPendingChangesPageVS is the type), so I should be making the same calls as in the example from the site.  Here's my code in the Git Changes page's Loaded() function.  Notice that I try to get the IChangesExt service 3 different ways, but all of them just return null.

public override void Loaded(object sender, SectionLoadedEventArgs e)
{
	base.Loaded(sender, e);

	// Find the Pending Changes extensibility service and save a handle to it.
	var teamExplorer = this.GetService<ITeamExplorer>();
	var service = teamExplorer.GetService(typeof(IChangesExt)) as IChangesExt;
	var service2 = teamExplorer.CurrentPage.GetExtensibilityService(typeof(IChangesExt)) as IChangesExt;
	var service3 = teamExplorer.CurrentPage.GetService<IChangesExt>();
...
}
Any ideas what I am doing wrong?  I also tried this.GetService<IChangesExt>(), but that just returns null as well.

The extension is open source, so if you like you can download the source from here (make sure you get the GitInitialFunctionality branch) and take a look.  The relevant code is in the GitChangesSection.cs file.

Any suggestions are appreciated.  Thanks!


- Dan - "Can't never could do anything"


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>