Error with a definition for 'IsEmpty'

Ask general questions here.
mrkeyo
Posts: 2
Joined: Thu Feb 28, 2019 10:32 am

Error with a definition for 'IsEmpty'

Post by mrkeyo » Thu Feb 28, 2019 10:39 am

Hi folks,
I just upgraded Ranorex Studio to 9.0 , and I meet a following problem :

'System.Collections.Generic.IEnumerable<Ranorex.Cell>' does not contain a definition for 'IsEmpty' and no extension method 'IsEmpty' accepting a first argument of type 'System.Collections.Generic.IEnumerable<Ranorex.Cell>' could be found (are you missing a using directive or an assembly reference?) (CS1061)'

My code looks as follows:

Code: Select all

 int resultsPresentCount = repo.formFind.tableSearchResults.Rows.Where
            	(
            		rowSearchResults => !rowSearchResults.Cells.Where
            		(
            			cellSearchResults => Regex.IsMatch(cellSearchResults.GetAttributeValue<string>("text"),varSearchQuery,RegexOptions.IgnoreCase)
            		)[color=#FF0000].IsEmpty()[/color]
            	).Count();
Can someone help me to resolve it ?
Best regards

ahoisl
Certified Professional
Certified Professional
Posts: 192
Joined: Fri Sep 07, 2007 8:16 am

Re: Error with a definition for 'IsEmpty'

Post by ahoisl » Thu Feb 28, 2019 10:57 pm

I guess this was an extension method that has been removed. Try using the (negated) standard Any method instead following instead:
// put next line at top of file where your using statements are
using System.Linq;

cellSearchResults => !Regex.IsMatch(cellSearchResults.GetAttributeValue<string>("text"),varSearchQuery,RegexOptions.IgnoreCase).Any() 
Regards,
Alex
Ranorex Team

semate
Posts: 19
Joined: Tue Jul 03, 2018 7:42 am

Re: Error with a definition for 'IsEmpty'

Post by semate » Tue Mar 12, 2019 10:03 am

Hi!

Same issue here with Ranorex 9.0 the IsEmpty() does not work!
Happens on strings and on an array. I just replaced .IsEmpty() with .Length==0.
For the strings I used the static string.IsNullOrEmpty(mystring) method.
Still wondering why that was dropped ?!

ahoisl
Certified Professional
Certified Professional
Posts: 192
Joined: Fri Sep 07, 2007 8:16 am

Re: Error with a definition for 'IsEmpty'

Post by ahoisl » Tue Mar 12, 2019 2:17 pm

That extension method just happened to be available in one of the namespaces that are commonly used by test code (Ranorex.Core.Testing). It should never have been public and was internally a duplicate of the same method in a base library. Thus it was removed in an attempt to remove duplicate code, unaware that it is used by some users and causing compilation problems.

We will discuss internally whether it makes sense to put that extension method back in, but it won't help you any more, so sorry again for causing you problems on upgrading!

Regards,
Alex
Ranorex Team

ahoisl
Certified Professional
Certified Professional
Posts: 192
Joined: Fri Sep 07, 2007 8:16 am

Re: Error with a definition for 'IsEmpty'

Post by ahoisl » Wed Mar 13, 2019 1:10 pm

Just for your info, we will re-add the method with Ranorex Studio release 9.0.1. That will not help you any more, sorry about that, but hopefully others upgrading directly to 9.0.1.

Regards,
Alex
Ranorex Team