PowerShell / PowerShell/PSScriptAnalyzer
Write-Host should be closed within the scope it was created in, unless it is a Async command type
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- C#
- Estrelas
- 2.2k
- Forks
- 415
- Merge médio
- 13h 1min
- PRs com merge (30d)
- 2
Descrição
Summary of the new feature
Some times people don't properly close their Write-progress calls with a -Completed which can cause unexpected output, or "leftover" progress bars from commands that completed, but never closed their progress bars
Proposed technical implementation details (optional)
Write-Progress automatically stops showing open progress bars when execution is complete, but this means that if you are making an interface that does not properly close their Write-Progress progress bars with a Write-Progress -Activity $ActivityName -Completed then it stays open while other code is running, until execution stops.
It seems like in vanilla shell console, powershell can recognize that it is "done" (I'm guessing.... maybe something like the scope that created the Write-Progress is stopped? )
But if you do this in other environments, like ISE, then the Progress bars don't go away unless properly closed with a -Completed
Additionally there is the case that people who are running with something like -PercentComplete 100 but never closing.
A recommendation to close Write-Progress'es with a -Completed would effectively stop this problem
Possibly make sure each write-progress -Activity has a matching one with -Completed ? Not sure if there is a way to detect if it's closed in the same scope or if that might cause more problems
A potential problem for that would be things like People start it in the begin { } block write over time in the progress { } block, but not closing in the end { } block?
What is the latest version of PSScriptAnalyzer at the point of writing
As far as I can tell, it does nothing for this currently
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece localizando as regras e os testes existentes do analisador para comandos do PowerShell; a issue menciona Write-Progress e chamadas -Completed correspondentes, mas não informa arquivos nem pontos de entrada. Esclareça como os limites de escopo e os blocos begin/process/end devem se comportar e, em seguida, defina testes que cubram tipos de comando comuns e assíncronos antes da implementação.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp, powershell
- Domínio
- tooling
- Tipo de issue
- Funcionalidade
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Status de atividade
- Estagnada
- Clareza
- Precisa de esclarecimento
- Facilidade para iniciantes
- 20/100