Hi,
I love the new Feature in version 3.3 that allows us to pass arguments through the recording into our user code methods. This is an extremely useful tool that is going to allow us to create tests faster that cover more cases.
The feature request I have is to be able to pass arguments to another CS file's user code. We have created a "Common" user code file that stores common tasks that require user code. Currently we would still have to write a new piece of user code for our recording that calls the Common user code method. We have several common user code methods that are used quite often in our tests.
Thank you for considering our request and thank you for the great new feature!
-Nick
Feature Request: User code arguments
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Feature Request: User code arguments
Actually, this is already possible if you let a recording inherit from your Common class. You can then select the inherited methods from within the recording in your user code actions.
Just edit the *.UserCode.* file of the recording and specify your Common class as the base class.
Alex
Ranorex Team
Just edit the *.UserCode.* file of the recording and specify your Common class as the base class.
public partial class Recording1 : Common { ...Regards,
Alex
Ranorex Team
-
- Posts: 169
- Joined: Thu Jan 13, 2011 2:06 pm
Re: Feature Request: User code arguments
That is incredibly useful! Is there any way to do multiple inheritance? I tried comma separation but that didn't seem to work for me.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Feature Request: User code arguments
No, sorry, the .NET Framework does not support multiple inheritance. You can achieve a similar effect by letting class A inherit from B and let B inherit from C.tallahassee101 wrote: Is there any way to do multiple inheritance?
Regards,
Alex
Ranorex Team
-
- Posts: 169
- Joined: Thu Jan 13, 2011 2:06 pm
Re: Feature Request: User code arguments
Ok, that's what I was going to do if multiple inheritance was not an option. I am getting this warning however doing single inheritance:
'TacViewLib.UISpecific.BreakThroughFilters.Setup.repo' hides inherited member 'TacViewLib.UISpecific.Common.CommonUserCode.repo'. Use the new keyword if hiding was intended. (CS0108) - C:\Ranorex\TacViewLib\UISpecific\BreakThroughFilters\Setup.cs:34,55
Here is the code:
The user code methods from Common.CommonUserCode are available in the recording, however this warning comes up as if something is wrong. Am I doing something wrong? The warning points to the following line in the corresponding generated cs file:
'TacViewLib.UISpecific.BreakThroughFilters.Setup.repo' hides inherited member 'TacViewLib.UISpecific.Common.CommonUserCode.repo'. Use the new keyword if hiding was intended. (CS0108) - C:\Ranorex\TacViewLib\UISpecific\BreakThroughFilters\Setup.cs:34,55
Here is the code:
Code: Select all
namespace TacViewLib.UISpecific.BreakThroughFilters
{
public partial class Setup : Common.CommonUserCode
{
....
Code: Select all
public static TacViewLib.TacViewLibRepository repo = TacViewLib.TacViewLibRepository.Instance;
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Feature Request: User code arguments
Hi,
as both the inheriting and the inherited class have a member called repo which is automatically generated via code generation it's not really possible to get rid of this warning.
Basically, as we can say it's not a good idea to inherit one recording from another.
Regards,
Tobias
Ranorex Team
as both the inheriting and the inherited class have a member called repo which is automatically generated via code generation it's not really possible to get rid of this warning.
Basically, as we can say it's not a good idea to inherit one recording from another.
Regards,
Tobias
Ranorex Team
-
- Posts: 169
- Joined: Thu Jan 13, 2011 2:06 pm
Re: Feature Request: User code arguments
Thank you, I totally looked over the fact that CommonUserCode was defining a variable "repo". CommonUserCode is just a cs code file, not generated. So this works great now, thanks for the new feature!
Re: Feature Request: User code arguments
I am using a "common" file much like you are.
But if you need the repo within your common file just make it private
private static TacViewLib.TacViewLibRepository repo = TacViewLib.TacViewLibRepository.Instance;
then it will not bug you with warnings and you can access all your repository handles from the common file
I had the same porblem with a desire with multi derive:
My test modules derive the common file
and the common file derive all my hw/instruments handles (another file)
This allows me to power on/off and measure stuff within a recording, its pretty sweet
But if you need the repo within your common file just make it private
private static TacViewLib.TacViewLibRepository repo = TacViewLib.TacViewLibRepository.Instance;
then it will not bug you with warnings and you can access all your repository handles from the common file

I had the same porblem with a desire with multi derive:
My test modules derive the common file
and the common file derive all my hw/instruments handles (another file)
This allows me to power on/off and measure stuff within a recording, its pretty sweet
-
- Posts: 169
- Joined: Thu Jan 13, 2011 2:06 pm
Re: Feature Request: User code arguments
So in Ranorex 4.02 this no longer works again. We just recently upgraded from 3.3 to 4.02 and now the usercode that inherits from the baseclass is generating empty methods that are in the baseclass. This generates the same warning as before:
Additionally its generating empty methods that will override the baseclass methods and cause the tests to no longer work since the baseclass won't be called.
Code: Select all
'TacViewLib.Common.SetDeclutterState.TurnOffDeclutter()' hides inherited member 'TacViewLib.Common.CommonUserCode.TurnOffDeclutter()'. Use the new keyword if hiding was intended. (CS0108) - C:\Ranorex\TacViewLib\Common\SetDeclutterState.UserCode.cs:35,21
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Feature Request: User code arguments
Hi,
There is unfortunately an issue in 4.0.3 under the following case, but this should work with 4.0.2, so could it be that you use 4.0.3?
When UserCode Class inherits from Class A and Class A inherits from Class B and the method is defined in Class B, the method is not found and therefore it will be replaced. However it should be found and not be replaced.
Again this problem is only known to exist in 4.0.3.
Regards,
Markus
There is unfortunately an issue in 4.0.3 under the following case, but this should work with 4.0.2, so could it be that you use 4.0.3?
When UserCode Class inherits from Class A and Class A inherits from Class B and the method is defined in Class B, the method is not found and therefore it will be replaced. However it should be found and not be replaced.
Again this problem is only known to exist in 4.0.3.
Regards,
Markus