From d04b0c7c9ed817c0492c38f05e18545351e31831 Mon Sep 17 00:00:00 2001 From: Morten Brix Pedersen Date: Thu, 22 Jul 2021 23:57:24 +0200 Subject: [PATCH 1/2] Upgrade McMaster.Extensions.CommandLineUtils to 3.1.0. --- build/Packages.props | 2 +- src/OmniSharp.Host/CommandLineApplication.cs | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/build/Packages.props b/build/Packages.props index 90f4da26b9..f779ef748b 100644 --- a/build/Packages.props +++ b/build/Packages.props @@ -18,7 +18,7 @@ - + diff --git a/src/OmniSharp.Host/CommandLineApplication.cs b/src/OmniSharp.Host/CommandLineApplication.cs index 17ba4c54f4..260796dc7a 100644 --- a/src/OmniSharp.Host/CommandLineApplication.cs +++ b/src/OmniSharp.Host/CommandLineApplication.cs @@ -24,7 +24,10 @@ public class CommandLineApplication public CommandLineApplication() { - Application = new McMaster.Extensions.CommandLineUtils.CommandLineApplication(throwOnUnexpectedArg: false); + Application = new McMaster.Extensions.CommandLineUtils.CommandLineApplication + { + UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.StopParsingAndCollect + }; Application.HelpOption("-? | -h | --help"); _applicationRoot = Application.Option("-s | --source", "Solution or directory for OmniSharp to point at (defaults to current directory).", CommandOptionType.SingleValue); @@ -62,15 +65,6 @@ public int Execute(string[] args) return Application.Execute(args.Except(OtherArgs).ToArray()); } - public void OnExecute(Func> func) - { - Application.OnExecute(() => - { - DebugAttach(); - return func(); - }); - } - public void OnExecute(Func func) { Application.OnExecute(() => From e38675bf30522813f6b3981e33dff69a0a473f0c Mon Sep 17 00:00:00 2001 From: Morten Brix Pedersen Date: Fri, 23 Jul 2021 10:08:17 +0200 Subject: [PATCH 2/2] Add new OnExecuteAsync variant and obsolete the old noe. --- src/OmniSharp.Host/CommandLineApplication.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/OmniSharp.Host/CommandLineApplication.cs b/src/OmniSharp.Host/CommandLineApplication.cs index 260796dc7a..2f3861ce4b 100644 --- a/src/OmniSharp.Host/CommandLineApplication.cs +++ b/src/OmniSharp.Host/CommandLineApplication.cs @@ -65,6 +65,25 @@ public int Execute(string[] args) return Application.Execute(args.Except(OtherArgs).ToArray()); } + [Obsolete("Please use OnExecuteAsync instead")] + public void OnExecute(Func> func) + { + Application.OnExecuteAsync((_) => + { + DebugAttach(); + return func(); + }); + } + + public void OnExecuteAsync(Func> func) + { + Application.OnExecuteAsync((token) => + { + DebugAttach(); + return func(token); + }); + } + public void OnExecute(Func func) { Application.OnExecute(() =>