Skip to content

Commit b62c516

Browse files
fix: make invalid UNC path error message platform-specific (#1351)
This PR updates the `InvalidUncPath` error message to be platform specific, referencing the form `\\server\share` in Windows environments, and `//server/share` in other environments. The method now checks the environment's platform (`RuntimeInformation.IsOSPlatform(OSPlatform.Windows)`) and conditionally returns an `IOException` with the correctly-formed UNC path in the message, using `System.Runtime.InteropServices` in the `CommonExceptions` class.
1 parent 112ab13 commit b62c516

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/TestableIO.System.IO.Abstractions.TestingHelpers/CommonExceptions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Globalization;
2+
using System.Runtime.InteropServices;
23

34
namespace System.IO.Abstractions.TestingHelpers;
45

@@ -55,7 +56,9 @@ public static ArgumentException IllegalCharactersInPath(string paramName = null)
5556
: new ArgumentException(StringResources.Manager.GetString("ILLEGAL_CHARACTERS_IN_PATH_EXCEPTION"));
5657

5758
public static ArgumentException InvalidUncPath(string paramName) =>
58-
new ArgumentException(@"The UNC path should be of the form \\server\share.", paramName);
59+
RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
60+
? new ArgumentException(@"The UNC path should be of the form \\server\share.", paramName)
61+
: new ArgumentException(@"The UNC path should be of the form //server/share.", paramName);
5962

6063
public static IOException ProcessCannotAccessFileInUse(string paramName = null) =>
6164
paramName != null

0 commit comments

Comments
 (0)