Intellisense completion in ArgumentNullException()?

VS2010 adds a Code Analysis inspection for validating parameters that are
referenced inside publicly visible methods.

It would be really nice if ReSharper could easily assist in fixing these
up... first, but adding ReSharper notifications of these issues with a quick
fix (add the line "if (parameterName == null) throw new
ArgumentNullException("parameterName");" ... but also if it could provide
some intellisense inside the parameter list of ArgumentNullException when
typing it manually, for whatever reason.  Once the cursor is inside the
parens, ReSharper can easily "know" what the valid entries are and let you
select them the moment you type the opening quote...

Good idea?  Bad idea?  Already in progress idea?  :)


4 comments
Comment actions Permalink

The quick fix already exists, just place your cursor on the parameter declaration and press Alt+Enter and choose "Check parameter for null". There is no notification though for public methods. It will be a nice thing to have.
Plus, ReSharper already does the second part of what you want. Place your cursor inside the ArgumentNullException parenthesis, start typing a quote and intellisense with parameter names will pop up. You can also use Ctrl+Space to automatically complete it.

0
Avatar
Andrey Serebryansky
Comment actions Permalink

Hello Julien and Paul,

Also, here's a request: http://youtrack.jetbrains.net/issue/RSRP-60514 that
suggests to provide smart completion inside Argument...Exception constructors.
Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

The quick fix already exists, just place your cursor on the parameter
declaration and press Alt+Enter and choose "Check parameter for null".
There is no notification though for public methods. It will be a nice
thing to have.

Plus, ReSharper already does the second part of what you want. Place
your cursor inside the ArgumentNullException parenthesis, start
typing a quote and intellisense with parameter names will pop up. You
can also use Ctrl+Space to automatically complete it.

---
Original message URL:
http://devnet.jetbrains.net/message/5303038#5303038



0
Comment actions Permalink

I should have known about the quick-fix possibility.

But I cannnot see that ReSharper does the second part of what I want... I
put my cursor inside the ArgumentNullExeption parenthesis, start typing a
quote, and there is no intellisense at all, and ctrl-space doesn’t do
anything.  Which is why I brought up the suggestion.

"Julien Lebosquain"  wrote in message
news:15954562.80891305229247597.JavaMail.devnet@confluence.jetbrains.net...

The quick fix already exists, just place your cursor on the parameter
declaration and press Alt+Enter and choose "Check parameter for null". There
is no notification though for public methods. It will be a nice thing to
have.
Plus, ReSharper already does the second part of what you want. Place your
cursor inside the ArgumentNullException parenthesis, start typing a quote
and intellisense with parameter names will pop up. You can also use
Ctrl+Space to automatically complete it.

---
Original message URL: http://devnet.jetbrains.net/message/5303038#5303038

0
Comment actions Permalink

It's weird. I do have this feature (using R# 6 EAP Build 2151) and ReSharper is the only language addin I have. I'm also quite sure that this behavior was already present in R# 5.1:
IntellisenseForParameterNames.png
Edit: if I type an invalid argument name, it is underlined with "unresolved symbol" and a quick fix "Fix argument text" is also proposed: it's another way to enter the parameter names.

0

Please sign in to leave a comment.