Skip to content

Add Class key to Includes hashtable #89

Description

@juneb

The PSRepositoryInfo object has an Includes hashtable with keys for the types of commands and resources in a module.

Please add a Class key for classes defined in the root module or ScriptsToProcess script that can be exported into the user's session.

Name                           Value
----                           -----
Function                       {}
RoleCapability                 {}
Command                        {}
DscResource                    {}
Workflow                       {}
Cmdlet                         {}

Activity

  1. bmanikm commented on Jan 6, 2017

    @bmanikm

    June Blender (@juneb) PowerShellGet needs to work on PS 3.0 or newer. Classes feature got added in PS 5.0.

  2. juneb commented on Jan 6, 2017

    @juneb
    Author

    If there are no classes defined in the script or module, the Classes value would be null. This shouldn't create any problems for older versions of PowerShell.

  3. bmanikm commented on Jan 6, 2017

    @bmanikm

    June Blender (@juneb) Could you please update the issue with more details as mentioned in the issue template?

  4. juneb commented on Jan 6, 2017

    @juneb
    Author

    Sure. It's a feature request, not a bug. :)

    Expected Behavior
    If a module or script defines PowerShell classes, I would like them to be discoverable before installing or importing the module, such as in the Includes hash table in the PSRepositoryInfo object. Currently, the Includes hash table has keys for functions and DSCResources, but not for classes.

    Current Behavior

    PS C:\ps-test> (Find-Module PoshRsJob -RequiredVersion 1.7.0.0).Includes
    
    Name                           Value
    ----                           -----
    Function                       {Get-RSJob, Receive-RSJob, Remove-RSJob, Start-RSJob...}
    RoleCapability                 {}
    Command                        {Get-RSJob, Receive-RSJob, Remove-RSJob, Start-RSJob...}
    DscResource                    {}
    Workflow                       {}
    Cmdlet                         {}
    

    Possible Solution
    Add a Class key to the Includes hash table:

    PS C:\ps-test> (Find-Module PoshRsJob -RequiredVersion 1.7.0.0).Includes
    
    Name                           Value
    ----                           -----
    Function                       {Get-RSJob, Receive-RSJob, Remove-RSJob, Start-RSJob...}
    RoleCapability                 {}
    Command                        {Get-RSJob, Receive-RSJob, Remove-RSJob, Start-RSJob...}
    DscResource                    {}
    Workflow                       {}
    Cmdlet                         {}
    Class                          {V2UsingVariable, RSRunspacePool, RSJob}
    

    Environment:

    PS C:\Program Files\PowerShell\6.0.0.14> $psversiontable
    
    Name                           Value
    ----                           -----
    PSRemotingProtocolVersion      2.3
    PSVersion                      6.0.0-alpha
    GitCommitId                    v6.0.0-alpha.14
    BuildVersion                   3.0.0.0
    CLRVersion
    SerializationVersion           1.1.0.1
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    PSEdition                      Core
    WSManStackVersion              3.0
    
  5. ThomasNieto commented on May 30, 2019

    @ThomasNieto
    Contributor

    June Blender (@juneb) I'd like to take a stab at implementing this but am running into some roadblocks with the multiple ways a class can be defined. I found your article about finding classes in modules but it seems to have some limitations. Do you know how to get the list of exported classes when it's defined in ScriptsToProcess or NestedModules? If not we may need to wait until PowerShell/PowerShell#6293 is complete.

  6. added this to the vNext milestone on Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions