Title: Get-Help for dynamic function created from ScriptBlock does not work. · Issue #8234 · PowerShell/PowerShell · GitHub
Open Graph Title: Get-Help for dynamic function created from ScriptBlock does not work. · Issue #8234 · PowerShell/PowerShell
X Title: Get-Help for dynamic function created from ScriptBlock does not work. · Issue #8234 · PowerShell/PowerShell
Description: Reproducible on 6.1.0 and on master b525b1f Steps to reproduce $sb = { <# .SYNOPSIS Sample synopsis. #> process { } } $str = [String]$sb Set-Item -Path function:private:FunctionFromString -Value $str (Get-Help FunctionFromString).Synopsi...
Open Graph Description: Reproducible on 6.1.0 and on master b525b1f Steps to reproduce $sb = { <# .SYNOPSIS Sample synopsis. #> process { } } $str = [String]$sb Set-Item -Path function:private:FunctionFromString -Value $s...
X Description: Reproducible on 6.1.0 and on master b525b1f Steps to reproduce $sb = { <# .SYNOPSIS Sample synopsis. #> process { } } $str = [String]$sb Set-Item -Path function:private:FunctionFromString -Va...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/8234
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Get-Help for dynamic function created from ScriptBlock does not work.","articleBody":"Reproducible on 6.1.0 and on master b525b1f0bde65f0c59ccd9bbfe25d1459fcff1a3\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n$sb = {\r\n \u003c#\r\n .SYNOPSIS\r\n Sample synopsis.\r\n #\u003e \r\n process { }\r\n}\r\n$str = [String]$sb\r\n\r\nSet-Item -Path function:private:FunctionFromString -Value $str\r\n(Get-Help FunctionFromString).Synopsis\r\n\r\nSet-Item -Path function:private:FunctionFromScriptBlock -Value $sb\r\n(Get-Help FunctionFromScriptBlock).Synopsis\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\n```none\r\nSample synopsis.\r\n\r\nSample synopsis.\r\n```\r\n\r\nActual behavior\r\n---------------\r\n\r\n```none\r\nSample synopsis.\r\n\r\nFunctionFromScriptBlock\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable --\u003e\r\n\r\n```powershell\r\n\u003e $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 6.1.0\r\nPSEdition Core\r\nGitCommitId 6.1.0\r\nOS Microsoft Windows 10.0.17134\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n\r\nAnalysis\r\n----------------\r\nThe difference between these two cases can be observed in the following block of code:\r\nhttps://github.com/PowerShell/PowerShell/blob/b525b1f0bde65f0c59ccd9bbfe25d1459fcff1a3/src/System.Management.Automation/help/HelpCommentsParser.cs#L1145-L1164\r\n\r\n`[ScriptBlock]` cases are handled by the `else` statement where the `startTokenIndex` is being set to the position before script block itself. Changing `- 1` to `+ 1` in the line https://github.com/PowerShell/PowerShell/blob/b525b1f0bde65f0c59ccd9bbfe25d1459fcff1a3/src/System.Management.Automation/help/HelpCommentsParser.cs#L1157\r\nsolves the problem.\r\n\r\nMay I prepare a PR for this?","author":{"url":"https://github.com/hubuk","@type":"Person","name":"hubuk"},"datePublished":"2018-11-12T02:05:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/8234/PowerShell/issues/8234"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:75d82837-5cdf-ef46-2116-5d0a843f427d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C8E:EAC63:EE88A9:1553CF1:6A5A0ABF |
| html-safe-nonce | 324620a6b1469b820cfca16a0c068ca7f0cb8eae00aed19401ba3176b3914317 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzhFOkVBQzYzOkVFODhBOToxNTUzQ0YxOjZBNUEwQUJGIiwidmlzaXRvcl9pZCI6IjYxODYyMzQ2NzYwMzYzNzMxODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 547a5d78851e8db2a519cfcafdc922d880844ee8d7289b403461e9cc312658db |
| hovercard-subject-tag | issue:379593661 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/8234/issue_layout |
| twitter:image | https://opengraph.githubassets.com/36e48ba65afadb206ec7dfb129cc3aac07bf708c8220a440a2c9a25ee8a7205e/PowerShell/PowerShell/issues/8234 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/36e48ba65afadb206ec7dfb129cc3aac07bf708c8220a440a2c9a25ee8a7205e/PowerShell/PowerShell/issues/8234 |
| og:image:alt | Reproducible on 6.1.0 and on master b525b1f Steps to reproduce $sb = { <# .SYNOPSIS Sample synopsis. #> process { } } $str = [String]$sb Set-Item -Path function:private:FunctionFromString -Value $s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hubuk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8c2fe7351e4e987cb8f75e2425a0b895d807779bc4c2d3c312be0a54082219f7 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 491710c7a8eecca9d0a06bd157646f2685d8c87b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width