using System.Diagnostics;
using System.Runtime.InteropServices;
namespace CommIpc;
public static class PipeName
{
///
/// Creates a pipe name that is unique per parent process instance and child id.
///
public static string ForChild(int childId, int? parentPid = null)
{
parentPid ??= Environment.ProcessId;
return $"CommTester_{parentPid}_{childId}";
}
///
/// Returns the full pipe path for the current platform.
/// Windows: \\.\pipe\{pipeName}
/// Unix/macOS: /tmp/CoreFxPipe_{pipeName}
///
public static string Describe(string pipeName) =>
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? $"\\\\.\\pipe\\{pipeName}" : $"/tmp/CoreFxPipe_{pipeName}";
}