From d0ca50c2c08c8cce683d6f4aba91f06b58fa8e4e Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 30 May 2017 16:07:30 -0700 Subject: [PATCH] Catch RuntimeException when getting signatures with bad attribute This change catches a RuntimeException that may occur when the user types out the name of a command or script which uses an invalid parameter binding attribute. This exception will be logged and the signatures just won't be displayed for that command. Resolves #462. --- src/PowerShellEditorServices/Language/LanguageService.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/PowerShellEditorServices/Language/LanguageService.cs b/src/PowerShellEditorServices/Language/LanguageService.cs index 57b0eef4c..f808a2a1d 100644 --- a/src/PowerShellEditorServices/Language/LanguageService.cs +++ b/src/PowerShellEditorServices/Language/LanguageService.cs @@ -481,6 +481,15 @@ await CommandHelpers.GetCommandInfo( IEnumerable commandParamSets = commandInfo.ParameterSets; return new ParameterSetSignatures(commandParamSets, foundSymbol); } + catch (RuntimeException e) + { + // A RuntimeException will be thrown when an invalid attribute is + // on a parameter binding block and then that command/script has + // its signatures resolved by typing it into a script. + Logger.WriteException("RuntimeException encountered while accessing command parameter sets", e); + + return null; + } catch (InvalidOperationException) { // For some commands there are no paramsets (like applications). Until