Replace with IsEmpty inspection Follow
I've noticed that I keep getting a warning for "Replace with IsEmpty()" which wants to change things like:
if(collection.Count() > 1)
with
if(collection.IsEmpty())
but when I do that, the IsEmpty() function is not resolvable, so I get an error. What is this, is this something new to VS 2011/.NET 4.5?
Please sign in to leave a comment.
Hello Mark,
Could you please attach a screenshot demonstrating this suggestion? Thank
you!
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Resharper should be suggesting changing
if(collection.Count() > 1)
to
if(collection.Any())
and
if(collection.Count() == 0)
to
if(!collection.Any())
which I'm sure it used to.
This just started happening with R# 6.1. I thought there was a new 'IsEmpty()' extension method that I was missing! :^O
There is an IsEmpty function for XElement.
http://msdn.microsoft.com/en-us/library/system.xml.linq.xelement.isempty%28v=vs.95%29.aspx
But I'm not aware of an extension method for what your screen capture is displaying.
That applies to the XElement class specifically, if you look closely at that code, the suggestion is on the documents variable which is of type IEnumerable<XElement>. As I mentioned, if I take the suggestion, the IsEmpty is immediately highlighted (by R# ironically enough) as an error that indicates that IsEmpty cannot be resolved.
You got to that quick, I was in the middle of editing my post as I realised you were stating an extension for collections.
Hello Mark,
This is a bug and it should get fixed in the next EAP build. Thank you!
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"