duplicates functions while build

Bug reports.
kathrin
Posts: 13
Joined: Wed Mar 15, 2017 11:27 am

duplicates functions while build

Post by kathrin » Mon Apr 20, 2020 1:29 pm

Hi @all,

we recently changed to 9.3 an having issues with code generation now.

In a recording-module we have uses custom functions in "userCode.cs". When I try to build the solution some of the functions are created again and throw a build error:
Type '<module>' already defines a member called '<function>' with the same parameter types (CS0111)

Is there a solution for this?

Best regards, Kathrin

The user-code file:

Code: Select all

		public void OpenElement(string idocElement)
		{
			//my original code
		}

		public void SetParameters(string index)
		{
			//my original code
		}

		// new generated functions
		public void OpenElement(string idocElement)
		{
			// TODO: Replace the following line with your code implementation.
			throw new NotImplementedException();
		}

		public void SetParameters(string index)
		{
			// TODO: Replace the following line with your code implementation.
			throw new NotImplementedException();
		}
K
-----------------------
:arrow: Ranorex 9.3
:arrow: Ranorex Certified Professional (01/2017)
:arrow: ISTQB Certified Tester Foundation Level (07/2018)

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

Re: duplicates functions while build

Post by Support Team » Tue Apr 21, 2020 8:15 pm

Hi kathrin,

This build error is occurring because there are two methods with the same name and the same parameters, which .NET/C# does not allow since there is no way to specify which one you want to call. You can resolve this by either giving them different names or making them overloaded methods by specifying different parameters.

Different Names:

Code: Select all

public void SetParameters(string index) {}
public void SetParameters2(string index) {}
Overloaded:

Code: Select all

public void SetParameters(string index)  {}
public void SetParameters(string index, bool example) {}
I hope this helps!

Regards,
Ned

Edit: I realized you may mean the provided code is autogenerated by Ranorex. If this is the case, please provide the exact steps used to duplicate this so I can further investigate this in our controlled environments. Thanks!
.
Image

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

Re: duplicates functions while build

Post by odklizec » Wed Apr 22, 2020 8:19 am

Hi,

I must say I eventually experienced this problem as well? In my case, Ranorex (9.3.1) duplicated “Init” function in one of my recordings (in UserCode file). And the only thing I did was loading solution and started one particular test. Then I got this error about duplicated function. And there it was, at the end of file. Once I deleted it, the test started OK. Sadly, I was unable to reproduce this issue after that.
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

kathrin
Posts: 13
Joined: Wed Mar 15, 2017 11:27 am

Re: duplicates functions while build

Post by kathrin » Thu Apr 23, 2020 11:51 am

Hello Ned,

yes, that's whtat I have meant :)
Edit: I realized you may mean the provided code is autogenerated by Ranorex. If this is the case, please provide the exact steps used to duplicate this so I can further investigate this in our controlled environments. Thanks!
I can not provide the exact steps. I created a new recording-module and added a user-code-method. Then I have run the build and several other modules (not the new one) crashed with the error message. (Maybe there was a "Clean Solution" before the build, can't tell anymore)

I got it running again by "reseting" the files via git's "revert changes" (*.rxrec, *.cs and *.UserCode.cs) for the crashed modules and run the build again.
The second build was not sucessful too, but the shown errors where located in the new module.

After the fix of those the build was sucessful with warnings.

Now I have several Messages like "The following variables have been removed or deleted from module "<Name>" : Paramers. Click to resolve the problem.". Since I did not delete them manually I guess this is because of code autogenerated by Ranorex, too.
K
-----------------------
:arrow: Ranorex 9.3
:arrow: Ranorex Certified Professional (01/2017)
:arrow: ISTQB Certified Tester Foundation Level (07/2018)