InlineSnapshotAssertionAttribute Class

Marks a method as an inline snapshot assertion method and specifies the parameter that contains the expected snapshot value. This attribute is used to enable snapshot validation in helper methods.

[AttributeUsage(AttributeTargets.Method)]
public sealed class InlineSnapshotAssertionAttribute : Attribute

Example

Helper(new { Name = "John" }, "Name: John");

[InlineSnapshotAssertion(nameof(expected))]
static void Helper(object data, string expected, [CallerFilePath] string? filePath = null, [CallerLineNumber] int lineNumber = -1)
{
    InlineSnapshot.Validate(data, expected, filePath, lineNumber);
}
Inheritance
Attribute InlineSnapshotAssertionAttribute

Constructors

NameDescription
InlineSnapshotAssertionAttribute(string)Initializes a new instance of the InlineSnapshotAssertionAttribute class with the specified parameter name.

InlineSnapshotAssertionAttribute(string)

InlineSnapshotAssertionAttribute.cs

Initializes a new instance of the InlineSnapshotAssertionAttribute class with the specified parameter name.

public InlineSnapshotAssertionAttribute(string parameterName)

Parameters

parameterName string
The name of the parameter that contains the expected snapshot value.

Properties

NameDescription
ParameterNameGets the name of the parameter that contains the expected snapshot value.

Gets the name of the parameter that contains the expected snapshot value.

public string ParameterName { get; }

Property value

string