3.0: Cannot resolve symbol; bogus warning

I get a cannot resolve symbol resharper prompt on

throw new ArgumentNullException("logMessage was null");

And what can't it resolve? The actual message string. Wheee.

0
10 comments
Avatar
Permanently deleted user

Hello,

ReSharper expects ArgumentNullException(string) constructor to receive parameter
name. It looks like you have a parameter named "logMessage". ReSharper excepts

throw new ArgumentNullException("logMessage").
The warning is introduced to easy keep exception messages up to date with
actual code.
Probably, we need a quick-fix that fix the exception message in one click.

I get a cannot resolve symbol resharper prompt on

throw new ArgumentNullException("logMessage was null");

And what can't it resolve? The actual message string. Wheee.

Best regards,
Andrey Simanovsky


0
Avatar
Permanently deleted user

Ah I see what you mean; but of course it's a null warning, well then the argument passed to it could be null, and therefore useless, and really you should be putting the parameter name in a string so you know which one failed :)

Also

cannot resolve symbol "logMessage is null"

isn't an accurate description here.

0
Avatar
Permanently deleted user

Ah I see what you mean; but of course it's a null warning, well then
the argument passed to it could be null, and therefore useless, and
really you should be putting the parameter name in a string so you
know which one failed :)


Precisely. That is why you do not need " is null" added to "logMessage".
It is clear from the exception name as well as that logMessage is a parameter.


Also

cannot resolve symbol "logMessage is null"

isn't an accurate description here.


True. It should sound like "text does not correspond to any parameter name".

Best regards,
Andrey Simanovsky


0
Avatar
Permanently deleted user

Or "It's already an ArgumentNullException, you don't need to tell people twice!"

0
Avatar
Permanently deleted user

"blowdart" <no_reply@jetbrains.com> wrote in message
news:33132050.1182525192742.JavaMail.itn@is.intellij.net...
>I get a cannot resolve symbol resharper prompt on
>

throw new ArgumentNullException("logMessage was null");

>

And what can't it resolve? The actual message string. Wheee.


I noticed this feature. It's pretty neat. What turns it on? For which
exceptions does it work?
--
John


0
Avatar
Permanently deleted user

Hello,

I noticed this feature. It's pretty neat. What turns it on?


It's on by default, you may turn it off by editing the highlighting priorities
on the Options / Code Inspection / Inspection Severity page.

For which exceptions does it work?


Those that require an argument name as one of their parameters, as written
in their xml-doc. The list of those exceptions is not user-editable, for
all that I know.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0
Avatar
Permanently deleted user

"Serge Baltic" <baltic@intellij.net> wrote in message
news:dc0986bf65f8b8c98334bee4d2ca@news.intellij.net...

Hello,

>
>> I noticed this feature. It's pretty neat. What turns it on?
>

It's on by default, you may turn it off by editing the highlighting
priorities on the Options / Code Inspection / Inspection Severity page.

>
>> For which exceptions does it work?
>

Those that require an argument name as one of their parameters, as written
in their xml-doc. The list of those exceptions is not user-editable, for
all that I know.


My question really was, is this a hard-coded list in ReSharper, or do you
determine it from metadata or from the xml-doc?
--
John


0
Avatar
Permanently deleted user

The declaration for ArgumentNullException is ArgumentNullException(string
paramName[, string message]), so you should use one of these forms:

throw new ArgumentNullException("logMessage")
throw new ArgumentNullException("logMessage", "logMessage is null")

FxCop and Visual Studio Code Analysis both complain if the paramName
parameter is not the name of one of the parameters of the method, so
ReSharper is following the same convention. If the paramName parameter does
not contain the name of a parameter, Code Analysis emits the message:

"Calls to System.ArgumentNullException's constructor
'ArgumentNullException.ArgumentNullException(String)' should contain one of
the method's parameter names instead of 'logMessage was null'. Note that the
provided parameter name should have the exact casing as declared on the
method."

--


"blowdart" <no_reply@jetbrains.com> wrote in message
news:31589849.1182527859999.JavaMail.itn@is.intellij.net...

Ah I see what you mean; but of course it's a null warning, well then the
argument passed to it could be null, and therefore useless, and really you
should be putting the parameter name in a string so you know which one
failed :)

>

Also

>

cannot resolve symbol "logMessage is null"

>

isn't an accurate description here.



0
Avatar
Permanently deleted user

It Works for ArgumentException and its derivatives (ArgumentNullException,
etc.)

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"John Saunders" <john.saunders@trizetto.com> wrote in message
news:f5h1dk$1lj$1@is.intellij.net...

"blowdart" <no_reply@jetbrains.com> wrote in message
news:33132050.1182525192742.JavaMail.itn@is.intellij.net...

>>I get a cannot resolve symbol resharper prompt on
>>
>> throw new ArgumentNullException("logMessage was null");
>>
>> And what can't it resolve? The actual message string. Wheee.
>

I noticed this feature. It's pretty neat. What turns it on? For which
exceptions does it work?
--
John



0
Avatar
Permanently deleted user

"Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in
message news:f5noo6$6es$1@is.intellij.net...

It Works for ArgumentException and its derivatives (ArgumentNullException,
etc.)



Thanks.

--
John

0

Please sign in to leave a comment.