Skip to content

Tab completion should find members for $_ in a typed catch block #17613

@SeeminglyScience

Description

@SeeminglyScience

Steps to reproduce

$script = 'try {
} catch [System.Net.Http.HttpResponseException] {
    $PSItem.
}'

$column = $script.IndexOf('.', $script.IndexOf('$')) + 1
(TabExpansion2 -inputScript $script -cursorColumn $column).CompletionMatches

Expected behavior

CompletionText        ListItemText          ResultType ToolTip
--------------        ------------          ---------- -------
CategoryInfo          CategoryInfo            Property System.Management.Automation.ErrorCategoryInfo CategoryInfo { get; }
ErrorDetails          ErrorDetails            Property System.Management.Automation.ErrorDetails ErrorDetails { get; set; }
Exception             Exception               Property System.Exception Exception { get; }
FullyQualifiedErrorId FullyQualifiedErrorId   Property string FullyQualifiedErrorId { get; }
InvocationInfo        InvocationInfo          Property System.Management.Automation.InvocationInfo InvocationInfo { get; }
PipelineIterationInfo PipelineIterationInfo   Property System.Collections.ObjectModel.ReadOnlyCollection[int] PipelineIterationInfo { get;…
PSMessageDetails      PSMessageDetails        Property System.Object PSMessageDetails {get=& { Set-StrictMode -Version 1; $this.Exception.…
ScriptStackTrace      ScriptStackTrace        Property string ScriptStackTrace { get; }
TargetObject          TargetObject            Property System.Object TargetObject { get; }
Equals(               Equals                    Method bool Equals(System.Object obj)
GetHashCode(          GetHashCode               Method int GetHashCode()
GetObjectData(        GetObjectData             Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runt…
GetType(              GetType                   Method type GetType()
ToString(             ToString                  Method string ToString()

Ideally $PSItem.Exception.<tab> would also infer members of the exception specified in the catch block.

Actual behavior

No results

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0-preview.5
PSEdition                      Core
GitCommitId                    7.3.0-preview.5
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions