{"action":"created","issue":{"url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/195","labels_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/195/labels{/name}","comments_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/195/comments","events_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/195/events","html_url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/195","id":79551579,"number":195,"title":"PSUseOutputTypeCorrectly generates false warning for PSObjects with custom ETS type names","user":{"login":"KirkMunro","id":3515485,"avatar_url":"https://avatars.githubusercontent.com/u/3515485?v=3","gravatar_id":"","url":"https://api.github.com/users/KirkMunro","html_url":"https://github.com/KirkMunro","followers_url":"https://api.github.com/users/KirkMunro/followers","following_url":"https://api.github.com/users/KirkMunro/following{/other_user}","gists_url":"https://api.github.com/users/KirkMunro/gists{/gist_id}","starred_url":"https://api.github.com/users/KirkMunro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KirkMunro/subscriptions","organizations_url":"https://api.github.com/users/KirkMunro/orgs","repos_url":"https://api.github.com/users/KirkMunro/repos","events_url":"https://api.github.com/users/KirkMunro/events{/privacy}","received_events_url":"https://api.github.com/users/KirkMunro/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-22T18:05:04Z","updated_at":"2015-05-22T20:32:11Z","closed_at":null,"body":"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.\r\n\r\nIn 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)."},"comment":{"url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/comments/104760574","html_url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/195#issuecomment-104760574","issue_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/195","id":104760574,"user":{"login":"KirkMunro","id":3515485,"avatar_url":"https://avatars.githubusercontent.com/u/3515485?v=3","gravatar_id":"","url":"https://api.github.com/users/KirkMunro","html_url":"https://github.com/KirkMunro","followers_url":"https://api.github.com/users/KirkMunro/followers","following_url":"https://api.github.com/users/KirkMunro/following{/other_user}","gists_url":"https://api.github.com/users/KirkMunro/gists{/gist_id}","starred_url":"https://api.github.com/users/KirkMunro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KirkMunro/subscriptions","organizations_url":"https://api.github.com/users/KirkMunro/orgs","repos_url":"https://api.github.com/users/KirkMunro/repos","events_url":"https://api.github.com/users/KirkMunro/events{/privacy}","received_events_url":"https://api.github.com/users/KirkMunro/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T20:32:11Z","updated_at":"2015-05-22T20:32:11Z","body":"I just found another scenario where this occurs.  I have a command that returns an array of PSObjects.  This warning indicates that my command returns an object of type System.Object[], but that type is not declared in the OutputType attribute.  My OutputType properly identifies the ETS type name here as well, as a single quoted string.  Please make sure this is addressed for collections as well."}}