Skip to content

Commit 4482a99

Browse files
rmarinhoCopilot
andcommitted
Address Copilot review round 4: whitespace-tolerant parsing, tab test
- ParseReverseListOutput now splits on all whitespace (tabs, spaces) instead of single space - Added ParseReverseListOutput_TabSeparated test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7b10652 commit 4482a99

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/Xamarin.Android.Tools.AndroidSdk/Runners/AdbRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ internal static IReadOnlyList<AdbPortRule> ParseReverseListOutput (IEnumerable<s
343343
if (!trimmed.StartsWith ("(reverse)", StringComparison.Ordinal))
344344
continue;
345345

346-
var parts = trimmed.Substring ("(reverse)".Length).Trim ().Split (new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
346+
var parts = trimmed.Substring ("(reverse)".Length).Trim ().Split ((char[]?) null, StringSplitOptions.RemoveEmptyEntries);
347347
if (parts.Length >= 2) {
348348
var remote = AdbPortSpec.TryParse (parts [0]);
349349
var local = AdbPortSpec.TryParse (parts [1]);

tests/Xamarin.Android.Tools.AndroidSdk-Tests/AdbRunnerTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,21 @@ public void ParseReverseListOutput_WindowsLineEndings ()
848848
Assert.AreEqual (8081, rules [1].Remote.Port);
849849
}
850850

851+
[Test]
852+
public void ParseReverseListOutput_TabSeparated ()
853+
{
854+
var output = new [] {
855+
"(reverse)\ttcp:5000\ttcp:5000",
856+
"(reverse)\ttcp:8081\ttcp:8081",
857+
};
858+
859+
var rules = AdbRunner.ParseReverseListOutput (output);
860+
861+
Assert.AreEqual (2, rules.Count);
862+
Assert.AreEqual (5000, rules [0].Remote.Port);
863+
Assert.AreEqual (8081, rules [1].Remote.Port);
864+
}
865+
851866
// --- AdbPortSpec tests ---
852867

853868
[Test]

0 commit comments

Comments
 (0)