Skip to content

Remove empty branch and add Dbg.Assert in ExportCsvHelper. #6816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2018

Conversation

sethvs
Copy link
Contributor

@sethvs sethvs commented May 3, 2018

PR Summary

Remove empty branch and add Dbg.Assert in ExportCsvHelper.
Fix #6809

PR Checklist

Copy link
Contributor

@dantraMSFT dantraMSFT left a comment

Choose a reason for hiding this comment

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

Relying on Dbg.Assert for parameter checking is not a good practice because we don't run tests against Debug builds. I've encountered numerous bugs that relied on Assert for validation but had none in release/production builds.

In this case, the previous code was clearly incorrect but replacing it with a Dbg.Assert doesn't solve it.

I suggest, you make the assignment a condition of non-null or throw an ArgumentNullException when null.

@sethvs
Copy link
Contributor Author

sethvs commented May 4, 2018

Fixed.

@iSazonov
Copy link
Collaborator

iSazonov commented May 4, 2018

@dantraMSFT Should we review all code base to replace Asserts? Ex., in the file I see same patterns.

@dantraMSFT
Copy link
Contributor

@iSazonov: I would say yes. Assert is perfectly fine if it is used as a debugging aid as long as it has runtime code to back it up. At a minimum, it should be part of any PR review.

@iSazonov
Copy link
Collaborator

iSazonov commented May 5, 2018

@daxian-dbw @TravisEz13 Should we add @dantraMSFT's suggestion in our PR check list?

@TravisEz13
Copy link
Member

@iSazonov I think this comes to the level of something that should be documented guidance, but not something that should be in the checklist for every PR. If it should be verified for every PR, we should probably write a test to verify that this code is not in any changed code blocks.

@iSazonov iSazonov self-assigned this May 8, 2018
@iSazonov iSazonov merged commit d1b9aa7 into PowerShell:master May 8, 2018
@sethvs sethvs deleted the ExportCsvHelper branch May 21, 2018 16:24
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.

Do we need empty branch in Microsoft.PowerShell.Commands.ExportCsvHelper?
4 participants