Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.

Commit 469e37f

Browse files
committed
add object writing
1 parent d95a986 commit 469e37f

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
33
<PropertyGroup>
4-
<Version>1.6.0</Version>
4+
<Version>1.7.0</Version>
55
<NoWarn>CS1591;xUnit1026</NoWarn>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>

src/XunitContext/Context.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ void InitBuilder()
101101
}
102102
}
103103

104+
/// <summary>
105+
/// Writes a value to the current <see cref="ITestOutputHelper"/>.
106+
/// </summary>
107+
public void Write(object value)
108+
{
109+
Guard.AgainstNull(value, nameof(value));
110+
Write(value.ToString());
111+
}
112+
104113
/// <summary>
105114
/// Writes a string to the current <see cref="ITestOutputHelper"/>.
106115
/// </summary>
@@ -172,6 +181,15 @@ public void WriteLine()
172181
}
173182
}
174183

184+
/// <summary>
185+
/// Writes a line to the current <see cref="ITestOutputHelper"/>.
186+
/// </summary>
187+
public void WriteLine(object value)
188+
{
189+
Guard.AgainstNull(value, nameof(value));
190+
WriteLine(value.ToString());
191+
}
192+
175193
/// <summary>
176194
/// Writes a line to the current <see cref="ITestOutputHelper"/>.
177195
/// </summary>

src/XunitContext/XunitContext.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ private static void InnerInit()
8686

8787
public static void Write(string value)
8888
{
89-
Guard.AgainstNull(value, nameof(value));
89+
Context.Write(value);
90+
}
91+
92+
public static void Write(object value)
93+
{
9094
Context.Write(value);
9195
}
9296

@@ -119,6 +123,11 @@ public static void WriteLine(string value)
119123
Context.WriteLine(value);
120124
}
121125

126+
public static void WriteLine(object value)
127+
{
128+
Context.WriteLine(value);
129+
}
130+
122131
public static IReadOnlyList<string> Flush(bool clearAsyncLocal = true)
123132
{
124133
var context = local.Value;

0 commit comments

Comments
 (0)