Skip to content

Commit 7f55b2d

Browse files
authored
[logcat-parse] Use C# verbatim strings for paths (#927)
`logcat-parse` didn't properly deal with execution on Windows; when specifying a Windows-style path on Windows: > cd "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android" > .\logcat-parse.exe \path\to\my\grefs.txt var grefs = Grefs.Parse("\path\to\my\grefs.txt"); (1,52): error CS1009: Unrecognized escape sequence `\p' (1,60): error CS1009: Unrecognized escape sequence `\m' (1,63): error CS1009: Unrecognized escape sequence `\g' `logcat-parse` could still be used, but you'd either have to use `/` instead of `\`, or invoke `logcat-parse` from where `grefs.txt` is: > cd \path\to\my > "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\logcat-parse.exe" ^ grefs.txt // `adb logcat` GREF parsing utility // // Use `Grefs.Parse(stream)` to parse a file containing `adb logcat` output. // Grefs.AllocatedPeers contains all exposed Java.Lang.Object instances. // Grefs.AlivePeers contains those still alive by the end of parsing. var grefs = Grefs.Parse("grefs.txt"); Mono C# Shell, type "help;" for help Enter statements below. csharp> Fix `logcat-parse` so that [C# verbatim strings][0] are used: > "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\logcat-parse.exe" ^ \path\to\my\grefs.txt … var grefs = Grefs.Parse(@"\path\to\my\grefs.txt"); This allows straightforward usage on Windows. [0]: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/strings/#regular-and-verbatim-string-literals
1 parent 2601146 commit 7f55b2d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/logcat-parse/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public static int Main (string[] args)
4848
if (files.Count > 0) {
4949
if (files.Count > 1)
5050
Console.Error.WriteLine ("logcat-parse: More than one file is unsupported. Loading: {0}", files [0]);
51-
Console.WriteLine ("var grefs = Grefs.Parse(\"{0}\"{1});", files [0],
51+
Console.WriteLine ("var grefs = Grefs.Parse(@\"{0}\"{1});", files [0],
5252
pid.HasValue ? ", " + pid.Value : "");
5353
eval.Run ("Grefs grefs;");
5454
eval.Run (
55-
"using (var __source = new System.IO.StreamReader(\"" +
55+
"using (var __source = new System.IO.StreamReader(@\"" +
5656
files [0] +
5757
"\")) grefs = Grefs.Parse(__source" +
5858
(pid.HasValue ? (", " + pid.ToString ()) : "") + ");");

0 commit comments

Comments
 (0)