Skip to content

Latest commit

 

History

History
175 lines (91 loc) · 7.58 KB

File metadata and controls

175 lines (91 loc) · 7.58 KB

DiffEngine

Discussions Build status NuGet Status NuGet Status NuGet Status NuGet Status NuGet Status

include: intro

See Milestones for release notes.

Currently used by:

Sponsors

include: sponsors

toc include: doc-index

NuGet

include: diffToolList

Launching a tool

A tool can be launched using the following:

snippet: DiffRunnerLaunch

Note that this method will respect the above difference behavior in terms of Auto refresh and MDI behaviors.

Files derived from another

A snapshot of a document is often several files: the document, and what was computed from it, such as a png of each page, its text, or a csv per sheet. A file of the second kind can be launched as derived from the first:

snippet: DiffRunnerLaunchDerived

The source is named by its temp file, is launched first, and is named only while it is itself pending.

This changes nothing for most tools: each derived file is launched exactly as Launch would launch it. The exception is DiffEngineViewer when it is drawing the source as a document. It already shows the pages and the text, so the derived files open no tool, do not count towards MaxInstancesToLaunch, and are accepted or discarded together with the document.

Closing a tool

A tool can be closed using the following:

snippet: DiffRunnerKill

Note that this method will respect the above difference behavior in terms of MDI behavior.

File type detection

DiffEngine use EmptyFiles to determine if a given file or extension is a binary or text. Custom extensions can be added, or existing ones changed.

BuildServerDetector

BuildServerDetector.Detected returns true if the current code is running on a build/CI server.

Supports:

There are also individual properties to check for each specific build system

snippet: BuildServerDetectorProps

WSL

Running under WSL is not treated as a build server, since a WSL session is usually a developer machine. BuildServerDetector.IsWsl reports it, and BuildServerDetector.Detected ignores it. Diff tools are launched there, the ones installed on Windows included: see Windows Subsystem for Linux.

A build that runs its tests inside WSL from a Windows build agent is the case to watch. The variables the build server sets exist on the Windows side, and WSL only passes across the ones named in WSLENV. So inside WSL nothing is detected, and diff tools are launched on the build agent.

To have such a build detected, either name the build server's variable in WSLENV on the Windows side, for example on Azure DevOps:

set WSLENV=TF_BUILD:%WSLENV%

or set one of the detected variables on the command that starts the tests:

wsl -- env TF_BUILD=True dotnet test

To treat every WSL run as a build server, in a test:

BuildServerDetector.Detected = BuildServerDetector.Detected || BuildServerDetector.IsWsl;

That value is scoped to the current async context, as described below.

Override in tests

BuildServerDetector.Detected can be set at test time. The value is stored in an AsyncLocal, so it is scoped to the current async context and does not leak to other threads or tests running in parallel.

snippet: BuildServerDetectorDetectedOverride

Automatic AI detection

DiffEngine automatically detects when it is running inside an AI-powered CLI environment and disables the diff tool launch. This means no DiffEngine_Disabled=true environment variable is required when running tests from within an AI CLI — it is detected and handled automatically.

Supported AI CLIs:

Programmatic usage

AiCliDetector.Detected returns true if the current code is running in an AI-powered CLI environment.

There are also individual properties to check for each specific AI CLI

snippet: AiCliDetectorProps

Disable for a machine/process

Set an environment variable DiffEngine_Disabled with the value true.

Disable in code

DiffRunner.Disabled = true;

Disable the tray

Pending moves and deletes are sent to DiffEngineTray when one is running. That tracking is separate from launching a diff tool, so disabling diff does not stop it.

Set an environment variable DiffEngine_TrayDisabled with the value true, or in code:

DiffRunner.TrayDisabled = true;

More detail.

Icons

Game designed by Andrejs Kirma from The Noun Project.

Tray icons from LineIcons.