Title: ProxyCommand breaks ValidateRange for enum-parameters · Issue #17546 · PowerShell/PowerShell · GitHub
Open Graph Title: ProxyCommand breaks ValidateRange for enum-parameters · Issue #17546 · PowerShell/PowerShell
X Title: ProxyCommand breaks ValidateRange for enum-parameters · Issue #17546 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/17546
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ProxyCommand breaks ValidateRange for enum-parameters","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\n```powershell\r\nfunction Test-EnumValidation {\r\n param(\r\n [ValidateSet([Microsoft.PowerShell.ExecutionPolicy]::Unrestricted, [Microsoft.PowerShell.ExecutionPolicy]::Undefined)]\r\n [Microsoft.PowerShell.ExecutionPolicy]$Works,\r\n\r\n [ValidateRange([Microsoft.PowerShell.ExecutionPolicy]::Unrestricted, [Microsoft.PowerShell.ExecutionPolicy]::Undefined)]\r\n [Microsoft.PowerShell.ExecutionPolicy]$Fails\r\n )\r\n}\r\n\r\n\r\n$m = New-Object System.Management.Automation.CommandMetaData (Get-Command Test-EnumValidation)\r\n$s = [System.Management.Automation.ProxyCommand]::Create($m)\r\n\r\n$function:proxy = [scriptblock]::Create($s)\r\n\r\n# fails with .ctor exception\r\nproxy\r\n\r\n# if we check the generated function, we see that `ValidateRange` got unquoted strings as arguments in the proxycommand\r\n$s\r\n\r\n...\r\nparam(\r\n [ValidateSet('Unrestricted','Undefined')]\r\n [Microsoft.PowerShell.ExecutionPolicy]\r\n ${Works},\r\n\r\n [ValidateRange(Unrestricted,Undefined)]\r\n [Microsoft.PowerShell.ExecutionPolicy]\r\n ${Fails})\r\n....\r\n```\r\n\r\n### Expected behavior\r\n\r\n`proxy` should work without errors\r\n\r\n\r\n### Actual behavior\r\n\r\n`proxy` throws MethodException due to missing overload.\r\n\r\n\r\n### Error details\r\n\r\n```powershell\r\nException :\r\n Type : System.Management.Automation.MethodException\r\n ErrorRecord :\r\n Exception :\r\n Type : System.Management.Automation.ParentContainsErrorRecordException\r\n Message : Cannot find an overload for \".ctor\" and the argument count: \"0\".\r\n HResult : -2146233087\r\n CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException\r\n FullyQualifiedErrorId : MethodCountCouldNotFindBest\r\n InvocationInfo :\r\n ScriptLineNumber : 7\r\n OffsetInLine : 5\r\n HistoryId : -1\r\n Line : [ValidateRange(Unrestricted, Undefined)]\r\n\r\n PositionMessage : At line:7 char:5\r\n + [ValidateRange(Unrestricted, Undefined)]\r\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n CommandOrigin : Internal\r\n ScriptStackTrace : at \u003cScriptBlock\u003e, \u003cNo file\u003e: line 1\r\n TargetSite :\r\n Name : GetAttribute\r\n DeclaringType : System.Management.Automation.Language.Compiler, System.Management.Automation, Version=7.2.4.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35\r\n MemberType : Method\r\n Module : System.Management.Automation.dll\r\n Message : Cannot find an overload for \".ctor\" and the argument count: \"0\".\r\n Data : System.Collections.ListDictionaryInternal\r\n Source : System.Management.Automation\r\n HResult : -2146233087\r\n StackTrace :\r\n at System.Management.Automation.Language.Compiler.GetAttribute(AttributeAst attributeAst)\r\n at System.Management.Automation.Language.AttributeAst.GetAttribute()\r\n at System.Management.Automation.Language.Compiler.GetRuntimeDefinedParameter(ParameterAst parameterAst, Boolean\u0026 customParameterSet, Boolean\u0026 usesCmdletBinding)\r\n at System.Management.Automation.Language.Compiler.GetParameterMetaData(ReadOnlyCollection`1 parameters, Boolean automaticPositions, Boolean\u0026 usesCmdletBinding)\r\n at System.Management.Automation.Language.ScriptBlockAst.System.Management.Automation.Language.IParameterMetadataProvider.GetParameterMetadata(Boolean automaticPositions, Boolean\u0026 usesCmdletBinding)\r\n at System.Management.Automation.CompiledScriptBlockData.InitializeMetadata()\r\n at System.Management.Automation.CompiledScriptBlockData.get_ObsoleteAttribute()\r\n at System.Management.Automation.DlrScriptCommandProcessor.Init()\r\n at System.Management.Automation.CommandDiscovery.CreateCommandProcessorForScript(FunctionInfo functionInfo, ExecutionContext context, Boolean useNewScope, SessionStateInternal sessionState)\r\n at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(CommandInfo commandInfo, CommandOrigin commandOrigin, Nullable`1 useLocalScope, SessionStateInternal sessionState)\r\n at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)\r\n at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionCont\r\next context)\r\n at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandR\r\nedirections, FunctionContext funcContext)\r\n at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)\r\n at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)\r\nCategoryInfo : NotSpecified: (:) [], MethodException\r\nFullyQualifiedErrorId : MethodCountCouldNotFindBest\r\nInvocationInfo :\r\n ScriptLineNumber : 7\r\n OffsetInLine : 5\r\n HistoryId : -1\r\n Line : [ValidateRange(Unrestricted, Undefined)]\r\n\r\n PositionMessage : At line:7 char:5\r\n + [ValidateRange(Unrestricted, Undefined)]\r\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n CommandOrigin : Internal\r\nScriptStackTrace : at \u003cScriptBlock\u003e, \u003cNo file\u003e: line 1\r\n```\r\n\r\n\r\n### Environment data\r\n\r\n```powershell\r\nName Value\r\n---- -----\r\nPSVersion 7.2.4\r\nPSEdition Core\r\nGitCommitId 7.2.4\r\nOS Microsoft Windows 10.0.22000\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\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/fflaten","@type":"Person","name":"fflaten"},"datePublished":"2022-06-20T22:23:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/17546/PowerShell/issues/17546"}
| 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:e74a4950-8611-c7b2-741c-100246546937 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CDD2:29681E:3870501:4DF28E7:6A54BFD3 |
| html-safe-nonce | 7480775b86e7054746883ca06ef8136e6ee76cc2a567328cf3f5f217df3f306b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDREQyOjI5NjgxRTozODcwNTAxOjRERjI4RTc6NkE1NEJGRDMiLCJ2aXNpdG9yX2lkIjoiNTU4NDc1MDEzODU5NjA0ODg1MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c498fac0ba8be2ff6b6dc38c624b224adbcf5f016e14eaec793c3e34e391d480 |
| hovercard-subject-tag | issue:1277436674 |
| 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/17546/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bf837603c800c559292a673f95be3bd25c5397751549b0ea2d1ea8e527e6f609/PowerShell/PowerShell/issues/17546 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bf837603c800c559292a673f95be3bd25c5397751549b0ea2d1ea8e527e6f609/PowerShell/PowerShell/issues/17546 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fflaten |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 69f9664dd5e7a82ba8ab1b4cb7f5a2f09333ab38 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width