Page 1 of 1

using System.Text.RegularExpressions;Drawing;Threading;

Posted: Mon Jan 09, 2017 6:09 pm
by Poblarp
Hi there,

When creating a code module, Ranorex automatically includes the following namespaces.

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;

During the code review, I was asked to remove the following namespaces from my code modules:

using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;


The reviewer said that I haven't used the above functionalities in my code.

If I may remove the above 3 namespaces (Text.RegularExpressions, Drawing, Threading), would Ranorex still functions properly without compromising its reliability and efficiency ?

Thank you very much for your input.

Best regards,

Poblarp

Re: using System.Text.RegularExpressions;Drawing;Threading;

Posted: Mon Jan 09, 2017 6:22 pm
by krstcs
Without seeing your actual code, I don't think anyone can say for sure what you need or don't need.

However, if you are using the standard, Ranorex-generated modules then you should not remove the generated using statements as they are potentially used in other places in the code, mostly by machine-generated segments that are not user-editable.

The issue is that you are editing a PARTIAL class, and if you remove items from the user-code part, that doesn't mean it is removed in the computer-generated part, and that it isn't actually needed.

Normally your peer would be correct, but in this case they are not. I would recommend that you leave the generated code alone.


Edit to add: In addition to the above, the .NET compiler will disregard any unused using directives at compile time, so having them there won't impact the compiled executable.

Re: using System.Text.RegularExpressions;Drawing;Threading;

Posted: Mon Jan 09, 2017 7:01 pm
by Poblarp
Thank you very much for your input on this issue. I will pass along this info to my co-worker who has reviewed my code. They are not working in Ranorex and C# so they may not have knowledge specific to Ranorex and C#. They mostly work with Python and Java for their automation development.

Re: using System.Text.RegularExpressions;Drawing;Threading;

Posted: Mon Jan 09, 2017 7:34 pm
by krstcs
You're welcome.

As I said, normally you want to remove unused using directives, more because it clutters the code than anything. But with Ranorex most of the code is generated, and it is best to leave it alone, especially when it's like this where it doesn't make a difference.

Re: using System.Text.RegularExpressions;Drawing;Threading;

Posted: Tue Jan 10, 2017 9:38 am
by Stub
FWIW I have an option enabled in VS2015 that deletes unused Using statements upon save. I love it. So when I'm editing my Ranorex code in VS rather than the Ranorex native editor I automatically lose these unnecessary Using statements. Hasn't impacted me at all that I've noticed. So I say chuck 'em and put 'em back in if it fails to compile.