Page 1 of 1

Changing namespace in a project

Posted: Thu Oct 15, 2009 10:25 am
by daa
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?

Re: Changing namespace in a project

Posted: Thu Oct 15, 2009 12:09 pm
by Support Team
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

Re: Changing namespace in a project

Posted: Thu Oct 15, 2009 2:03 pm
by daa
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.

Re: Changing namespace in a project

Posted: Fri Oct 16, 2009 8:56 am
by Support Team
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

Re: Changing namespace in a project

Posted: Fri Oct 16, 2009 9:37 am
by daa
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.

Re: Changing namespace in a project

Posted: Fri Oct 16, 2009 10:59 am
by Support Team
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

Re: Changing namespace in a project

Posted: Fri Oct 16, 2009 11:33 am
by daa
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...

Re: Changing namespace in a project

Posted: Fri Oct 16, 2009 12:33 pm
by Support Team
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

Re: Changing namespace in a project

Posted: Thu Oct 22, 2009 11:25 am
by daa
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.

Re: Changing namespace in a project

Posted: Tue Oct 27, 2009 9:03 am
by Support Team
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

Re: Changing namespace in a project

Posted: Thu Dec 17, 2009 11:06 am
by daa
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.

Re: Changing namespace in a project

Posted: Thu Dec 17, 2009 11:12 am
by Support Team
Thanks for reporting back! I'm glad we could make that work! :-)

Regards,
Alex
Ranorex Support Team