Skip to content

Commit

Permalink
Ensure HelpInfo.Category is consistently a string (PowerShell#18254)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveL-MSFT authored Nov 16, 2022
1 parent 65b353d commit 4f19c05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/System.Management.Automation/help/MamlClassHelpInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal MamlClassHelpInfo Copy()
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ internal MamlCommandHelpInfo Copy()
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;
}

Expand Down
10 changes: 10 additions & 0 deletions test/powershell/engine/Help/HelpSystem.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 4f19c05

Please sign in to comment.