-
Notifications
You must be signed in to change notification settings - Fork 3
/
DiffTools.cs
71 lines (62 loc) · 2.43 KB
/
DiffTools.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#region License
/*
ClipboardDiff Visual Studio Extension
Copyright (C) 2011-2014 Einar Egilsson
http://einaregilsson.com/clipboarddiff-visual-studio-extension/
This program is licensed under the MIT license, see the file LICENSE
for details.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
namespace EinarEgilsson.ClipboardDiff
{
internal class DiffTool
{
public string Path { get; set; }
public string Arguments { get; set; }
}
internal static class DiffTools
{
internal static List<DiffTool> GetCandidates()
{
var result = new List<DiffTool>();
//Ok, vsDiffMerge is our default choice here, since it's integrated into VS itself...
var processFullPath = Process.GetCurrentProcess().MainModule.FileName;
var vsFolder = Path.GetDirectoryName(processFullPath);
const string vsDiffMergeArgs = "$FILE1$ $FILE2$ /t";
//Older VS versions
result.Add(new DiffTool
{
Path = Path.Combine(vsFolder, "vsDiffMerge.exe"),
Arguments = vsDiffMergeArgs
});
//VS 2017 versions
result.Add(new DiffTool
{
Path = Path.Combine(vsFolder, @"CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe"),
Arguments = vsDiffMergeArgs
});
const string defaultArgs = "$FILE1$ $FILE2$";
//These will probably never be used anymore, except in really old VS version, but we'll leave them in here just in case...
foreach (var path in new[] { @"Perforce\p4merge.exe", @"tortoisesvn\bin\TortoiseMerge.exe", @"WinMerge\WinMergeU.exe" })
{
result.Add(new DiffTool
{
//Hardcode the program files because running in 32-bit VS will always return the x86 folder, and
//we might have a program in the "real" program files...
Path = Path.Combine(@"C:\Program Files", path),
Arguments = defaultArgs
});
result.Add(new DiffTool
{
Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), path),
Arguments = defaultArgs
});
}
return result;
}
}
}