Skip to content

Conversation

@xtqqczze
Copy link
Contributor

@xtqqczze xtqqczze commented Jul 2, 2020

PR Summary

  • "paramName" -> nameof(paramName)
  • Fix paramName typos/casing/name issues

Previously this PR had more changes, but they were removed for a future follow-up PR.

PR Context

Follow-up: #12716

PR Checklist

@ghost ghost assigned TravisEz13 Jul 2, 2020
@xtqqczze xtqqczze force-pushed the use-nameof-operator2 branch 3 times, most recently from 5505fac to 8695fba Compare July 2, 2020 19:57
@iSazonov
Copy link
Collaborator

iSazonov commented Jul 3, 2020

@xtqqczze Microsoft.Management.UI.Internal is a frozen code. Please exclude it from the PR.

@xtqqczze
Copy link
Contributor Author

xtqqczze commented Jul 5, 2020

@iSazonov Code cleanup changes have previously been merged to Microsoft.Management.UI.Internal (#12917), why must these changes be excluded?

@iSazonov
Copy link
Collaborator

iSazonov commented Jul 6, 2020

This code should not be changed. It will not develop, it is not tested.

@xtqqczze xtqqczze force-pushed the use-nameof-operator2 branch from 8695fba to 361ddb6 Compare July 6, 2020 17:49
@xtqqczze
Copy link
Contributor Author

xtqqczze commented Jul 6, 2020

@iSazonov Rebased to remove changes to Microsoft.Management.UI.Internal.

@xtqqczze xtqqczze force-pushed the use-nameof-operator2 branch from d8d1a73 to 7c6efc9 Compare July 6, 2020 21:07

if (fed.formatEntryInfo == null)
{
PSTraceSource.NewArgumentNullException("fed.formatEntryInfo");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder why do we change this? Please revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should not use ArgumentNullException here as the argument is not null but a property.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Intention is to trace. We shouldn't remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder why we do not throw the exception from NewArgumentNullException here. I think this could be a bug.


if (string.IsNullOrEmpty(Value))
if (Value == null || ValueType == DisplayEntryValueType.Property)
throw PSTraceSource.NewArgumentNullException(nameof(expression));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder why do we change this? Please revert.

Copy link
Contributor Author

@xtqqczze xtqqczze Aug 3, 2020

Choose a reason for hiding this comment

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

We should not use ArgumentNullException here as the argument expression may not be null.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Intention is to trace. We shouldn't remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Documentation for ArgumentNullException states:

An ArgumentNullException exception is thrown when a method is invoked and at least one of the passed arguments is null but should never be null.

The passed argument expression may not be null when we throw here so ArgumentNullException is not appropriate.

ActionPreference preference = pair.Value;
if (errorRecord == null)
{
throw PSTraceSource.NewArgumentNullException("errorRecord");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not NewArgumentNullException(nameof(errorRecord))?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Method signature is DoWriteError(object obj), errorRecord is not an argument.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Intention is to trace. We shouldn't remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should not pass "errorRecord" as paramName as it is not an argument for this method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The question is not for the style PR.

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Jul 11, 2020
@ghost ghost added the Stale label Jul 26, 2020
@ghost
Copy link

ghost commented Jul 26, 2020

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment.

@iSazonov
Copy link
Collaborator

@xtqqczze Please address last comments.

@ghost ghost removed the Stale label Jul 27, 2020
@ghost ghost removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept Stale labels Aug 3, 2020
@xtqqczze
Copy link
Contributor Author

xtqqczze commented Aug 3, 2020

@iSazonov Addressed

@TravisEz13 TravisEz13 assigned daxian-dbw and unassigned TravisEz13 Aug 11, 2020
@ghost ghost added the Review - Needed The PR is being reviewed label Aug 19, 2020
@ghost
Copy link

ghost commented Aug 19, 2020

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@daxian-dbw daxian-dbw added the Review - Maintainer The PR/issue needs a review from the PowerShell repo Maintainers label Aug 19, 2020
@daxian-dbw
Copy link
Member

@PowerShell/powershell-maintainers reviewed this PR and agreed to accept it.

@ghost ghost removed the Review - Needed The PR is being reviewed label Sep 1, 2020
@daxian-dbw daxian-dbw removed the Review - Maintainer The PR/issue needs a review from the PowerShell repo Maintainers label Sep 1, 2020
@ghost ghost added the Review - Needed The PR is being reviewed label Sep 9, 2020
@ghost
Copy link

ghost commented Sep 9, 2020

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

Copy link
Member

@TravisEz13 TravisEz13 left a comment

Choose a reason for hiding this comment

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

Let's start with a PR where all the names end up the change and no types are changed. There is too much too review here.

Comment on lines +1221 to +1236
/// <param name="str"></param>
/// <param name="offset"></param>
/// <returns></returns>
/// <exception cref="HostException">
/// If Win32's WideCharToMultiByte fails
/// </exception>

public override
int LengthInBufferCells(string s, int offset)
int LengthInBufferCells(string str, int offset)
{
if (s == null)
if (str == null)
{
throw PSTraceSource.NewArgumentNullException("str");
throw PSTraceSource.NewArgumentNullException(nameof(str));
}

return ConsoleControl.LengthInBufferCells(s, offset, parent.SupportsVirtualTerminal);
return ConsoleControl.LengthInBufferCells(str, offset, parent.SupportsVirtualTerminal);
Copy link
Member

Choose a reason for hiding this comment

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

Please try to keep different changes in different PRs

if (fed.formatEntryInfo == null)
{
PSTraceSource.NewArgumentNullException("fed.formatEntryInfo");
PSTraceSource.NewArgumentException(nameof(fed), "fed.formatEntryInfo is null");
Copy link
Member

Choose a reason for hiding this comment

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

Please move any changes which change an exception type to a new PR

{
#if CORECLR
throw PSTraceSource.NewArgumentException("isConfiguration", ParserStrings.ConfigurationNotSupportedInPowerShellCore);
throw PSTraceSource.NewArgumentException(nameof(moduleInfo), ParserStrings.ConfigurationNotSupportedInPowerShellCore);
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look right

{
if (typeDefinition == null)
throw PSTraceSource.NewArgumentNullException("viewDefinition");
throw PSTraceSource.NewArgumentNullException(nameof(typeDefinition));
Copy link
Member

Choose a reason for hiding this comment

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

again, why is this changed

if (newCmdletInfo == null)
{
throw PSTraceSource.NewArgumentNullException("cmdlet");
throw PSTraceSource.NewArgumentNullException(nameof(newCmdletInfo));
Copy link
Member

Choose a reason for hiding this comment

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

why?

if (newFunction == null)
{
throw PSTraceSource.NewArgumentNullException("function");
throw PSTraceSource.NewArgumentNullException(nameof(newFunction));
Copy link
Member

Choose a reason for hiding this comment

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

why

// a bad format.

throw PSTraceSource.NewArgumentException("name");
throw PSTraceSource.NewArgumentException(nameof(splitName));
Copy link
Member

Choose a reason for hiding this comment

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

why?

@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Review - Needed The PR is being reviewed labels Sep 9, 2020
@ghost ghost added the Stale label Sep 24, 2020
@ghost
Copy link

ghost commented Sep 24, 2020

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment.

@ghost ghost closed this Oct 5, 2020
@ghost ghost removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept Stale labels Oct 12, 2020
@xtqqczze
Copy link
Contributor Author

@iSazonov I have made changes to this PR, could you please reopen.

@iSazonov
Copy link
Collaborator

I can not reopen :-( - GitHub button is blocked. Do you remove the PR branch?

@iSazonov
Copy link
Collaborator

@xtqqczze Please create new PR.

@xtqqczze
Copy link
Contributor Author

Opened #13875

@xtqqczze
Copy link
Contributor Author

xtqqczze commented Oct 27, 2020

See also #13898 for ArgumentException changes.

This pull request was closed.
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.

4 participants