Ranorex studio (re)creates empty methods

Bug reports.
User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Ranorex studio (re)creates empty methods

Post by odklizec » Tue Jul 02, 2013 5:41 pm

Hi,

I found an annoying problem while creating/editing methods in Studio (4.0.4 but I saw it also in previous versions), when the studio sometimes (re)create empty methods.
EmptyMethod.png
EmptyMethod.png (106.33 KiB) Viewed 1025 times
Steps to reproduce:
Load the attached solution
test3.zip
(20.87 KiB) Downloaded 163 times
It should open with active FillNotepad.UserCode.cs tab. Sometimes, there is immediatelly created an empty method TestMethod_1 in that UserCode file. If you don't get this result right after loading the project for the first time, try to rebuild the whole solution. Now the empty method should definitely appear and there should be issued a warning (as shown in the above attached picture). If not, try to close the solution and repeat the steps again.

Now about the background of this issue.
While editing recording FillNotepad, I added a new "User Code" action TestMethod_1. By default, it created an empty method declaration in Recording.UserCode.cs file. This creation of empty method is expected. So far so good. I added one line of code and then I moved whole method to common.cs file. Then I made the common.cs inherited by FillNotepad.UserCode.cs. I checked the FillNotepad recording table and it seems it correctly inherited the TestMethod_1. I then saved and closed the solution. Since then, the empty method is sometimes re-created right after loading the solution, sometimes during the solution build. And this is unfortunately neither expected or wanted behavior ;)

Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex studio (re)creates empty methods

Post by Support Team » Wed Jul 03, 2013 2:25 pm

Hello,

Unfortunately, I couldn't reproduce your issue followed your steps.
Could you please describe how you moved your method from FillNotepad.UserCode.cs to common.cs?
Did you use cut & paste?

Regards,
Markus (T)
.
Image

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex studio (re)creates empty methods

Post by odklizec » Wed Jul 03, 2013 3:33 pm

Hi Markus,

Thanks for the reply. That's weird. I can repeat it quite steadily. And yes, I moved the method by using Cut&Paste.

I just manually created a new method in FillNotepad.UserCode.cs, added a new User Code action to the FillNotepad recording and then I moved the newly created method from FillNotepad.UserCode.cs to common.cs. I then saved the solution, closed/reload it and then rebuild it. After that, there were created two empty methods TestMethod_1() and TestMethod_2(). I reproduced it also on another machine and also with other projects.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Ranorex studio (re)creates empty methods

Post by krstcs » Wed Jul 03, 2013 3:54 pm

If you still have a reference in your rxrec file to the method that you moved, Ranorex will create an empty method with the same signature if it cannot find the referenced method in your UserCode file.

This appears to be by design in order to keep the system from reporting NullReferenceExceptions at runtime. In other-words, this is there to keep you from removing methods that you still have references to, which is a bad thing.

If you don't want an empty method to be created, you need to remove the "UserCode" line from your rxrec file, or change the method reference to a method that is actually in your .UserCode.cs file for that module.

You cannot reference a method in any other file from within this module's rxrec file. All references in the current module's rxrec must be in this module's .cs or .UserCode.cs files.

edit to add:

If you need to reference external methods, you will need to do so inside a UserCode method in this module.
Shortcuts usually aren't...

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex studio (re)creates empty methods

Post by odklizec » Wed Jul 03, 2013 4:26 pm

Hi krstcs,

Thanks for your suggestions.

I completely removed the user code action from the recording and also all previously generated empty methods from UserCode.cs. I even searched the source files at binary level, just to see if there is not a forgotten reference of the TestMethod_2. But it seems Common.cs is the only place where this method exists.

I reloaded the solution, created new User Code action and selected one of the offered methods. All of them are now available only in common.cs! I then saved and rebuild the solution. No empty method has been created...so far so good.

Finally, I again reloaded the solution and simply rebuild it one more time. And sure enough, this time, the empty method has been created. Reloading solution seems to be a crucial step in reproducibility of this issue.

PS: I forgot to mention it before, but UserCode.cs inherits common.cs methods! So I don't think there is a need for Ranorex Studio to recreate empty methods in UserCode.cs?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex studio (re)creates empty methods

Post by Support Team » Thu Jul 04, 2013 12:13 pm

Hello krstcs,

Finally, I could reproduce this behavior although it didn't happen every time.
I will add this issue to our internal bug-tracking system.

In the meantime, please try to re-select your method in the Recording action table.

Regards,
Markus (T)
.
Image

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex studio (re)creates empty methods

Post by odklizec » Thu Jul 04, 2013 12:25 pm

Unfortunately, re-selecting does not help. I even tried to create completely new User Code action using already moved methods from common.cs. The problem with empty methods reappears after some time.

I think it has something to do with inheriting common.cs in .UserCode.cs. But without inheriting, the common.cs methods are not available for given recording. Catch 22 ;) I hope it's something easy to fix. Feel free to contact me in case you need more details.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex studio (re)creates empty methods

Post by Support Team » Fri Jul 05, 2013 8:08 am

Hello,

Thank you for your information.
It seems that inheriting causes this issue.
Our development team will analyze it.

Regards,
Markus (T)
.
Image

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex studio (re)creates empty methods

Post by odklizec » Mon Jul 15, 2013 3:18 pm

Hi Markus,

Should this problem be fixed in 4.0.5? I found this bug fix in 4.0.5 description...
Fixed detection of user code methods inherited from a grandparent base class

Unfortunately, the problem seems to be still there. At least I can still reproduce it.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex studio (re)creates empty methods

Post by Support Team » Wed Jul 17, 2013 10:15 am

Hello,

Unfortunately, this issue has not been fixed in 4.0.5.
We will provide a fix in our next minor release version (4.1.0).

Regards,
Markus (T)
.
Image

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex studio (re)creates empty methods

Post by odklizec » Wed Jul 17, 2013 10:21 am

Hi Markus,

No problem! I just thought the issue is fixed after reading 4.0.5 changes ;) It's not a critical issue anyway.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration