Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fix ArgumentNullException messages passed as parameter names - #2889

Merged
jkotas merged 1 commit into
dotnet:masterfrom
hughbe:string-exception
May 10, 2016
Merged

jkotas merged 1 commit into
dotnet:masterfrom
hughbe:string-exception

Conversation

@hughbe

@hughbe hughbe commented Jan 27, 2016

Copy link
Copy Markdown

Found one weird parameter name, and git grepped the mscorlib folder to fix the others

@AlgorithmsAreCool

Copy link
Copy Markdown

Is it still to soon to use nameof() in coreclr?

@hughbe

hughbe commented Feb 23, 2016

Copy link
Copy Markdown
Author

I think it's corefx only at the moment

{
if (handle.IsNullHandle())
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"), "handle");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are these parameters backwards i.e. shouldn't "handle" come before the GetResourceString call?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't think so, as this is an ArgumentException

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nvm, just looked it up and the order is reversed for ArgumentException. That's confusing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Very! Stumped me more than a few times

@ianhays

ianhays commented Apr 8, 2016

Copy link
Copy Markdown

Changes look good to me.

Fixed several ArgumentNullExceptions that throw with the message as the parameter name, leading to potential confusion for developers.
@hughbe

hughbe commented May 10, 2016

Copy link
Copy Markdown
Author

@jkotas please take a look, this has been reviewed but unmerged for a while :)

@jkotas

jkotas commented May 10, 2016

Copy link
Copy Markdown
Member

LGTM. Thanks! Sorry for the delay.

Would you mind porting the applicable fixes to CoreRT as well?

@jkotas
jkotas merged commit ad2485b into dotnet:master May 10, 2016
@hughbe

hughbe commented May 10, 2016

Copy link
Copy Markdown
Author

Will do

@hughbe
hughbe deleted the string-exception branch May 10, 2016 15:07
jkotas pushed a commit to dotnet/corert that referenced this pull request May 10, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…coreclr#2889)

Fixed several ArgumentNullExceptions that throw with the message as the parameter name, leading to potential confusion for developers.

Commit migrated from dotnet/coreclr@ad2485b
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants