PowerShell / PowerShell/PSScriptAnalyzer
PSUseOutputTypeCorrectly complains "... type is not declared in the OutputType attribute" even though it is
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 414
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Descrizione
Steps to reproduce
PSScriptAnalyzer is complaining about a missing OutputType attribute, even though I did set it correctly.
See PSScriptAnalyzer CI comment under my commits: https://github.com/jantari/LSUClient/commit/a6c2fcc1622aa221d0be73debb4a97baea7b36b5
Easiest way to reproduce is test with my exact file:
mkdir test-pssa
curl.exe "https://raw.githubusercontent.com/jantari/LSUClient/develop/public/Install-LSUpdate.ps1" -o .\test-pssa\Install-LSUpdate.ps1
Import-Module PSScriptAnalyzer -RequiredVersion 1.20.0 # Latest
Invoke-ScriptAnalyzer -Path .\test-pssa -ExcludeRule PSAvoidTrailingWhitespace -Recurse -Verbose
Expected behavior
PSScriptAnalyzer should have no complaints.
Actual behavior
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSUseOutputTypeCorrectly Information Install-LS 93 The cmdlet 'Install-LSUpdate' returns an object of type
Update.ps1 'PackageInstallResult' but this type is not declared in the
OutputType attribute.
PSUseOutputTypeCorrectly Information Install-LS 125 The cmdlet 'Install-LSUpdate' returns an object of type
Update.ps1 'PackageInstallResult' but this type is not declared in the
OutputType attribute.
Environment data
Issue is reproducible under both:
> $PSVersionTable
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.22538
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.20.0
1.19.1
and:
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.22538.1000
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22538.1000
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.0
1.20.0
1.19.1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo il report con Install-LSUpdate.ps1 dalla riproduzione collegata e con Invoke-ScriptAnalyzer usando PSScriptAnalyzer 1.20.0. Esamina la regola PSUseOutputTypeCorrectly e confronta il relativo output PackageInstallResult dedotto con l’OutputType dichiarato; il lavoro è completato quando i diagnostici di falso positivo alle righe 93 e 125 non compaiono più, mentre gli avvisi validi continuano a essere rilevati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- powershell
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 35/100