Skip to content

Latest commit

 

History

History
94 lines (72 loc) · 3.69 KB

diff-tool.custom.md

File metadata and controls

94 lines (72 loc) · 3.69 KB

Custom Diff Tool

A custom tool can be added by calling DiffTools.AddTool

var resolvedTool = DiffTools.AddTool(
    name: "MyCustomDiffTool",
    autoRefresh: true,
    isMdi: false,
    supportsText: true,
    requiresTarget: true,
    launchArguments: new(
        Left: (tempFile, targetFile) => $"\"{targetFile}\" \"{tempFile}\"",
        Right: (tempFile, targetFile) => $"\"{tempFile}\" \"{targetFile}\""),
    exePath: diffToolPath,
    binaryExtensions: [".jpg"])!;

snippet source | anchor

Add a tool based on existing resolved tool:

var resolvedTool = DiffTools.AddToolBasedOn(
    DiffTool.VisualStudio,
    name: "MyCustomDiffTool",
    launchArguments: new(
        Left: (temp, target) => $"\"custom args \"{target}\" \"{temp}\"",
        Right: (temp, target) => $"\"custom args \"{temp}\" \"{target}\""))!;

snippet source | anchor

Resolution order

New tools are added to the top of the order, the last tool added will resolve before any existing tools. So when the following is executed the last tool that supports the file types will launch:

await DiffRunner.LaunchAsync(tempFile, targetFile);

snippet source | anchor

Alternatively the instance returned from AddTool* can be used to explicitly launch that tool.

var resolvedTool = DiffTools.AddToolBasedOn(
    DiffTool.VisualStudio,
    name: "MyCustomDiffTool",
    launchArguments: new(
        Left: (temp, target) => $"\"custom args \"{target}\" \"{temp}\"",
        Right: (temp, target) => $"\"custom args \"{temp}\" \"{target}\""));

await DiffRunner.LaunchAsync(resolvedTool!, "PathToTempFile", "PathToTargetFile");

snippet source | anchor

exePath

exePath is the path to the executable.

If the file cannot be found AddTool* will return null.

Path conventions

So for example %ProgramFiles(x86)%\Microsoft Visual Studio\*\*\Common7\IDE\devenv.exe might discover the following:

  • C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe
  • C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe

Then C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe will be used.