From a582fddc225f0dae8cb04c32f760491fd5653a85 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 17 Jun 2021 16:38:48 -0700 Subject: [PATCH 1/3] Deprecate -p option (in short form) to dotnet watch Contributes to https://github.com/dotnet/designs/pull/229 --- src/BuiltInTools/dotnet-watch/Program.cs | 9 ++- src/BuiltInTools/dotnet-watch/Resources.resx | 57 ++++++++++--------- .../dotnet-watch/xlf/Resources.cs.xlf | 5 ++ .../dotnet-watch/xlf/Resources.de.xlf | 5 ++ .../dotnet-watch/xlf/Resources.es.xlf | 5 ++ .../dotnet-watch/xlf/Resources.fr.xlf | 5 ++ .../dotnet-watch/xlf/Resources.it.xlf | 5 ++ .../dotnet-watch/xlf/Resources.ja.xlf | 5 ++ .../dotnet-watch/xlf/Resources.ko.xlf | 5 ++ .../dotnet-watch/xlf/Resources.pl.xlf | 5 ++ .../dotnet-watch/xlf/Resources.pt-BR.xlf | 5 ++ .../dotnet-watch/xlf/Resources.ru.xlf | 5 ++ .../dotnet-watch/xlf/Resources.tr.xlf | 5 ++ .../dotnet-watch/xlf/Resources.zh-Hans.xlf | 5 ++ .../dotnet-watch/xlf/Resources.zh-Hant.xlf | 5 ++ .../CommandLineOptionsTests.cs | 21 ++++++- 16 files changed, 120 insertions(+), 32 deletions(-) diff --git a/src/BuiltInTools/dotnet-watch/Program.cs b/src/BuiltInTools/dotnet-watch/Program.cs index 9a72e6744da4..ebb4b4d8f205 100644 --- a/src/BuiltInTools/dotnet-watch/Program.cs +++ b/src/BuiltInTools/dotnet-watch/Program.cs @@ -105,11 +105,11 @@ public static async Task Main(string[] args) internal async Task RunAsync(string[] args) { - var rootCommand = CreateRootCommand(HandleWatch); + var rootCommand = CreateRootCommand(HandleWatch, _reporter); return await rootCommand.InvokeAsync(args); } - internal static RootCommand CreateRootCommand(Func> handler) + internal static RootCommand CreateRootCommand(Func> handler, IReporter reporter) { var quiet = new Option( new[] { "--quiet", "-q" }, @@ -147,6 +147,11 @@ internal static RootCommand CreateRootCommand(Func root.TreatUnmatchedTokensAsErrors = false; root.Handler = CommandHandler.Create((CommandLineOptions options, ParseResult parseResults) => { + if (!string.IsNullOrEmpty(parseResults.ValueForOption("-p"))) + { + reporter.Warn(Resources.Warning_ProjectAbbreviationDeprecated); + } + string[] remainingArguments; if (parseResults.UnparsedTokens.Any() && parseResults.UnmatchedTokens.Any()) { diff --git a/src/BuiltInTools/dotnet-watch/Resources.resx b/src/BuiltInTools/dotnet-watch/Resources.resx index 40d7b9cdf729..0a0b28841174 100644 --- a/src/BuiltInTools/dotnet-watch/Resources.resx +++ b/src/BuiltInTools/dotnet-watch/Resources.resx @@ -1,17 +1,17 @@  - @@ -129,4 +129,7 @@ Cannot specify both '--quiet' and '--verbose' options. + + The abbreviation of -p for --project is deprecated. Please use --project. + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf index 59d5f98e5b77..2d7b8e4287ad 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf @@ -22,6 +22,11 @@ Možnosti --quiet a --verbose se nedají zadat spolu. + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf index b772a5351792..f5fec21d57cc 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf @@ -22,6 +22,11 @@ Die Optionen "--quiet" und "--verbose" können nicht gleichzeitig angegeben werden. + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf index 9a01f59deae5..f00916b6a600 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf @@ -22,6 +22,11 @@ No se pueden especificar ambas opciones, "--quiet" y "--verbose". + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf index d06ee87bd3e9..47dee3765da9 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf @@ -22,6 +22,11 @@ Impossible de spécifier les options '--quiet' et '--verbose'. + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf index ced7af187f3f..59a3e1b1a54c 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf @@ -22,6 +22,11 @@ Non è possibile specificare entrambe le opzioni '--quiet' e '--verbose'. + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf index 34e19a784b9d..7d772e98bd1d 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf @@ -22,6 +22,11 @@ '--quiet' と '--verbose' の両方のオプションを指定することはできません。 + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf index 130b666b6f04..9dca8122fd54 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf @@ -22,6 +22,11 @@ '--quiet' 옵션과 '--verbose' 옵션을 둘 다 지정할 수는 없습니다. + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf index b31b93d70753..27ee6d0118e5 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf @@ -22,6 +22,11 @@ Nie można jednocześnie określić opcji „--quiet” i „--verbose”. + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf index e7a1e5088eda..116491d4ef3b 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf @@ -22,6 +22,11 @@ Não é possível especificar as opções '--quiet' e '--verbose'. + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf index 0230037ff9be..9336363682ce 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf @@ -22,6 +22,11 @@ Невозможно одновременно указать параметры "--quiet" и "--verbose". + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf index fe0b1cd8c3f0..3c4668392399 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf @@ -22,6 +22,11 @@ Hem '--quiet' hem de '--verbose' seçenekleri belirtilemez. + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf index f25a47e35b39..1d067953c3bc 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf @@ -22,6 +22,11 @@ 不能同时指定 "--quiet" 和 "--verbose" 选项。 + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf index 69667a91d1a1..677aa7b9995f 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf @@ -22,6 +22,11 @@ 無法同時指定 '--quiet' 和 '--verbose' 選項。 + + The abbreviation of -p for --project is deprecated. Please use --project. + The abbreviation of -p for --project is deprecated. Please use --project. + + \ No newline at end of file diff --git a/src/Tests/dotnet-watch.Tests/CommandLineOptionsTests.cs b/src/Tests/dotnet-watch.Tests/CommandLineOptionsTests.cs index e35be5a939e9..70177fa2c167 100644 --- a/src/Tests/dotnet-watch.Tests/CommandLineOptionsTests.cs +++ b/src/Tests/dotnet-watch.Tests/CommandLineOptionsTests.cs @@ -5,6 +5,7 @@ using System.CommandLine.IO; using System.CommandLine.Parsing; using System.Threading.Tasks; +using Moq; using Xunit; using Xunit.Abstractions; @@ -12,11 +13,13 @@ namespace Microsoft.DotNet.Watcher.Tools { public class CommandLineOptionsTests { + private readonly Extensions.Tools.Internal.TestReporter _testReporter; private readonly TestConsole _console; public CommandLineOptionsTests(ITestOutputHelper output) { _console = new(); + _testReporter = new(output); } [Theory] @@ -26,7 +29,7 @@ public CommandLineOptionsTests(ITestOutputHelper output) [InlineData(new object[] { new[] { "--help", "--bogus" } })] public async Task HelpArgs(string[] args) { - var rootCommand = Program.CreateRootCommand(c => Task.FromResult(0)); + var rootCommand = Program.CreateRootCommand(c => Task.FromResult(0), _testReporter); await rootCommand.InvokeAsync(args, _console); @@ -46,7 +49,7 @@ public async Task ParsesRemainingArgs(string[] args, string[] expected) { options = c; return Task.FromResult(0); - }); + }, _testReporter); await rootCommand.InvokeAsync(args, _console); @@ -59,11 +62,23 @@ public async Task ParsesRemainingArgs(string[] args, string[] expected) [Fact] public async Task CannotHaveQuietAndVerbose() { - var rootCommand = Program.CreateRootCommand(c => Task.FromResult(0)); + var rootCommand = Program.CreateRootCommand(c => Task.FromResult(0), _testReporter); await rootCommand.InvokeAsync(new[] { "--quiet", "--verbose" }, _console); Assert.Contains(Resources.Error_QuietAndVerboseSpecified, _console.Error.ToString()); } + + [Fact] + public async Task ShortFormForProjectArgumentPrintsWarning() + { + var reporter = new Mock(); + reporter.Setup(r => r.Warn(Resources.Warning_ProjectAbbreviationDeprecated)).Verifiable(); + var rootCommand = Program.CreateRootCommand(c => Task.FromResult(0), reporter.Object); + + await rootCommand.InvokeAsync(new[] { "-p", "MyProject.csproj" }, _console); + + reporter.Verify(); + } } } From 6ee6e8f79be66c142985092dbde66c3fb7408259 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 18 Jun 2021 11:24:05 -0700 Subject: [PATCH 2/3] Fixup --- src/BuiltInTools/dotnet-watch/Program.cs | 14 ++++- src/BuiltInTools/dotnet-watch/Resources.resx | 56 +++++++++---------- .../dotnet-watch/xlf/Resources.cs.xlf | 4 +- .../dotnet-watch/xlf/Resources.de.xlf | 4 +- .../dotnet-watch/xlf/Resources.es.xlf | 4 +- .../dotnet-watch/xlf/Resources.fr.xlf | 4 +- .../dotnet-watch/xlf/Resources.it.xlf | 4 +- .../dotnet-watch/xlf/Resources.ja.xlf | 4 +- .../dotnet-watch/xlf/Resources.ko.xlf | 4 +- .../dotnet-watch/xlf/Resources.pl.xlf | 4 +- .../dotnet-watch/xlf/Resources.pt-BR.xlf | 4 +- .../dotnet-watch/xlf/Resources.ru.xlf | 4 +- .../dotnet-watch/xlf/Resources.tr.xlf | 4 +- .../dotnet-watch/xlf/Resources.zh-Hans.xlf | 4 +- .../dotnet-watch/xlf/Resources.zh-Hant.xlf | 4 +- .../CommandLineOptionsTests.cs | 19 ++++++- 16 files changed, 83 insertions(+), 58 deletions(-) diff --git a/src/BuiltInTools/dotnet-watch/Program.cs b/src/BuiltInTools/dotnet-watch/Program.cs index ebb4b4d8f205..7ec40e095791 100644 --- a/src/BuiltInTools/dotnet-watch/Program.cs +++ b/src/BuiltInTools/dotnet-watch/Program.cs @@ -137,8 +137,11 @@ internal static RootCommand CreateRootCommand(Func new[] { "--no-hot-reload" }, "Suppress hot reload for supported apps."), new Option( - new[] { "--project", "-p" }, + "--project", "The project to watch"), + new Option( + "-p", + "The project to watch") { IsHidden = true }, new Option( "--list", "Lists all discovered files without starting the watcher"), @@ -147,9 +150,14 @@ internal static RootCommand CreateRootCommand(Func root.TreatUnmatchedTokensAsErrors = false; root.Handler = CommandHandler.Create((CommandLineOptions options, ParseResult parseResults) => { - if (!string.IsNullOrEmpty(parseResults.ValueForOption("-p"))) + if (string.IsNullOrEmpty(options.Project)) { - reporter.Warn(Resources.Warning_ProjectAbbreviationDeprecated); + var projectOptionShort = parseResults.ValueForOption("-p"); + if (!string.IsNullOrEmpty(projectOptionShort)) + { + reporter.Warn(Resources.Warning_ProjectAbbreviationDeprecated); + options.Project = projectOptionShort; + } } string[] remainingArguments; diff --git a/src/BuiltInTools/dotnet-watch/Resources.resx b/src/BuiltInTools/dotnet-watch/Resources.resx index 0a0b28841174..5497b3dcd5cc 100644 --- a/src/BuiltInTools/dotnet-watch/Resources.resx +++ b/src/BuiltInTools/dotnet-watch/Resources.resx @@ -1,17 +1,17 @@  - @@ -130,6 +130,6 @@ Cannot specify both '--quiet' and '--verbose' options. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf index 2d7b8e4287ad..8ff1166ae02c 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf index f5fec21d57cc..9122d85719ba 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf index f00916b6a600..4d07a8b7697d 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf index 47dee3765da9..3eb625430f89 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf index 59a3e1b1a54c..f7f69debbd64 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf index 7d772e98bd1d..609369e4d43e 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf index 9dca8122fd54..4a45d362c786 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf index 27ee6d0118e5..1fdba918ebe6 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf index 116491d4ef3b..9d1ae51a78cc 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf index 9336363682ce..b4951f921909 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf index 3c4668392399..1270702ffdf1 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf index 1d067953c3bc..90ddbdba74de 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf index 677aa7b9995f..369be6251bfb 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf @@ -23,8 +23,8 @@ - The abbreviation of -p for --project is deprecated. Please use --project. - The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/Tests/dotnet-watch.Tests/CommandLineOptionsTests.cs b/src/Tests/dotnet-watch.Tests/CommandLineOptionsTests.cs index 70177fa2c167..0e38505461bd 100644 --- a/src/Tests/dotnet-watch.Tests/CommandLineOptionsTests.cs +++ b/src/Tests/dotnet-watch.Tests/CommandLineOptionsTests.cs @@ -74,11 +74,28 @@ public async Task ShortFormForProjectArgumentPrintsWarning() { var reporter = new Mock(); reporter.Setup(r => r.Warn(Resources.Warning_ProjectAbbreviationDeprecated)).Verifiable(); - var rootCommand = Program.CreateRootCommand(c => Task.FromResult(0), reporter.Object); + CommandLineOptions options = null; + var rootCommand = Program.CreateRootCommand(c => { options = c; return Task.FromResult(0); }, reporter.Object); await rootCommand.InvokeAsync(new[] { "-p", "MyProject.csproj" }, _console); reporter.Verify(); + Assert.NotNull(options); + Assert.Equal("MyProject.csproj", options.Project); + } + + [Fact] + public async Task LongFormForProjectArgumentWorks() + { + var reporter = new Mock(); + CommandLineOptions options = null; + var rootCommand = Program.CreateRootCommand(c => { options = c; return Task.FromResult(0); }, reporter.Object); + + await rootCommand.InvokeAsync(new[] { "--project", "MyProject.csproj" }, _console); + + reporter.Verify(r => r.Warn(It.IsAny()), Times.Never()); + Assert.NotNull(options); + Assert.Equal("MyProject.csproj", options.Project); } } } From 2037fe93c71f8d4296ff79721c3328d572aa82d0 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 18 Jun 2021 11:28:39 -0700 Subject: [PATCH 3/3] Use error code --- src/BuiltInTools/dotnet-watch/Resources.resx | 2 +- src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf | 4 ++-- src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf | 4 ++-- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/BuiltInTools/dotnet-watch/Resources.resx b/src/BuiltInTools/dotnet-watch/Resources.resx index 5497b3dcd5cc..30a8cd6c1ec8 100644 --- a/src/BuiltInTools/dotnet-watch/Resources.resx +++ b/src/BuiltInTools/dotnet-watch/Resources.resx @@ -130,6 +130,6 @@ Cannot specify both '--quiet' and '--verbose' options. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. \ No newline at end of file diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf index 8ff1166ae02c..43f860f58ef0 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.cs.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf index 9122d85719ba..dc9dcdd089cf 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.de.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf index 4d07a8b7697d..7b92c1b8987c 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.es.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf index 3eb625430f89..c3e3202db59a 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.fr.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf index f7f69debbd64..83b5c6351028 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.it.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf index 609369e4d43e..2e4c1202b35f 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.ja.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf index 4a45d362c786..7c20a39fdc9d 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.ko.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf index 1fdba918ebe6..b28408e463aa 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.pl.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf index 9d1ae51a78cc..c5c484e3f462 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.pt-BR.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf index b4951f921909..656d3c554793 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.ru.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf index 1270702ffdf1..70ccc020fa8c 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.tr.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf index 90ddbdba74de..92902902fd1c 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hans.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. diff --git a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf index 369be6251bfb..4762234ba060 100644 --- a/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf +++ b/src/BuiltInTools/dotnet-watch/xlf/Resources.zh-Hant.xlf @@ -23,8 +23,8 @@ - Warning: The abbreviation of -p for --project is deprecated. Please use --project. - Warning: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project. + Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project.