Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static async Task<CommandInfo> GetCommandInfoAsync(
.FirstOrDefault();

// Only cache CmdletInfos since they're exposed in binaries they are likely to not change throughout the session.
if (commandInfo.CommandType == CommandTypes.Cmdlet)
if (commandInfo?.CommandType == CommandTypes.Cmdlet)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would have crashed here before this change if commandInfo was null. Now that the code will get past here, do the callers of this method properly handle a null return value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. They handle a null value. The change I added with the caching is what didn't handle a null value

{
s_commandInfoCache.TryAdd(commandName, commandInfo);
}
Expand Down