Changing namespace in a project

Ask general questions here.
User avatar
daa
Posts: 22
Joined: Tue May 19, 2009 2:01 pm
Location: York, UK
Contact:

Changing namespace in a project

Post by daa » Thu Oct 15, 2009 10:25 am

Ranorex 2.1.4, Windows Vista.

Background first, problem second...

We've had Ranorex for a while, and have a fair bit of useful test stuff, but it's all over the place at the moment. I've now got the job of tidying up and getting everything into a state where we can move on. The first thing I've got to do is rationalise all the namespaces. Where the current test projects have namespaces (say) "X" and "Y", we want "Company.Test.X" and "Company.Test.Y".

As there are hundreds of files around, I've used text tools to change all the "namespace" code lines in the .cs files, all the "namespace=" attributes in the .rxrec files, and the "<RootNameSpace>" attribute in the .csproj files. This all works, and builds both with msbuild and from within Ranorex Studio. However...

As soon as I open a recording in Studio, I get a dialogue box saying "Recycling 1 item" which hangs for 30s or so, and then fills up a green progress bar and goes. It doesn't do anything else except put two copies of the embedded repository .cs file for the recording in the system recycle bin. This also happens on startup for each recording that is re-opened because it was open last time.

Anyone seen this annoyance before and know how to stop it bugging me?
David Allsopp,
Test Automation Engineer, Mitrefinch Ltd.

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

Re: Changing namespace in a project

Post by Support Team » Thu Oct 15, 2009 12:09 pm

Hi daa,
this sounds a little bit strange!
I couldn`t reproduce this issue so far.
Could you please give me a step-by-step instruction.

Regards,
Christian
Ranorex Support Team
.
Image

User avatar
daa
Posts: 22
Joined: Tue May 19, 2009 2:01 pm
Location: York, UK
Contact:

Re: Changing namespace in a project

Post by daa » Thu Oct 15, 2009 2:03 pm

OK, I'll give it a shot...

Take working project, with a standard namespace throughout of (say) "Foobar" -- this is the namespace given to it by just saying "Yes" and "Accept default" when using Studio to create a new project. Have some of your own code and some recordings in it.

Close down Ranorex totally. Use the text editor of your choice (I recommend Vim, but I have heard there are heretical barbarians using something else, "Ewoks" I think) to change all the namespace references in the files (see original post) to "Company.Test.Foobar".

Invoke "msbuild" appropriately to make sure it compiles. Start up Ranorex Studio on the changed project files. Open one of your own code files in Studio, and check the namespace. Build in Studio. All this is OK.

Open a recording in Studio. This is where you get the weird behaviour. See original post again.

I can zip up a smallish example and upload it if you need one. Note that the problem has persisted over a complete new SVN check-out of the code to a new location.
David Allsopp,
Test Automation Engineer, Mitrefinch Ltd.

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

Re: Changing namespace in a project

Post by Support Team » Fri Oct 16, 2009 8:56 am

Hi daa!
I have tested your issue with and without embedded repositories according to your instruction but all works fine.
Could it be that you don`t modify all the files correctly? It looks like that the auto-generated files(from recorder) don`t have the right namespace and the recorder view want to create new ones (and maybe clean up the old ones). That`s the only thing I see problematic at the moment. If the issue still occurs please attach your example app.

Best regards,
Christian
Ranorex Support Team
.
Image

User avatar
daa
Posts: 22
Joined: Tue May 19, 2009 2:01 pm
Location: York, UK
Contact:

Re: Changing namespace in a project

Post by daa » Fri Oct 16, 2009 9:37 am

OK, here's the smallest one I have that shows the behaviour, as a zip. Note that this has a reference to some toolset code that I haven't included, but if you just cut Main.cs down to a stub, the whole thing should compile, and it's the behaviour of the recordings we're interested in anyway.
Attachments
General.zip
Zip of small project with odd behaviour
(186.83 KiB) Downloaded 236 times
David Allsopp,
Test Automation Engineer, Mitrefinch Ltd.

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

