Skip to content

Random ValueFromPipelineByValue error in PSIC while editing script #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rkeithhill opened this issue May 23, 2017 · 3 comments
Closed
Labels
Issue-Bug A bug to squash.
Milestone

Comments

@rkeithhill
Copy link
Contributor

VSCode 1.12.2, Ext: 1.1.0, Windows 10 CU.

Here is the error that showed up in the PSIC:

Caught error while waiting for EditorServicesHost to complete:
One or more errors occurred.
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.WaitForExit()
   at CallSite.Target(Closure , CallSite , Object )
One or more errors occurred.

Property 'ValueFromPipelineByValue' cannot be found for type 'System.Management.Automation.CmdletBindingAttribute'.
   at System.Management.Automation.Language.Compiler.NewParameterAttribute(AttributeAst ast)
   at System.Management.Automation.Language.Compiler.GetAttribute(AttributeAst attributeAst)
   at System.Management.Automation.Language.Compiler.GetRuntimeDefinedParameter(ParameterAst parameterAst, Boolean& customParameterSet, Boolean& usesCmdletBinding)
   at System.Management.Automation.Language.Compiler.GetParameterMetaData(ReadOnlyCollection`1 parameters, Boolean automaticPositions, Boolean& usesCmdletBinding)
   at System.Management.Automation.CompiledScriptBlockData.InitializeMetadata()
   at System.Management.Automation.CompiledScriptBlockData.get_CmdletBindingAttribute()
   at System.Management.Automation.CommandMetadata..ctor(ScriptBlock scriptblock, String commandName, ExecutionContext context)
   at System.Management.Automation.FunctionInfo.get_CommandMetadata()
   at System.Management.Automation.CommandInfo.GenerateCommandParameterSetInfo()
   at System.Management.Automation.CommandInfo.get_ParameterSets()
   at Microsoft.PowerShell.EditorServices.LanguageService.<FindParameterSetsInFile>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.<HandleSignatureHelpRequest>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<ListenForMessages>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc)
   at System.Threading.Tasks.Task.Execute()

1495579816-646549eb-cb5a-4a84-9336-af14a96c21161495495298087.zip

@daviwil
Copy link
Contributor

daviwil commented May 23, 2017

Hmmm, weird, haven't seen that before. Should be easy to fix though.

@daviwil daviwil added this to the 1.2.0 milestone May 23, 2017
@daviwil daviwil added the Issue-Bug A bug to squash. label May 23, 2017
@rkeithhill
Copy link
Contributor Author

This is a bug in my script but it probably shouldn't have caused the above exception. Here's the bad script:

    param(
        [Parameter(Mandatory, Position = 0, ValueFromPipelineByValue)]
        [ValidateNotNull()]
        [DomainModel.LicenseService.LicenseHost[]]
        $LicenseHost
    )

ValueFromPipelineByValue is not a valid property.

@daviwil
Copy link
Contributor

daviwil commented May 23, 2017

Cool, that's helpful!

daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue May 30, 2017
This change catches a RuntimeException that may occur when the user
types out the name of a command or script which uses an invalid
parameter binding attribute.  This exception will be logged and the
signatures just won't be displayed for that command.

Resolves PowerShell#462.
daviwil added a commit that referenced this issue May 30, 2017
This change catches a RuntimeException that may occur when the user
types out the name of a command or script which uses an invalid
parameter binding attribute.  This exception will be logged and the
signatures just won't be displayed for that command.

Resolves #462.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

2 participants