Skip to content

When displaying method overloads, show optional parameters as such #13728

@mklement0

Description

@mklement0

Summary of the new feature/enhancement

As a user, when I inspect the overloads of a given .NET method, I want to know which parameters are optional, so I only pass arguments to them if actually needed.

Accessing a method without invoking it (via (...)) conveniently shows all its overloads (signatures), but currently doesn't indicate which parameters are optional:

Add-Type -NameSpace demo -Name Foo -MemberDefinition 'public static void Bar(string param, int optParam = -1) { }'
# Show the method signature.
[demo.Foo]::Bar

Current output - NO indication that optParam is optional):

OverloadDefinitions
-------------------
static void Bar(string param, int optParam)

Desired output - clear indication that optParam is optional, ideally also with its default value, if technically feasible:

OverloadDefinitions
-------------------
static void Bar(string param, int optParam = -1)

Note: The same representation should be used for Get-Member output, as originally proposed in #7373.
I suspect that the implementation is shared anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions