8000 Refactor Test-Connection by vexx32 · Pull Request #10044 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@vexx32
Copy link
Collaborator
@vexx32 vexx32 commented Jul 1, 2019

PR Summary

Refactor the Test-Connection cmdlet according to PowerShell/PowerShell-RFC#172

PR Context

Resolves #6768

NOTE: Currently this changes the pattern from Ping.Send() to Ping.SendAsync() with a manual event handler. This is due to a bug that was only recently resolved (see https://github.com/dotnet/corefx/issues/38770#issuecomment-507788270)

We can return to the simpler Ping.Send() pattern once we hit .NET Core 3-preview8 per the comment in that issue. 🙂

TODO:

  • Cleanup verbose messages
  • Add tests

Additional suggestions:

PR Checklist

vexx32 added 30 commits July 1, 2019 18:50
Simplify some variable declarations, fix up some uber long lines, etc.
& some misc cleanup.
Implementing IDisposable allows us to put the Ping() instances used
everywhere into a single field and dispose it whenever the command is.
Kinda in the name aight?
Copy link
Collaborator
@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vexx32 Please move all style changes in 1,2,3 new simple PRs.

Also I think it makes no sense create a workaround with async if we get Core Preview8 soon.

{ Test-Connection $targetName -BufferSize 0 } | Should Not Throw
{ Test-Connection $targetName -BufferSize -1 } | Should -Throw -ErrorId "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.TestConnectionCommand"
{ Test-Connection $targetName -BufferSize 65501 } | Should -Throw -ErrorId "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.TestConnectionCommand"
{ Test-Connection $targetName -BufferSize 0 } | Should -Not Throw
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ Test-Connection $targetName -BufferSize 0 } | Should -Not Throw
{ Test-Connection $targetName -BufferSize 0 } | Should -Not -Throw

@vexx32
Copy link
Collaborator Author
vexx32 commented Jul 3, 2019

Not sure it even makes sense to split style changes to be honest as this changes / rewrites a heck of a lot that I would cover in a style PR anyway.

We're still blocked on preview6 so I'm leaving the temp fix in for now so we can trust test results. When we get preview8 it isn't difficult to switch the pattern back.

@iSazonov
Copy link
Collaborator
iSazonov commented Jul 3, 2019

Have pity!😭 We have open about 50 PRs...

@vexx32
Copy link
Collaborator Author
vexx32 commented Jul 3, 2019

I know. But is one of these better, or four for the same thing? 😕

If you'd really rather extra style PRs I can probably look to trim some of that out, but in a lot of ways the style changes are kind of tied into the rest of the changes. Let me know what you'd prefer! 😊

@iSazonov
Copy link
Collaborator
iSazonov commented Jul 3, 2019

@vexx32 You will spend some time for temporary PRs but save a lot of time of reviewers.
It's incredible that someone can view more than 400-500 changes at a time.
After PR exeeds 100 changes, any style change significantly slows down the code review and begins to annoy.
While the PR draft you could make temporary PRs. I see many renames.
Also you could split functional changes too, ex. separate ping, traceroute and etc. to different PRs.
As for async, we get Preview7 in 5 weeks. I suppose we have nowhere to hurry.

@vexx32
Copy link
Collaborator Author
vexx32 commented Jul 3, 2019

Yeah, I guess that makes sense.

I'll look to do a style pass and see how I can split it out from there. Thanks! 💖
I may keep working in here till I see what I mucked up in the tests but as soon as I have this sorted I'll start splitting. 🙂

Bug with native exceptions was fixed in .NET Core 3-preview7
Should be safe to use synchronous ping.
@vexx32
Copy link
Collaborator Author
vexx32 commented Oct 4, 2019

Closing this as this has been superceded by #10697

@vexx32 vexx32 closed this Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test-Connection cmdlet displaying unwanted data.

3 participants

0