Class DiffSuggestionAnalyzer
- Namespace
- SnapshotAssertions
- Assembly
- SnapshotAssertions.dll
Scans the rendered diff from a snapshot mismatch for known volatile patterns (GUID, GUID N-format, ISO 8601 timestamp, Unix epoch milliseconds, elapsed ms) and surfaces DiffSuggestion entries recommending applicable built-in scrubbers. Pure: no IO, no allocation beyond the result list and the per-pattern match enumeration.
public static class DiffSuggestionAnalyzer
- Inheritance
-
DiffSuggestionAnalyzer
- Inherited Members
Remarks
The analyzer counts regex matches only on lines that begin with the diff
markers + or - (i.e. the differing lines emitted by
LineDiffRenderer). Context lines that match between expected and
actual are skipped so a pattern that appears in both sides without drift does NOT
surface as a suggestion.
The result list is sorted by Count descending, stable secondary ordering by pattern declaration order. Patterns with zero hits are omitted. Callers that want to cap the suggestion list at a maximum count (e.g. the top 3 + rollup pattern used by WriteDescription(TextWriter)) apply that cap on top of the analyzer output.
Methods
Analyze(string)
Scans diff for the five built-in volatile patterns and returns
matching scrubber recommendations.
public static IReadOnlyList<DiffSuggestion> Analyze(string diff)
Parameters
diffstringA rendered diff string, typically the Diff property. Lines beginning with
+or-are scanned; other lines are skipped. May be empty (yields an empty result list).
Returns
- IReadOnlyList<DiffSuggestion>
The list of suggestions, sorted by hit count descending. Empty if the diff is empty, has no differing lines, or contains no known patterns.
Exceptions
- ArgumentNullException
diffis null.