diff --git a/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs b/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs index 8c91ca4..aacaa25 100644 --- a/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs +++ b/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; namespace RtMidi.Core.Unmanaged.Devices.Infos { @@ -8,10 +9,14 @@ internal RtMidiDeviceInfo(uint port, string name) { Port = port; - // RtMidi may add port number to end of name to ensure uniqueness - Name = name.EndsWith(port.ToString()) - ? name.Substring(0, name.LastIndexOf(port.ToString(), StringComparison.Ordinal)) + // RtMidi may add port number to end of name on Windows to ensure uniqueness + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Name = name.EndsWith(port.ToString()) + ? name.Substring(0, name.LastIndexOf(port.ToString(), StringComparison.Ordinal) - 1) : name; + } + else { Name = name; } } public uint Port { get; }