From 38042cd80466509c9cb4daabb6f59c678aff86bd Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 15 Oct 2025 10:31:14 -0700 Subject: [PATCH 1/2] Try to fix the null-ref exception --- PSReadLine/DynamicHelp.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/PSReadLine/DynamicHelp.cs b/PSReadLine/DynamicHelp.cs index bbd6bf70e..c863d8131 100644 --- a/PSReadLine/DynamicHelp.cs +++ b/PSReadLine/DynamicHelp.cs @@ -67,7 +67,6 @@ object IPSConsoleReadLineMockableMethods.GetDynamicHelpContent(string commandNam .AddParameter("Parameter", parameterName) .Invoke() .FirstOrDefault(); - } catch (Exception) { @@ -194,9 +193,9 @@ private void WriteParameterHelp(dynamic helpContent) { Collection helpBlock; - if (helpContent?.Description is not string descriptionText) + if (helpContent.Description is not string descriptionText) { - descriptionText = helpContent?.Description?[0]?.Text; + descriptionText = helpContent.Description?[0]?.Text; } if (descriptionText is null) @@ -209,7 +208,7 @@ private void WriteParameterHelp(dynamic helpContent) } else { - string syntax = $"-{helpContent.name} <{helpContent.type.name}>"; + string syntax = $"-{helpContent.name} <{helpContent.type?.name}>"; helpBlock = new Collection { string.Empty, From 6c231ecf4ebca4513f0f238b923d7f3871b46859 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 15 Oct 2025 10:33:10 -0700 Subject: [PATCH 2/2] Add an assertion --- PSReadLine/DynamicHelp.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PSReadLine/DynamicHelp.cs b/PSReadLine/DynamicHelp.cs index c863d8131..a43e8f6a5 100644 --- a/PSReadLine/DynamicHelp.cs +++ b/PSReadLine/DynamicHelp.cs @@ -191,6 +191,8 @@ private void WriteDynamicHelpBlock(Collection helpBlock) private void WriteParameterHelp(dynamic helpContent) { + System.Diagnostics.Debug.Assert(helpContent is not null); + Collection helpBlock; if (helpContent.Description is not string descriptionText)