Skip to content

Commit 9f51756

Browse files
committed
Share binlog arg detection code
1 parent 8094d49 commit 9f51756

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/Cli/dotnet/commands/VirtualProjectBuildingCommand.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Microsoft.Build.Framework;
1212
using Microsoft.Build.Logging;
1313
using Microsoft.DotNet.Cli.Utils;
14+
using Microsoft.DotNet.Tools.Run;
1415

1516
namespace Microsoft.DotNet.Tools;
1617

@@ -100,9 +101,7 @@ public int Execute(string[] binaryLoggerArgs, LoggerVerbosity verbosity)
100101
for (int i = args.Length - 1; i >= 0; i--)
101102
{
102103
var arg = args[i];
103-
if (arg.StartsWith("/bl:") || arg.Equals("/bl")
104-
|| arg.StartsWith("--binaryLogger:") || arg.Equals("--binaryLogger")
105-
|| arg.StartsWith("-bl:") || arg.Equals("-bl"))
104+
if (RunCommand.IsBinLogArgument(arg))
106105
{
107106
return new BinaryLogger
108107
{

src/Cli/dotnet/commands/dotnet-run/Program.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ public static RunCommand FromArgs(string[] args)
1717
return FromParseResult(parseResult);
1818
}
1919

20+
internal static bool IsBinLogArgument(string arg)
21+
{
22+
const StringComparison comp = StringComparison.Ordinal;
23+
return arg.StartsWith("/bl:", comp) || arg.Equals("/bl", comp)
24+
|| arg.StartsWith("--binaryLogger:", comp) || arg.Equals("--binaryLogger", comp)
25+
|| arg.StartsWith("-bl:", comp) || arg.Equals("-bl", comp);
26+
}
27+
2028
public static RunCommand FromParseResult(ParseResult parseResult)
2129
{
2230
if (parseResult.UsingRunCommandShorthandProjectOption())
@@ -35,10 +43,7 @@ public static RunCommand FromParseResult(ParseResult parseResult)
3543
var nonBinLogArgs = new List<string>();
3644
foreach (var arg in applicationArguments)
3745
{
38-
39-
if (arg.StartsWith("/bl:") || arg.Equals("/bl")
40-
|| arg.StartsWith("--binaryLogger:") || arg.Equals("--binaryLogger")
41-
|| arg.StartsWith("-bl:") || arg.Equals("-bl"))
46+
if (IsBinLogArgument(arg))
4247
{
4348
binlogArgs.Add(arg);
4449
}

0 commit comments

Comments
 (0)