You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have many functions that generate PSObjects. Whenever I create a PSObject, I add a type name to it. This is done either by invoking .PSTypeNames.Add(...), .PSTypeNames.Insert(...), or if I'm creating the object using [pscustomobject]@{...} then I just apply a PSTypeName value to the hashtable with the custom name for the object I am creating.
In scenarios like these, PSUseOutputTypeCorrectly identifies that I'm returning a PSObject and then complains because my OutputType is a string, set to the actual PSTypeName of the object that is returned. I'm following the best practice, but PSScriptAnalyzer is incorrectly assuming I'm doing the wrong thing. The PSUseOutputTypeCorrectly rule should not generate a warning on functions that return PSObjects when the OutputType is set to a string (the ETS type name for those PSObjects).