-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Use nameof operator part2 #13086
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
Use nameof operator part2 #13086
Changes from all commits
7b08f70
e4b26de
361ddb6
7f3a9cf
b7f69e4
7c6efc9
739d413
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,7 +112,7 @@ public override | |
| } | ||
| else | ||
| { | ||
| throw PSTraceSource.NewArgumentException("value", ConsoleHostRawUserInterfaceStrings.InvalidConsoleColorError); | ||
| throw PSTraceSource.NewArgumentException(nameof(value), ConsoleHostRawUserInterfaceStrings.InvalidConsoleColorError); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -163,7 +163,7 @@ public override | |
| } | ||
| else | ||
| { | ||
| throw PSTraceSource.NewArgumentException("value", ConsoleHostRawUserInterfaceStrings.InvalidConsoleColorError); | ||
| throw PSTraceSource.NewArgumentException(nameof(value), ConsoleHostRawUserInterfaceStrings.InvalidConsoleColorError); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -844,7 +844,7 @@ public override string WindowTitle | |
| } | ||
| else | ||
| { | ||
| throw PSTraceSource.NewArgumentNullException("value"); | ||
| throw PSTraceSource.NewArgumentNullException(nameof(value)); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1218,22 +1218,22 @@ int LengthInBufferCells(string s) | |
| /// <summary> | ||
| /// See base class. | ||
| /// </summary> | ||
| /// <param name="s"></param> | ||
| /// <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); | ||
|
Comment on lines
+1221
to
+1236
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please try to keep different changes in different PRs |
||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -1622,7 +1622,7 @@ public override void SetBufferContents(Coordinates origin, | |
| // if there are no contents, there is nothing to set the buffer to | ||
| if (contents == null) | ||
| { | ||
| PSTraceSource.NewArgumentNullException("contents"); | ||
| PSTraceSource.NewArgumentNullException(nameof(contents)); | ||
| } | ||
| // if the cursor is on the last line, we need to make more space to print the specified buffer | ||
| if (origin.Y == BufferSize.Height - 1 && origin.X >= BufferSize.Width) | ||
|
|
@@ -1695,19 +1695,19 @@ int LengthInBufferCells(string s) | |
| /// <summary> | ||
| /// See base class. | ||
| /// </summary> | ||
| /// <param name="s"></param> | ||
| /// <param name="str"></param> | ||
| /// <param name="offset"></param> | ||
| /// <returns></returns> | ||
|
|
||
| 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); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2189,7 +2189,7 @@ private static void LoadPowerShellClassResourcesFromModule(PSModuleInfo primaryM | |
| if (moduleInfo.ModuleType == ModuleType.Binary) | ||
| { | ||
| #if CORECLR | ||
| throw PSTraceSource.NewArgumentException("isConfiguration", ParserStrings.ConfigurationNotSupportedInPowerShellCore); | ||
| throw PSTraceSource.NewArgumentException(nameof(moduleInfo), ParserStrings.ConfigurationNotSupportedInPowerShellCore); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look right |
||
| #else | ||
| ResolveEventHandler reh = (sender, args) => CurrentDomain_ReflectionOnlyAssemblyResolve(sender, args, moduleInfo); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -513,7 +513,7 @@ private void ProcessPayload(FormatEntryData fed, FormatMessagesContextManager.Ou | |
|
|
||
| if (fed.formatEntryInfo == null) | ||
| { | ||
| PSTraceSource.NewArgumentNullException("fed.formatEntryInfo"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why do we change this? Please revert.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not use
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intention is to trace. We shouldn't remove this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why we do not throw the exception from |
||
| PSTraceSource.NewArgumentException(nameof(fed), "fed.formatEntryInfo is null"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
|
|
||
| WriteStreamType oldWSState = _lo.WriteStream; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -425,7 +425,7 @@ private void LoadData(XmlDocument doc, TypeInfoDataBase db) | |
| private void LoadData(ExtendedTypeDefinition typeDefinition, TypeInfoDataBase db, bool isForHelpOutput) | ||
| { | ||
| if (typeDefinition == null) | ||
| throw PSTraceSource.NewArgumentNullException("viewDefinition"); | ||
| throw PSTraceSource.NewArgumentNullException(nameof(typeDefinition)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, why is this changed |
||
|
|
||
| if (db == null) | ||
| throw PSTraceSource.NewArgumentNullException(nameof(db)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,7 +207,7 @@ internal CmdletInfo AddCmdletInfoToCache(string name, CmdletInfo newCmdletInfo, | |
|
|
||
| if (newCmdletInfo == null) | ||
| { | ||
| throw PSTraceSource.NewArgumentNullException("cmdlet"); | ||
| throw PSTraceSource.NewArgumentNullException(nameof(newCmdletInfo)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? |
||
| } | ||
|
|
||
| if (isGlobal) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,7 +222,7 @@ internal void Update(ScriptBlock newFunction, bool force, ScopedItemOptions opti | |
| { | ||
| if (newFunction == null) | ||
| { | ||
| throw PSTraceSource.NewArgumentNullException("function"); | ||
| throw PSTraceSource.NewArgumentNullException(nameof(newFunction)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why |
||
| } | ||
|
|
||
| if ((_options & ScopedItemOptions.Constant) != 0) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2767,7 +2767,7 @@ private void DoWriteError(object obj) | |
| ActionPreference preference = pair.Value; | ||
| if (errorRecord == null) | ||
| { | ||
| throw PSTraceSource.NewArgumentNullException("errorRecord"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Method signature is
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intention is to trace. We shouldn't remove this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not pass
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The question is not for the style PR. |
||
| throw PSTraceSource.NewArgumentException(nameof(obj), "errorRecord is null"); | ||
| } | ||
|
|
||
| // If this error came from a transacted cmdlet, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ private PSSnapinQualifiedName(string[] splitName) | |
| // Since the provider name contained multiple slashes it is | ||
| // a bad format. | ||
|
|
||
| throw PSTraceSource.NewArgumentException("name"); | ||
| throw PSTraceSource.NewArgumentException(nameof(splitName)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? |
||
| } | ||
|
|
||
| // Now set the full name | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.