PowerShell / PowerShell/PSScriptAnalyzer
Rule request: AvoidDefaultEncoding
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 414
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Descrizione
Apparently the default encoding -Encoding Default is removed from the cmdlet documentation that supports the -Encoding parameter. See e.g.:
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-content?view=powershell-5.1
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-content?view=powershell-7.5
Which makes sense in a way that this might cause compatibility issues when something is e.g. written (using -Encoding Default in Windows PowerShell 5.1 and read back in PowerShell 7 (e.g. after a PowerShell update migration). Yet, afaik, this isn't captured by any of the UseCompatibleCommands profiles either (probably because the default value is still accepted.
Also note:
- that using any of the newer encoding values as
Ansiandutf8NoBomin PowerShell 7 might cause an incompatibility issue with older versions of PowerShell. - the implementation of the
-Encoding utf8value also differs between Windows PowerShell and newer versions of PowerShell:- Character encoding in Windows PowerShell:
UTF8Uses UTF-8 (with BOM). - Character encoding in PowerShell:
utf8: Encodes in UTF-8 format (no BOM).
- Character encoding in Windows PowerShell:
Therefore I think that it is wise to avoid the default and utf8 encoding (-Encoding Default and -Encoding utf8) when PSUseCompatibleCommands is enabled in the PSScriptAnalyzer settings.
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 esaminando la regola PSUseCompatibleCommands e i relativi profili di compatibilità, quindi confronta la documentazione collegata sulla codifica di Windows PowerShell e PowerShell. Definisci le diagnosi previste per -Encoding Default e -Encoding utf8 quando l'analisi di compatibilità è abilitata, incluso come devono essere trattati i valori più recenti Ansi e utf8NoBom; l'issue è completata quando il comportamento della regola e la relativa copertura riflettono tale decisione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- powershell
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100