Re: Changing namespace in a project

Post by Support Team » Fri Oct 16, 2009 10:59 am

It only happens sometimes on my testing environment (Windows Vista, Ranorex 2.1.4) so it`s hard to reproduce.
It looks like that the referenced repository make problems when loading the recorder view. We have to analyse this issue more precisely. However, try to delete the auto-generated recorder files (underlying *.cs and if embedded the *.Repository.cs file, not the *.usercode.cs file) before opening Ranorex Studio. So the recorder code file(s) should be recreated on next load of the solution/project within Ranorex Studio with the namespace you have defined in the *.rxrec file.

Regards,
Christian
Ranorex Support Team
.
Image

User avatar
daa
Posts: 22
Joined: Tue May 19, 2009 2:01 pm
Location: York, UK
Contact:

Re: Changing namespace in a project

Post by daa » Fri Oct 16, 2009 11:33 am

Ok, we make sure that Ranorex Studio opens the project with no files visible, and shut it down. Then we have the following:
Remove all generated .cs files, start up Studio. All OK.
Open a non-recording .cs file in Studio, still OK.
Open a recording (.rxrec) in Studio, get error dialogue "Can't load file <recordingname>.cs under <DIR>".
Click OK on that box, get new error dialogue "Unable to update Recorder code. Message: Object reference not set to instance of an object".
OK on that one, and we're back to the "Recycling 1 object" behaviour.
When that finishes, get new error dialogue "Unable to update Recorder code. Message:Could not find file <DIR>/<recordingname>.cs".

None of this recreates the .cs files. Fortunately, they're in SVN...
David Allsopp,
Test Automation Engineer, Mitrefinch Ltd.

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

Re: Changing namespace in a project

Post by Support Team » Fri Oct 16, 2009 12:33 pm

I`m sorry, my fault.
Please go into Ranorex Studio, close all documents and delete the underlying auto-generated files there.
Further reopen all recordings to recreate the code.
I hope this will solve your problems!

Regards,
Christian
Ranorex Support Team
.
Image

User avatar
daa
Posts: 22
Joined: Tue May 19, 2009 2:01 pm
Location: York, UK
Contact:

Re: Changing namespace in a project

Post by daa » Thu Oct 22, 2009 11:25 am

OK, I'm back from the training course now...

That still doesn't work. In fact, I can take a project that is mainly hand-written code with just the recording and repository that you get as standard and still get the odd behaviour, even after deleting files as above.

Deleting the secondary recording files and the repository and recreating them under new names still displays the oddity, except this time the file that appears in the Recycle Bin is the new repository.

As a possibly useful bit of side information, the directory structure of the code bears no relation to the Company.Test.XXX structure of the namespace.
David Allsopp,
Test Automation Engineer, Mitrefinch Ltd.

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

Re: Changing namespace in a project

Post by Support Team » Tue Oct 27, 2009 9:03 am

Hi again!
Go into Tools->options->general->Load/Save in the Ranorex Studio menu panel and deactivate 'Use recycle bin when deleting files'. If this doesn`t help also try to deactivate 'Always create vbackup copy' and 'Load User-specific Settings with the document'.

Best regards,
Christian
Ranorex Support Team
.
Image

User avatar
daa
Posts: 22
Joined: Tue May 19, 2009 2:01 pm
Location: York, UK
Contact:

Re: Changing namespace in a project

Post by daa » Thu Dec 17, 2009 11:06 am

Just to say that this problem has gone away after following your advice, and also upgrading Ranorex. Sorry for the long delay in replying -- had a manic November.

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

Re: Changing namespace in a project

Post by Support Team » Thu Dec 17, 2009 11:12 am

Thanks for reporting back! I'm glad we could make that work! :-)

Regards,
Alex
Ranorex Support Team
.
Image