InlineSnapshotSettings Class

Provides configuration settings for inline snapshot testing.

public sealed class InlineSnapshotSettings : IEquatable<InlineSnapshotSettings>
Implements

Constructors

NameDescription
InlineSnapshotSettings()

InlineSnapshotSettings()

InlineSnapshotSettings.cs
public InlineSnapshotSettings()

No documentation is available.

Properties

NameDescription
AllowedStringFormatsGets or sets the allowed C# string formats for writing snapshots (quoted, verbatim, raw, etc.).
AutoDetectContinuousEnvironmentGets or sets a value indicating whether to automatically detect continuous integration, continuous testing, and LLM environments and disable snapshot updates.
DefaultGets or sets the default settings used for snapshot validation.
EndOfLineGets or sets the end-of-line string to use when writing snapshots. If null, the end-of-line is detected from the source file.
ErrorMessageFormatterGets or sets the formatter used to create error messages when snapshots don't match.
FileEncodingGets or sets the file encoding to use when writing snapshots. If null, the encoding is detected from the source file.
ForceUpdateSnapshotsUpdate snapshots even when the snapshot is already valid. This can be use to reformat snapshots.
IndentationGets or sets the indentation string to use when writing snapshots. If null, the indentation is detected from the source file.
MergeToolsGets or sets the ordered list of tools used by SnapshotUpdateStrategy.MergeTool and SnapshotUpdateStrategy.MergeToolSync. The first tool that can be started is used. The default list tries the DiffEngine_Tool environment variable, the git merge and diff tools, the current IDE (Visual Studio, Visual Studio Code, Rider), and then the GUI tools detected by DiffEngine. Terminal tools such as Vim are only used when they are named explicitly. If null or empty, no merge tool is launched and the assertion failure is reported.
ScrubbersGets the list of scrubbers applied to snapshots after serialization.
SnapshotComparerGets or sets the comparer used to determine if two snapshots are equal.
SnapshotSerializerGets or sets the serializer used to convert objects to snapshot strings.
SnapshotUpdateStrategyGets or sets the strategy for updating snapshots when they don't match.
ValidateLineNumberUsingPdbInfoWhenAvailableBefore editing a file, use the PDB to validate the line number containing the snapshot.
ValidateSourceFilePathUsingPdbInfoWhenAvailableBefore editing a file, use the PDB to validate the file path containing the snapshot.

AllowedStringFormats

InlineSnapshotSettings.cs

Gets or sets the allowed C# string formats for writing snapshots (quoted, verbatim, raw, etc.).

public CSharpStringFormats AllowedStringFormats { get; set; }

Property value

CSharpStringFormats

AutoDetectContinuousEnvironment

InlineSnapshotSettings.cs

Gets or sets a value indicating whether to automatically detect continuous integration, continuous testing, and LLM environments and disable snapshot updates.

public bool AutoDetectContinuousEnvironment { get; set; }

Property value

bool

Remarks

The default value is true, unless the INLINESNAPSHOTTESTING_AUTODETECT_CONTINUOUS_ENVIRONMENT environment variable is set to false, 0, no or off.

Gets or sets the default settings used for snapshot validation.

public static InlineSnapshotSettings Default { get; set; }

Gets or sets the end-of-line string to use when writing snapshots. If null, the end-of-line is detected from the source file.

public string? EndOfLine { get; set; }

Property value

string?

ErrorMessageFormatter

InlineSnapshotSettings.cs

Gets or sets the formatter used to create error messages when snapshots don't match.

public AssertionMessageFormatter ErrorMessageFormatter { get; set; }

Gets or sets the file encoding to use when writing snapshots. If null, the encoding is detected from the source file.

public Encoding? FileEncoding { get; set; }

Property value

Encoding?

ForceUpdateSnapshots

InlineSnapshotSettings.cs

Update snapshots even when the snapshot is already valid. This can be use to reformat snapshots.

public bool ForceUpdateSnapshots { get; set; }

Property value

bool

Gets or sets the indentation string to use when writing snapshots. If null, the indentation is detected from the source file.

public string? Indentation { get; set; }

Property value

string?

Gets or sets the ordered list of tools used by SnapshotUpdateStrategy.MergeTool and SnapshotUpdateStrategy.MergeToolSync. The first tool that can be started is used. The default list tries the DiffEngine_Tool environment variable, the git merge and diff tools, the current IDE (Visual Studio, Visual Studio Code, Rider), and then the GUI tools detected by DiffEngine. Terminal tools such as Vim are only used when they are named explicitly. If null or empty, no merge tool is launched and the assertion failure is reported.

public IEnumerable<MergeTool>? MergeTools { get; set; }

Property value

IEnumerable<MergeTool>?

Remarks

The DiffEngine_Disabled environment variable disables all merge tools, even the ones set explicitly. Merge tools are also never launched on a continuous integration server, in a continuous testing runner, or in an LLM agent while InlineSnapshotSettings.AutoDetectContinuousEnvironment is enabled.

Gets the list of scrubbers applied to snapshots after serialization.

public IList<Scrubber> Scrubbers { get; }

Property value

IList<Scrubber>

Gets or sets the comparer used to determine if two snapshots are equal.

public SnapshotComparer SnapshotComparer { get; set; }

Property value

SnapshotComparer

SnapshotSerializer

InlineSnapshotSettings.cs

Gets or sets the serializer used to convert objects to snapshot strings.

public SnapshotSerializer SnapshotSerializer { get; set; }

Property value

SnapshotSerializer

SnapshotUpdateStrategy

InlineSnapshotSettings.cs

Gets or sets the strategy for updating snapshots when they don't match.

public SnapshotUpdateStrategy SnapshotUpdateStrategy { get; set; }

ValidateLineNumberUsingPdbInfoWhenAvailable

InlineSnapshotSettings.cs

Before editing a file, use the PDB to validate the line number containing the snapshot.

public bool ValidateLineNumberUsingPdbInfoWhenAvailable { get; set; }

Property value

bool

Remarks

PDB and CallerLineNumberAttribute does not provide the same value. PDB provide the start of the expression whereas the attribute provide the line containing the call to the method. In the case of a multiline expression, the values can differ.

ValidateSourceFilePathUsingPdbInfoWhenAvailable

InlineSnapshotSettings.cs

Before editing a file, use the PDB to validate the file path containing the snapshot.

public bool ValidateSourceFilePathUsingPdbInfoWhenAvailable { get; set; }

Property value

bool

Methods

NameDescription
Equals(InlineSnapshotSettings?)
Equals(object?)
GetHashCode()
ToString()

Equals overloads

Equals(InlineSnapshotSettings?)

public bool Equals(InlineSnapshotSettings? other)
Parameters
other InlineSnapshotSettings?
Returns

bool

No documentation is available.

Equals(object?)

public override bool Equals(object? obj)
Parameters
obj object?
Returns

bool

No documentation is available.

GetHashCode()

public override int GetHashCode()

Returns

int

No documentation is available.

public override string ToString()

Returns

string

No documentation is available.

Operators

NameDescription
operator ==(InlineSnapshotSettings?, InlineSnapshotSettings?)
operator !=(InlineSnapshotSettings?, InlineSnapshotSettings?)

operator ==(InlineSnapshotSettings?, InlineSnapshotSettings?)

public static bool operator ==(InlineSnapshotSettings? left, InlineSnapshotSettings? right)

No documentation is available.

operator !=(InlineSnapshotSettings?, InlineSnapshotSettings?)

public static bool operator !=(InlineSnapshotSettings? left, InlineSnapshotSettings? right)

No documentation is available.