AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
325 stars 131 forks source link

Types not accessible #432

Closed agowa closed 3 years ago

agowa commented 3 years ago

Description

Types cannot be accessed after the module is imported.

Steps To Reproduce

  1. Import-Module -Name JiraPS
  2. Get-JiraFilter -Id 1 | Get-Member <= Look at TypeName. There is clearly a distinct type defined for objects in this module.
  3. [JiraPS.Filter]$myFilter = Get-JiraFilter -Id 1 <= But they cannot be accessed for type safe assignments.
  4. See error

Expected behavior

The types being exported into the current session upon module import, so that they can be used in the usual way. E.g. For type safe assignments.

Your Environment

Name   Version
----   -------
JiraPS 2.14.6

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.21337
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Possible Solution

lipkau commented 3 years ago

JiraPS v1. and v2. use a method of injecting a new string into the TypeNames of an PSCustomObject. This is done so that the default format for printing to the console can be manipulated. It does not create any kind of type which you can use in the way you described about

$result.PSObject.TypeNames.Insert(0, 'JiraPS.Field')

This will be changed in JiraPS v3. Current state can be seen here: https://github.com/lipkau/JiraPS/tree/feature/ProperUserHandling