Ensure HelpInfo.Category is consistently a string (#18254)

This commit is contained in:
Steve Lee
2022-11-15 17:57:03 -08:00
committed by GitHub
parent 65b353d9cf
commit 4f19c05547
3 changed files with 12 additions and 2 deletions
@@ -86,7 +86,7 @@ namespace System.Management.Automation
internal MamlClassHelpInfo Copy(HelpCategory newCategoryToUse)
{
MamlClassHelpInfo result = new MamlClassHelpInfo(_fullHelpObject.Copy(), newCategoryToUse);
result.FullHelp.Properties["Category"].Value = newCategoryToUse;
result.FullHelp.Properties["Category"].Value = newCategoryToUse.ToString();
return result;
}
@@ -441,7 +441,7 @@ namespace System.Management.Automation
internal MamlCommandHelpInfo Copy(HelpCategory newCategoryToUse)
{
MamlCommandHelpInfo result = new MamlCommandHelpInfo(_fullHelpObject.Copy(), newCategoryToUse);
result.FullHelp.Properties["Category"].Value = newCategoryToUse;
result.FullHelp.Properties["Category"].Value = newCategoryToUse.ToString();
return result;
}
@@ -45,6 +45,16 @@ function GetCurrentUserHelpRoot {
return $userHelpRoot
}
Describe 'Validate HelpInfo type' -Tags @('CI') {
It 'Category should be a string' {
$help = Get-Help *
$category = $help | ForEach-Object { $_.Category.GetType().FullName } | Select-Object -Unique
$category.Count | Should -Be 1 -Because 'All help categories should be strings, >1 indicates a type mismatch'
$category | Should -BeExactly 'System.String'
}
}
Describe "Validate that <pshome>/<culture>/default.help.txt is present" -Tags @('CI') {
It "Get-Help returns information about the help system" {