SkillAgentSearch skills...

DiffEngine

Manages launching and cleanup of diff tools

Install / Use

/learn @VerifyTests/DiffEngine
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<!-- GENERATED FILE - DO NOT EDIT This file was generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets). Source File: /readme.source.md To change this file edit the source file and then run MarkdownSnippets. -->

<img src="/src/icon.png" height="30px"> DiffEngine

Discussions Build status NuGet Status NuGet Status

DiffEngine manages launching and cleanup of diff tools. It is designed to be used by any Snapshot/Approval testing library.<!-- singleLineInclude: intro. path: /docs/mdsource/intro.include.md -->

See Milestones for release notes.

Currently used by:

Sponsors

Entity Framework Extensions<!-- include: sponsors. path: /docs/mdsource/sponsors.include.md -->

Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.

Entity Framework Extensions

Developed using JetBrains IDEs

JetBrains logo.<!-- endInclude -->

<!-- toc -->

Contents

NuGet

  • https://nuget.org/packages/DiffEngine/

Supported Tools

Launching a tool

A tool can be launched using the following:

<!-- snippet: DiffRunnerLaunch -->

<a id='snippet-DiffRunnerLaunch'></a>

await DiffRunner.LaunchAsync(tempFile, targetFile);

<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L68-L72' title='Snippet source file'>snippet source</a> | <a href='#snippet-DiffRunnerLaunch' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

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

Closing a tool

A tool can be closed using the following:

<!-- snippet: DiffRunnerKill -->

<a id='snippet-DiffRunnerKill'></a>

DiffRunner.Kill(file1, file2);

<sup><a href='/src/DiffEngine.Tests/DiffRunnerTests.cs#L82-L86' title='Snippet source file'>snippet source</a> | <a href='#snippet-DiffRunnerKill' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

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 -->

<a id='snippet-BuildServerDetectorProps'></a>

var isWsl = BuildServerDetector.IsWsl;
var isTravis = BuildServerDetector.IsTravis;
var isJenkins = BuildServerDetector.IsJenkins;
var isGithubAction = BuildServerDetector.IsGithubAction;
var isAzureDevops = BuildServerDetector.IsAzureDevops;
var isTeamCity = BuildServerDetector.IsTeamCity;
var isGitLab = BuildServerDetector.IsGitLab;
var isMyGet = BuildServerDetector.IsMyGet;
var isGoDc = BuildServerDetector.IsGoDc;
var isDocker = BuildServerDetector.IsDocker;
var isAppVeyor = BuildServerDetector.IsAppVeyor;

<sup><a href='/src/DiffEngine.Tests/BuildServerDetectorTest.cs#L8-L22' title='Snippet source file'>snippet source</a> | <a href='#snippet-BuildServerDetectorProps' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

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 -->

<a id='snippet-BuildServerDetectorDetectedOverride'></a>

[Test]
public async Task SetDetectedPersistsInAsyncContext()
{
    var original = BuildServerDetector.Detected;
    try
    {
        BuildServerDetector.Detected = true;
        await Assert.That(BuildServerDetector.Detected).IsTrue();

        await Task.Delay(1);

        await Assert.That(BuildServerDetector.Detected).IsTrue();
    }
    finally
    {
        BuildServerDetector.Detected = original;
    }
}

[Test]
public async Task SetDetectedDoesNotLeakToOtherContexts()
{
    var parentValue = BuildServerDetector.Detected;

    await Task.Run(async () =>
    {
        BuildServerDetector.Detected = true;
        await Assert.That(BuildServerDetector.Detected).IsTrue();
    });

    await Assert.That(BuildServerDetector.Detected).IsEqualTo(parentValue);
}

<sup><a href='/src/DiffEngine.Tests/BuildServerDetectorTest.cs#L27-L62' title='Snippet source file'>snippet source</a> | <a href='#snippet-BuildServerDetectorDetectedOverride' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

AiCliDetector

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

Supports:

  • [GitHub Copilot CLI](https://docs.github.com/en

Related Skills

View on GitHub
GitHub Stars232
CategoryDevelopment
Updated2h ago
Forks31

Languages

C#

Security Score

95/100

Audited on Apr 6, 2026

No findings