Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs (C#)

Code before:
            {
                // Process alias when there is partial input
                foreach (var alias in param.Parameter.Aliases)
                {
                    if (pattern.IsMatch(alias))
                    {
                        result.Add(new CompletionResult(
                            $"-{alias}{colonSuffix}",
                            alias,
                            CompletionResultType.ParameterName,
                            parameterType + alias + helpMessage));
                    }
                }
            }

            return result;
        }

#nullable enable
        /// <summary>
        /// Gets the help message text for the parameter attribute.
        /// </summary>
        /// <param name="attr">The attribute to check for the help message.</param>
        /// <param name="assembly">The assembly to lookup resources messages, this should be the assembly the cmdlet is defined in.</param>
        /// <returns>The help message of the parameter or <c>null</c> if none is defined.></returns>
        private static string? GetParameterHelpMessage(
            ParameterAttribute attr,
            Assembly? assembly = null)
        {
            if (!string.IsNullOrWhiteSpace(attr.HelpMessage))
            {
                return attr.HelpMessage.Trim();
            }

            if (assembly is null || string.IsNullOrWhiteSpace(attr.HelpMessageBaseName) || string.IsNullOrWhiteSpace(attr.HelpMessageResourceId))
            {
                return null;
            }

            try
            {
                return ResourceManagerCache.GetResourceString(assembly, attr.HelpMessageBaseName, attr.HelpMessageResourceId)?.Trim();
            }
            catch (Exception)
            {
                return null;
            }
        }
#nullable disable

        /// <summary>

Review comment (suggestion):
Since it is new code I suggest to follow more strong contract - return only useful data, otherwise null.
As result calling code will check only for null.
It might even be more convenient to use `bool TryGetParameterHelpMessage()` pattern.

Code after:
            if (pattern.IsMatch(matchedParameterName))
            {
                string completionText = $"-{matchedParameterName}{colonSuffix}";
                string tooltip = $"{parameterType}{matchedParameterName}{helpMessage}";
                result.Add(new CompletionResult(completionText, matchedParameterName, CompletionResultType.ParameterName, tooltip));
            }
            else
            {
                // Process alias when there is partial input
                foreach (var alias in param.Parameter.Aliases)
                {
                    if (pattern.IsMatch(alias))
                    {
                        result.Add(new CompletionResult(
                            $"-{alias}{colonSuffix}",
                            alias,
                            CompletionResultType.ParameterName,
                            $"{parameterType}{alias}{helpMessage}"));
                    }
                }
            }

            return result;
        }

#nullable enable
        /// <summary>
        /// Try and get the help message text for the parameter attribute.
        /// </summary>
        /// <param name="attr">The attribute to check for the help message.</param>
        /// <param name="assembly">The assembly to lookup resources messages, this should be the assembly the cmdlet is defined in.</param>
        /// <param name="message">The help message if it was found otherwise null.</param>
        /// <returns>True if the help message was set or false if not.></returns>
        private static bool TryGetParameterHelpMessage(
            ParameterAttribute attr,
            Assembly? assembly,
            [NotNullWhen(true)] out string? message)
        {
            message = null;
            
            if (attr.HelpMessage is not null)
            {
                message = attr.HelpMessage;
                return true;
            }

            if (assembly is null || attr.HelpMessageBaseName is null || attr.HelpMessageResourceId is null)
            {
                return false;
            }