Skip to content

Commit b6c3e48

Browse files
authored
Fix a null reference exception when showing parameter help (#4971)
1 parent 4a72454 commit b6c3e48

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

PSReadLine/DynamicHelp.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ object IPSConsoleReadLineMockableMethods.GetDynamicHelpContent(string commandNam
6767
.AddParameter("Parameter", parameterName)
6868
.Invoke<PSObject>()
6969
.FirstOrDefault();
70-
7170
}
7271
catch (Exception)
7372
{
@@ -192,11 +191,13 @@ private void WriteDynamicHelpBlock(Collection<string> helpBlock)
192191

193192
private void WriteParameterHelp(dynamic helpContent)
194193
{
194+
System.Diagnostics.Debug.Assert(helpContent is not null);
195+
195196
Collection<string> helpBlock;
196197

197-
if (helpContent?.Description is not string descriptionText)
198+
if (helpContent.Description is not string descriptionText)
198199
{
199-
descriptionText = helpContent?.Description?[0]?.Text;
200+
descriptionText = helpContent.Description?[0]?.Text;
200201
}
201202

202203
if (descriptionText is null)
@@ -209,7 +210,7 @@ private void WriteParameterHelp(dynamic helpContent)
209210
}
210211
else
211212
{
212-
string syntax = $"-{helpContent.name} <{helpContent.type.name}>";
213+
string syntax = $"-{helpContent.name} <{helpContent.type?.name}>";
213214
helpBlock = new Collection<string>
214215
{
215216
string.Empty,

0 commit comments

Comments
 (0)