Skip to content

Commit 42f0814

Browse files
Update NotepadWindow to do a no-op if not running on Windows
1 parent 0420051 commit 42f0814

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Serilog.Sinks.Notepad/Sinks/Notepad/NotepadWindow.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
using System;
16+
using System.Runtime.InteropServices;
1617
using Serilog.Sinks.Notepad.Interop;
1718

1819
namespace Serilog.Sinks.Notepad
@@ -38,6 +39,11 @@ public static class NotepadWindow
3839
/// <param name="value">The string to be written</param>
3940
public static void Write(string value)
4041
{
42+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
43+
{
44+
return;
45+
}
46+
4147
var notepadWindow = _notepadWindow.Value;
4248
notepadWindow.Write(value);
4349
notepadWindow.Flush();
@@ -48,6 +54,11 @@ public static void Write(string value)
4854
/// </summary>
4955
public static void WriteLine()
5056
{
57+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
58+
{
59+
return;
60+
}
61+
5162
var notepadWindow = _notepadWindow.Value;
5263
notepadWindow.WriteLine();
5364
notepadWindow.Flush();
@@ -59,6 +70,11 @@ public static void WriteLine()
5970
/// <param name="value">The string to be written</param>
6071
public static void WriteLine(string value)
6172
{
73+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
74+
{
75+
return;
76+
}
77+
6278
var notepadWindow = _notepadWindow.Value;
6379
notepadWindow.WriteLine(value);
6480
notepadWindow.Flush();

0 commit comments

Comments
 (0)