From 3eefa1b7605ea74f4fb7114d9c7afc92dfd4ae6d Mon Sep 17 00:00:00 2001 From: Matt Burke Date: Mon, 14 Apr 2014 14:01:36 -0400 Subject: [PATCH] Move the path resolver to the constructor. This will ensure that it's in place before evaluating checkin policies, which is when it is needed, without expanding the interface of ITfsHelper. --- GitTfs.VsCommon/TfsHelper.Common.cs | 2 -- GitTfs.VsCommon/TfsHelper.PostVs2010.Common.cs | 12 ++++++------ GitTfs/Core/TfsInterop/ITfsHelper.cs | 1 - GitTfs/Core/TfsWorkspace.cs | 3 --- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/GitTfs.VsCommon/TfsHelper.Common.cs b/GitTfs.VsCommon/TfsHelper.Common.cs index 29c2f6ba..89f60e02 100644 --- a/GitTfs.VsCommon/TfsHelper.Common.cs +++ b/GitTfs.VsCommon/TfsHelper.Common.cs @@ -363,8 +363,6 @@ namespace Sep.Git.Tfs.VsCommon protected abstract string GetAuthenticatedUser(); - public abstract void SetPathResolver(); - public abstract bool CanShowCheckinDialog { get; } public ITfsChangeset GetShelvesetData(IGitTfsRemote remote, string shelvesetOwner, string shelvesetName) diff --git a/GitTfs.VsCommon/TfsHelper.PostVs2010.Common.cs b/GitTfs.VsCommon/TfsHelper.PostVs2010.Common.cs index 67afec55..f200179b 100644 --- a/GitTfs.VsCommon/TfsHelper.PostVs2010.Common.cs +++ b/GitTfs.VsCommon/TfsHelper.PostVs2010.Common.cs @@ -23,6 +23,7 @@ namespace Sep.Git.Tfs.VsCommon : base(stdout, bridge, container) { _bridge = bridge; + AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromVSFolder); } public override bool CanGetBranchInformation @@ -220,18 +221,17 @@ namespace Sep.Git.Tfs.VsCommon protected abstract string GetVsInstallDir(); - public override void SetPathResolver() - { - AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromVSFolder); - - } - + /// + /// Help the TFS client find checkin policy assemblies. + /// Assembly LoadFromVSFolder(object sender, ResolveEventArgs args) { + Trace.WriteLine("Looking for assembly " + args.Name + " ..."); string folderPath = Path.Combine(GetVsInstallDir(), "PrivateAssemblies"); string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll"); if (File.Exists(assemblyPath) == false) return null; + Trace.WriteLine("... loading " + args.Name + " from " + assemblyPath); Assembly assembly = Assembly.LoadFrom(assemblyPath); return assembly; } diff --git a/GitTfs/Core/TfsInterop/ITfsHelper.cs b/GitTfs/Core/TfsInterop/ITfsHelper.cs index 60d4ce73..69822c49 100644 --- a/GitTfs/Core/TfsInterop/ITfsHelper.cs +++ b/GitTfs/Core/TfsInterop/ITfsHelper.cs @@ -23,7 +23,6 @@ namespace Sep.Git.Tfs.Core.TfsInterop bool HasShelveset(string shelvesetName); ITfsChangeset GetShelvesetData(IGitTfsRemote remote, string shelvesetOwner, string shelvesetName); int ListShelvesets(ShelveList shelveList, IGitTfsRemote remote); - void SetPathResolver(); bool CanShowCheckinDialog { get; } long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable checkedInfos, string checkinComment); void CleanupWorkspaces(string workingDirectory); diff --git a/GitTfs/Core/TfsWorkspace.cs b/GitTfs/Core/TfsWorkspace.cs index bcb4c456..a4838525 100644 --- a/GitTfs/Core/TfsWorkspace.cs +++ b/GitTfs/Core/TfsWorkspace.cs @@ -44,7 +44,6 @@ namespace Sep.Git.Tfs.Core shelveset.WorkItemInfo = GetWorkItemInfos().ToArray(); if (evaluateCheckinPolicies) { - _tfsHelper.SetPathResolver(); foreach (var message in _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, shelveset.Comment, null, shelveset.WorkItemInfo).Messages) { _stdout.WriteLine("[Checkin Policy] " + message); @@ -64,7 +63,6 @@ namespace Sep.Git.Tfs.Core if (string.IsNullOrWhiteSpace(checkinComment) && !_checkinOptions.NoGenerateCheckinComment) checkinComment = generateCheckinComment(); - _tfsHelper.SetPathResolver(); var newChangesetId = _tfsHelper.ShowCheckinDialog(_workspace, pendingChanges, GetWorkItemCheckedInfos(), checkinComment); if (newChangesetId <= 0) throw new GitTfsException("Checkin canceled!"); @@ -88,7 +86,6 @@ namespace Sep.Git.Tfs.Core var workItemInfos = GetWorkItemInfos(options); var checkinNote = _tfsHelper.CreateCheckinNote(options.CheckinNotes); - _tfsHelper.SetPathResolver(); var checkinProblems = _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, options.CheckinComment, checkinNote, workItemInfos); if (checkinProblems.HasErrors) {