Skip to content

Add documentation for invoking generic methods with explicit type parameters #8533

Closed

Description

Prerequisites

  • Write a descriptive title.
  • Search the existing issues.

Summary of the new feature or changed behavior

Now that PowerShell/PowerShell#12412 was merged, we need to look at adding documentation around the syntax and some general use cases for calling generic methods where PowerShell can't infer the appropriate generic overload based on the argument types.

General syntax is:

# static generic methods
[type_name]::MethodName[generic_type_arguments](method_arguments)

# instance generic methods
$object.MethodName[generic_type_arguments](method_arguments)

# generic_type_arguments can be a a single type, or comma-separated list of types, like `[string, int]`, 
# including other generic types like `$obj.MethodName[string, System.Collections.Generic.Dictionary[string, int]]()`

I would expect some of the most common use cases for this would be in using heavily generic types like System.Collections.Concurrent.ConcurrentDictionary and static methods with generic arguments like those found in the System.Linq namespace.

Note that as illustrated in this comment that certain methods may still require type casting their arguments appropriately at the moment.

List of articles that need to be updated

Unsure which articles exactly at the moment.

Link to related PR in PowerShell/PowerShell repo

PowerShell/PowerShell#12412

Link to related Issues in PowerShell/PowerShell repo

PowerShell/PowerShell#5146

Activity

  1. added
    issue-doc-idea
    needs-triage
    on Jan 27, 2022
  2. added
    area-sdk-docs
    and removed
    needs-triage
    on Jan 27, 2022
  3. added a commit that references this issue on Feb 2, 2022
    ba325e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-sdk-docsissue-doc-idea

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions