Skip to content

Commit cc6b05b

Browse files
committed
fix: add debugger display and custom ToString to SwapStyleBuilder
1 parent cfb400a commit cc6b05b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Htmxor/Http/SwapStyleBuilder.cs

+13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using System.Collections;
22
using System.Collections.Specialized;
3+
using System.Diagnostics;
34
using System.Numerics;
45

56
namespace Htmxor.Http;
67

78
/// <summary>
89
/// A builder class for constructing a swap style command string for HTMX responses.
910
/// </summary>
11+
[DebuggerDisplay("{ToString(),nq}")]
1012
public sealed class SwapStyleBuilder
1113
{
1214
private readonly SwapStyle style;
@@ -311,6 +313,17 @@ public SwapStyleBuilder ShowNone()
311313
return this;
312314
}
313315

316+
/// <inheritdoc/>
317+
public override string ToString()
318+
{
319+
var (swapStyle, modifier) = Build();
320+
var style = swapStyle.ToHtmxString();
321+
var value = !string.IsNullOrWhiteSpace(modifier)
322+
? $"{style} {modifier}"
323+
: style;
324+
return value;
325+
}
326+
314327
/// <summary>
315328
/// Builds the swap style command string with all specified modifiers.
316329
/// </summary>

0 commit comments

Comments
 (0)