Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/combinations.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public class CombinationResultsConverter :
var items = results.Items;
if (items.Count == 0)
{
writer.WriteEndObject();
return;
}

Expand Down Expand Up @@ -363,16 +364,19 @@ public class CombinationResultsConverter :
builder.Append(trimmed);
if (!trimmed.EndsWith('.'))
{
builder.Append(". ");
builder.Append('.');
}

// separate from the next line even when the sentence was already terminated
builder.Append(' ');
}

builder.TrimEnd();
return builder.ToString();
}
}
```
<sup><a href='/src/Verify/Combinations/CombinationResultsConverter.cs#L1-L185' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationResultsConverter.cs' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify/Combinations/CombinationResultsConverter.cs#L1-L189' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationResultsConverter.cs' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
results: {},
after: TheValue
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
1: ArgumentException: Value cannot be null. Parameter name: p.,
10: ArgumentException: Value cannot be null. Parameter name: p.
}
32 changes: 32 additions & 0 deletions src/Verify.Tests/CombinationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,38 @@ public Task RecordingWithExceptionPausedTest()
.IgnoreStackTrace();
}

static string ThrowMultiLine(int value) =>
throw new ArgumentException(
"""
Value cannot be null.
Parameter name: p
""");

// ArgumentException messages are flattened onto one line, so the parts of the
// message need a separator between them
[Fact]
public Task MultiLineArgumentException() =>
Combination(captureExceptions: true)
.Verify(
ThrowMultiLine,
params1);

// Only reachable by constructing the results directly, since the runner requires
// every list to have at least one item
[Fact]
public Task EmptyResults() =>
Verify(new CombinationResults([], [], null));

// an unclosed object would swallow everything written after it
[Fact]
public Task EmptyResultsNested() =>
Verify(
new
{
results = new CombinationResults([], [], null),
after = "TheValue"
});

[Fact]
public Task RecordingPausedTest()
{
Expand Down
6 changes: 5 additions & 1 deletion src/Verify/Combinations/CombinationResultsConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public override void Write(VerifyJsonWriter writer, CombinationResults results)
var items = results.Items;
if (items.Count == 0)
{
writer.WriteEndObject();
return;
}

Expand Down Expand Up @@ -175,8 +176,11 @@ static string FlattenMessage(string message)
builder.Append(trimmed);
if (!trimmed.EndsWith('.'))
{
builder.Append(". ");
builder.Append('.');
}

// separate from the next line even when the sentence was already terminated
builder.Append(' ');
}

builder.TrimEnd();
Expand Down
4 changes: 2 additions & 2 deletions src/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ All six resolved 2026-08-16 (five fixed here; the inline item resolved as by-des
- [ ] **MSTest source generator ignores `record` test classes.**
`Verify.MSTest.SourceGenerator/UsesVerifyGenerator.cs:125-126` — only `ClassDeclarationSyntax` is eligible; `[UsesVerify] [TestClass] partial record` compiles then fails at runtime with the misleading "TestContext is null" error. `Parser.GetParentClasses` similarly stops at a `record struct` parent.

- [ ] **Unclosed JSON object for empty `CombinationResults`.**
- [x] **Unclosed JSON object for empty `CombinationResults`.**
`Verify/Combinations/CombinationResultsConverter.cs:8-14` — `WriteStartObject()` then early `return` with no `WriteEndObject()`. Only reachable by constructing `CombinationResults([], ...)` directly.

- [ ] **`FlattenMessage` omits the joining space after a line ending in `.`.**
- [x] **`FlattenMessage` omits the joining space after a line ending in `.`.**
`Verify/Combinations/CombinationResultsConverter.cs:168-183` — two-line messages (net48 `ArgumentNullException`) render as `"Value cannot be null.Parameter name: p"`.

- [ ] **Negative sub-hour offsets render unsigned.**
Expand Down
Loading