Skip to content

Attribute may silently crash #3769

@iSazonov

Description

@iSazonov

Steps to reproduce

function Test-BadAttribute
{
    [CmdletBinding()]
    Param
    (
        # Param1 help description
        [Parameter]
        [ValidateSet("a","b")]
        $Param1,

        [Parameter]
        [ValidateSet()] # Bad attribute - the constructor is failed
        $Param2
    )

    Begin
    {
    }
    Process
    {
    }
    End
    {
    }
}

1. Test-BadAttribute -Param1 <Press Tab>
2. Test-BadAttribute -Param1 <Press Enter>
3. Test-BadAttribute -Param1 "a" <Press Enter>

Expected behavior

  1. IntelliSenese work for Param1 and don't work for Param2 with error message
    or IntelliSenese don't work for both parameters with appropriate error message.
  2. Show appropriate error message.
  3. Cmdlet work well or don't work with showing appropriate error message.

Actual behavior

  1. No exception. No error message. IntelliSense don't work.
  2. Murky error message: it is impossible to understand that there is a problem with any attribute, which is the attribute and which is the parameter.
  3. The same as 2. and the cmdlet don't work.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
BuildVersion                   3.0.0.0
CLRVersion
GitCommitId                    v6.0.0-beta.1-7-g7fa53aedb3c7514cf1c2a19af6c26566661596d9-dirty
OS                             Microsoft Windows 10.0.10240
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    First-Time-IssueEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimeWG-Interactive-IntelliSensetab completion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions