Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions src/System.Management.Automation/engine/PSClassSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ private PSClassInfo ConvertToClassInfo(PSModuleInfo module, ScriptBlockAst ast,

foreach (var member in statement.Members)
{
PropertyMemberAst propAst = member as PropertyMemberAst;
if (propAst != null)
if (member is PropertyMemberAst propAst && !propAst.PropertyAttributes.HasFlag(PropertyAttributes.Hidden))
{
Dbg.Assert(propAst.Name != null, "PropName cannot be null");
Dbg.Assert(propAst.PropertyType != null, "PropertyType cannot be null");
Expand Down
24 changes: 24 additions & 0 deletions test/powershell/engine/Help/HelpSystem.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ Describe "Get-Help should find pattern help files" -Tags "CI" {
Remove-Item $helpFilePath2 -Force -ErrorAction SilentlyContinue
}

BeforeEach {
$currentPSModulePath = $env:PSModulePath
}

AfterEach {
$env:PSModulePath = $currentPSModulePath
}

$testcases = @(
@{command = {Get-Help about_testCas?1}; testname = "test ? pattern"; result = "about_test1"}
@{command = {Get-Help about_testCase.?}; testname = "test ? pattern with dot"; result = "about_test2"}
Expand All @@ -309,6 +317,22 @@ Describe "Get-Help should find pattern help files" -Tags "CI" {
)
$command.Invoke() | Should -Be $result
}

It "Get-Help should fail expectedly searching for class help with hidden members" {
$testModule = @'
class foo
{
hidden static $monthNames = @('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun','Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
}
'@
$modulesFolder = Join-Path $TestDrive "Modules"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use -AdditionalChildPath instead of two Join-Path

Copy link
Member Author

Choose a reason for hiding this comment

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

$modulesFolder and $modulePath are used independently

$modulePath = Join-Path $modulesFolder "TestModule"
New-Item -ItemType Directory -Path $modulePath -Force > $null
Set-Content -Path (Join-Path $modulePath "TestModule.psm1") -Value $testModule
$env:PSModulePath += [System.IO.Path]::PathSeparator + $modulesFolder

{ Get-Help -Category Class -Name foo -ErrorAction Stop } | Should -Throw -ErrorId "HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand"
}
}

Describe "Get-Help should find pattern alias" -Tags "CI" {
Expand Down