Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.InteropServices;

namespace RtMidi.Core.Unmanaged.Devices.Infos
{
Expand All @@ -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; }
Expand Down