PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
494 stars 94 forks source link

Add Class key to Includes hashtable #89

Open juneb opened 7 years ago

juneb commented 7 years ago

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                         {}
bmanikm commented 7 years ago

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

juneb commented 7 years ago

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.

bmanikm commented 7 years ago

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

juneb commented 7 years ago

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
ThomasNieto commented 5 years ago

@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.