Replace "Dbg.Assert" with 'if () throw' in CSVCommands.cs.#6910
Replace "Dbg.Assert" with 'if () throw' in CSVCommands.cs.#6910iSazonov merged 3 commits intoPowerShell:masterfrom
Conversation
| @@ -331,6 +331,11 @@ private void CreateFileStream() | |||
| { | |||
| Dbg.Assert(_path != null, "FileName is mandatory parameter"); | |||
There was a problem hiding this comment.
I think we can remove the asserts now.
|
|
||
| if (_path == null) | ||
| { | ||
| throw new InvalidOperationException("FileName is mandatory parameter"); |
There was a problem hiding this comment.
Since the strings are now user visible, they need to be moved to a resx file. This applies to all the changes that now throw exceptions.
There was a problem hiding this comment.
Shall we localize the strings? In the case we should review all code base.
There was a problem hiding this comment.
@iSazonov I don't believe we localize assert strings because they are for debug only usage. Exception strings are handled like any other display string.
There was a problem hiding this comment.
@dantraMSFT In this case, I think there is no point in transferring these throw debug strings to the resource files.
There was a problem hiding this comment.
@iSazonov: I believe there is. We are effectively creating new strings that are displayed to the user. The fact that they were previously assert strings doesn't change that, IMHO.
There was a problem hiding this comment.
What about resx?
Should I move strings to CsvCommandStrings.resx?
There was a problem hiding this comment.
We just discuss this becouse of never do this previously.
There was a problem hiding this comment.
@iSazonov: There already is a guideline in docs\dev-process\coding-guidelines.
Resource strings used for errors or UI should be put in resource files (.resx) so that they can be localized later.
With few, ahem, exceptions, strings passed as the message to an exception are error strings and should be in the resx file. The fact that hit used to be a dbg.assert doesn't change this (IMHO).
As far as the string used in an Assert, I prefer to avoid them, especially when not backed up by code, They are a useful debugging aid though but I would not expect the strings to be localized.
|
@dantraMSFT Could you please update your review? |
PR Summary
As of discussion in #6816
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