Renaming method in user code collection, updates method references in code view, but not in actions view

Bug reports.
User avatar
lxsmkv
Posts: 14
Joined: Mon Jun 14, 2021 7:15 am

Renaming method in user code collection, updates method references in code view, but not in actions view

Post by lxsmkv » Mon Jul 12, 2021 2:03 pm

Software Version 9.5.3
  1. Create new blank solution (New Testsuite/Testcase and Recording are already added to the solution by default.)
  2. Right Click on Project Name in Prjects Browser Tree and select Add -> New Item -> User code collection
  3. Open the created User Code Collection (it should be opened automatically after creation)
  4. Right click inside the Class and select Insert New User Code Method
  5. In the name dialog give the method a name. Here "SetClipBoardText". Press OK to confirm.
  6. In the code editor add a string parameter to the method and implementation like this:

    Code: Select all

            [UserCodeMethod]
            public static void SetClipBoardText(string textString)
            {
            	WinForms.Clipboard.SetText(textString);
            }
    
  7. Go to the Recording module, and select Add New Action -> User Code -> Select from Library
    and select the method you just created inside the UserCodeCollection
  8. User Code Action is added to the Action View of the Recording Module. (OK)
  9. Build your solution.
  10. Solution Builds without any errors or warnings. (OK)
  11. Open User Code Collection again
  12. Right Click on your method name and select Rename from context menu
  13. In Rename Dialog change the Method name to i.e. WriteClipBoardText, press OK to confirm.
  14. Press Strg+S to save changes and build your solution.
  15. Error occurs that a method is missing:

    Code: Select all

    Error - Action #1: Method " System.Void UserCodeRefactoring.UserCodeCollection1.SetClipBoardText(System.String textString) " does not exist. Select a different method or add it to the user code. - C:\RanorexProjects\UserCodeRefactoring\UserCodeRefactoring\Recording1.rxrec:1
    
  16. Expand the Recoding and open the Recording1.cs file by double clicking on it.
  17. Inside the ITestModule.Run() implementation we see the renamed method (OK)
  18. Go to the Actions view of the Recording module
  19. The Line with the user Code displays an red exclamation sign for error and we see the old method name in method column (NOK)
  20. Expected: The method reference is automatically updated also in Actions View.
  21. Select the action line and press Args.. button
  22. The arguments dialog for the method is displayed (OK)
  23. Press OK in Arguments dialog. Arguments Dialog is closed. (OK)
  24. The Warning sign is no more displayed. User Code Action still displayes the old method name (NOK)
  25. Double click on the User Code line in Actions View to enter the code editor.
  26. Viewing the arguments dialog and closing it has seemingly created an empty local method with the old method name (NOK)
  27. Expected: Viewing arguments dialog for errorneus function doesnt silently "heal it", by creating a local empty method satisfying the signature, which will most probably go unnoticed by the developer
P.S.:
I found some similar 4 year old issue here without solution. May be the bug is just still there

Jacob
Certified Professional
Certified Professional
Posts: 120
Joined: Mon Mar 22, 2021 10:01 pm

Re: Renaming method in user code collection, updates method references in code view, but not in actions view

Post by Jacob » Tue Aug 03, 2021 7:09 pm

Hi lxsmkv,

Thank you for the report. I was able to reproduce this, and I was also able to get it working. After step 14 in your outline below, I did the following:
15. Go back into the Recording Module and click on the (now incorrect) User code name
16. Update the name of the method to match the new name that was just updated in the code-behind
17. Click "Save all buffers" (double floppy disk icon)
18. Build all Projects in the solution. Receive the same error.
19. Rename the User code method in the Recording again, and then build the solution again.
20. Solution should build without issue.

I do agree this is an issue, but taking the extra step to rename the method again in the recording fixed the issue for me. Of course, if this method is used in multiple recording modules, you may have to do this a couple times and this could be quite frustrating. However, I worked through this using grep to replace all occurrences. WARNING THIS IS NOT A BEST PRACTICE AND THERE ARE LIKELY BETTER IDEAS THAN THIS OUT THERE, BUT THIS WORKED FOR ME IN A TEST PROJECT.

--Jacob
Image

BaumerT
Posts: 3
Joined: Wed Sep 20, 2023 7:18 am

Re: Renaming method in user code collection, updates method references in code view, but not in actions view

Post by BaumerT » Fri Sep 22, 2023 7:33 am

Hi,

I have the same problem and I ask myself why this is not considered as a bug. I would expect if I use the "Rename" feature it schould replace all names even in the actions. With this limitation maintaining is a mess. I have 200 Tests with one specific function. Due to a change it makes more sense that the function has a different name. There should really be a better support for this.

Maybe Ranorex can make a comment on this.

BaumerT
Posts: 3
Joined: Wed Sep 20, 2023 7:18 am

Re: Renaming method in user code collection, updates method references in code view, but not in actions view

Post by BaumerT » Fri Sep 22, 2023 7:37 am

I just found some really old threads (2006!) with were users are complaining about the lack of the rename function. Will this be fixed or stays it as a known limitation???