Remove empty branch and add Dbg.Assert in ExportCsvHelper.#6816
Remove empty branch and add Dbg.Assert in ExportCsvHelper.#6816iSazonov merged 2 commits intoPowerShell:masterfrom
Conversation
dantraMSFT
left a comment
There was a problem hiding this comment.
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.
|
Fixed. |
|
@dantraMSFT Should we review all code base to replace Asserts? Ex., in the file I see same patterns. |
|
@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. |
|
@daxian-dbw @TravisEz13 Should we add @dantraMSFT's suggestion in our PR check list? |
|
@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. |
PR Summary
Remove empty branch and add Dbg.Assert in ExportCsvHelper.
Fix #6809
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests