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
4 changes: 2 additions & 2 deletions src/System.Management.Automation/help/HelpCommentsParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,10 +1154,10 @@ private static List<string> GetParameterComments(Language.Token[] tokens, IParam
// $sb = { }
// set-item function:foo $sb
// help foo
startTokenIndex = savedStartIndex = FirstTokenInExtent(tokens, ast.Extent) - 1;
startTokenIndex = savedStartIndex = FirstTokenInExtent(tokens, ast.Extent) + 1;
lastTokenIndex = LastTokenInExtent(tokens, ast.Extent, startTokenIndex);

Diagnostics.Assert(tokens[startTokenIndex + 1].Kind == TokenKind.LCurly,
Diagnostics.Assert(tokens[startTokenIndex - 1].Kind == TokenKind.LCurly,
"Unexpected first token in script block");
Diagnostics.Assert(tokens[lastTokenIndex].Kind == TokenKind.RCurly,
"Unexpected last token in script block");
Expand Down
56 changes: 56 additions & 0 deletions test/powershell/Language/Scripting/ScriptHelp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,69 @@ Describe 'get-help HelpFunc1' -Tags "Feature" {
# Useless
#
function helpFunc1 {}

Set-Item function:dynamicHelpFunc1 -Value {
# .SYNOPSIS
#
# A relatively useless function.
#
# .DESCRIPTION
#
# A description
#
# with indented text and a blank line.
#
# .NOTES
#
# This function is mostly harmless.
#
# .LINK
#
# http://blogs.msdn.com/powershell
#
# .LINK
#
# other commands
#
# .EXAMPLE
#
# If you need an example, you're hopeless.
#
# .INPUTS
#
# Anything you like.
#
# .OUTPUTS
#
# Nothing.
#
# .COMPONENT
#
# Something
#
# .ROLE
#
# CrazyUser
#
# .FUNCTIONALITY
#
# Useless
#

process { }
}
}

Context 'Get-Help helpFunc1' {
$x = get-help helpFunc1
TestHelpFunc1 $x
}

Context 'Get-Help dynamicHelpFunc1' {
$x = get-help dynamicHelpFunc1
TestHelpFunc1 $x
}

Context 'get-help helpFunc1 -component blah' {
$x = get-help helpFunc1 -component blah -ErrorAction SilentlyContinue -ErrorVariable e
TestHelpError $x $e 'HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand'
Expand Down