C# generated code - Change Request...

Ranorex Spy, Recorder, and Studio.
chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

C# generated code - Change Request...

Post by chrisgeorge » Tue May 18, 2010 9:33 am

Hi,

We are extensively using Ranorex to test a SQL Server Management Studio plugin, and as such have to run tests against different versions of management studio. To do this, I've created an partial class file to provide the facility to override certain parts of the repository for the few areas that differ between the various SSMS versions. I looked into having version specific repositories, but at the time it just was not feasible, and 95% of the objects would be duplicated.

However, since the changes to the generated code post-2.1 (i'm evaluating 2.3 atm), I now have to manually change the protection of the default class constructor ( eg MyRepo(), generated by Ranorex Spy) from private to internal every time I regenerate the code, so that I can call this constructor from my own one.

Therefore, I would like to request that the default constructor in the generated C# code be made internal, or an option added to specify this please :-)

BTW, Ranorex rocks! We automatically launch 6-8 virtual machines with each of them running over 250 ranorex tests every night on various OS/SQL Server configurations. :-D

Thanks

Chris
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

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

Re: C# generated code - Change Request...

Post by Support Team » Wed May 19, 2010 12:46 pm

Hi,
chrisgeorge wrote:Therefore, I would like to request that the default constructor in the generated C# code be made internal, or an option added to specify this please
We can change the default constructor protection from private to public. This is just a little change in the generation of the repository code. So it can be released with the next version of Ranorex.
chrisgeorge wrote:However, since the changes to the generated code post-2.1 (i'm evaluating 2.3 atm), I now have to manually change the protection of the default class constructor ( eg MyRepo(), generated by Ranorex Spy) from private to internal every time I regenerate the code, so that I can call this constructor from my own one.
The constructor protection was always set to private. I've tried the code generation of SPY (Ranorex Version 2.1.0 Build 6243) and the repository constructor is generated with protection mode private. Could you tell us in which version of Ranorex this behavior occurred?

Please can you explain us why you need this constructor with public or internal protection?

Regards,
Peter
Ranorex Support Team
.
Image

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: C# generated code - Change Request...

Post by chrisgeorge » Wed May 19, 2010 2:03 pm

Support Team wrote:Hi,
chrisgeorge wrote:Therefore, I would like to request that the default constructor in the generated C# code be made internal, or an option added to specify this please
We can change the default constructor protection from private to public. This is just a little change in the generation of the repository code. So it can be released with the next version of Ranorex.
Great :-) thanks
Support Team wrote:
chrisgeorge wrote:However, since the changes to the generated code post-2.1 (i'm evaluating 2.3 atm), I now have to manually change the protection of the default class constructor ( eg MyRepo(), generated by Ranorex Spy) from private to internal every time I regenerate the code, so that I can call this constructor from my own one.
The constructor protection was always set to private. I've tried the code generation of SPY (Ranorex Version 2.1.0 Build 6243) and the repository constructor is generated with protection mode private. Could you tell us in which version of Ranorex this behavior occurred?

Please can you explain us why you need this constructor with public or internal protection?

Regards,
Peter
Ranorex Support Team
I think you misunderstood. Yes the constructor has always been private and that has not changed.

We needed a way to override certain elements in the generated C# code and we did this by taking advantage of the fact that the class was partial, and most of the objects were static. So I created a new public constructor in my partial class. I could then inherit the repository class into a wrapper class using this public constructor. This worked (in 2.1) because the base objects were initialised statically.

However, because the objects are initialised in the default constructor now (2.3), I need to be able to inherit the default constructor, which is where I need to change the protection mode.

The reason we have to do all this is to support multiple versions of sql server management studio. Most of the controls in the repository can be reused across multiple versions, but some are slightly different. So rather than having multiple versions of the repository that would be a maintenance nightmare, I just override the specific objects as and when I have to.

Thanks

Chris
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

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

Re: C# generated code - Change Request...

Post by Support Team » Wed May 19, 2010 2:20 pm

Hi Chris,

this might also work:
namespace YourTestProject
{
    public partial class YourRepository
    {
        public YourRepository(object foo) : this()
        { 
        }
    }
}
Its a bit ugly, though .. 8)

Michael
Ranorex Team
.
Image

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: C# generated code - Change Request...

Post by chrisgeorge » Wed May 19, 2010 2:37 pm

d'oh "hits head in stupidity" ... of course!

Thanks :-D. However, it will be nice not to have this extra constructor and reference the constructor directly. Look forward to it.

Cheers

Chris
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge