Question about module variables in Code modules

Class library usage, coding and language questions.
MichalSk
Posts: 35
Joined: Fri Jul 10, 2020 9:23 am
Location: Pforzheim, Germany

Question about module variables in Code modules

Post by MichalSk » Fri Aug 14, 2020 3:43 pm

Hello everyone,

I have an code module where I am using 5 module variables.

When I added them through the Ranorex IDE by clicking "Insert new module variable" everything works fine and all 5 variables are shown in the Test suite view (see Module_Variables_Before_Refactoring.PNG).

But when I refactor those module variables in Visual Studio, by using "Show potential fixes" and click "convert to auto property" some module variables arent getting recognized anymore (see Module_Variables_After_Refactoring.PNG).

Only 2 from 5 module variables are beeing showed in test suite view now.

Do you have an idea why it works that way and how to fix it?
Attachments
Module_Variables_After_Refactoring.PNG
Module_Variables_After_Refactoring.PNG (28.74 KiB) Viewed 94 times
Module_Variables_Before_Refactoring.PNG
Module_Variables_Before_Refactoring.PNG (45.83 KiB) Viewed 94 times

User avatar
Stub
Posts: 373
Joined: Fri Jul 15, 2016 1:35 pm

Re: Question about module variables in Code modules

Post by Stub » Mon Aug 17, 2020 8:12 am

Try getting rid of the default value setting i.e. = "" and = "Max" on the end of your properties. It wouldn't surprise me if that fixes it.

MichalSk
Posts: 35
Joined: Fri Jul 10, 2020 9:23 am
Location: Pforzheim, Germany

Re: Question about module variables in Code modules

Post by MichalSk » Mon Aug 17, 2020 1:22 pm

Hello Stub,

removing the default value settings, like you mentioned, fixed my problem.

Now all module variables are beeing shown in the test suite.

Thanks for the help!

MichalSk
Posts: 35
Joined: Fri Jul 10, 2020 9:23 am
Location: Pforzheim, Germany

Re: Question about module variables in Code modules

Post by MichalSk » Tue Aug 25, 2020 2:17 pm

Hello,

now I realized it would be pretty nice, if I could still use a default value for my code module variables. :lol:

But as soon as, I add to one of my code module variables (e.x. = "Test") they aren' getting recognized in the test suite...
In the attachment there is a picture how the variables look like, after I add some default values.

Has anybody an idea how to add default values to code module variables, as they look like in my code?
And not the way Ranorex generates them by default?
Attachments
CodeModuleVariables.PNG
CodeModuleVariables.PNG (28.04 KiB) Viewed 47 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6179
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Question about module variables in Code modules

Post by odklizec » Tue Aug 25, 2020 3:38 pm

Hi,

My guess is, that the way you like it is simply from an unsupported C# version? Anyway, is there something wrong with the way Ranorex generates code module variables? Or is just aesthetic issue? 😉
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

MichalSk
Posts: 35
Joined: Fri Jul 10, 2020 9:23 am
Location: Pforzheim, Germany

Re: Question about module variables in Code modules

Post by MichalSk » Tue Aug 25, 2020 3:57 pm

odklizec wrote:
Tue Aug 25, 2020 3:38 pm
Hi,

My guess is, that the way you like it is simply from an unsupported C# version? Anyway, is there something wrong with the way Ranorex generates code module variables? Or is just aesthetic issue? 😉
Yes it's basically an aesthetic issue :wink:
Here https://stackoverflow.com/questions/407 ... tial-value I read that since C# 6.0, you can specify initial value in-line, like i would like. Do you know if this version is supported by Ranorex?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6179
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Question about module variables in Code modules

Post by odklizec » Wed Aug 26, 2020 7:42 am

Hi,

I believe that actual Ranorex 9.3.2 supports C# up to version 7? The thing is, that Ranorex supports compiling of such projects, but its code completion and syntax checker definitely does not support all C# 6/7 specific goodies. Which means, that your requested inline variable syntax is supported and Ranorex successfully compiles projects with such variables. These variables can even be used in code. It's just that you will not see them in the list of available variables or you will not be able to examine their content during debugging (by hovering mouse over them).
inlineVar.png
inlineVar.png (29.39 KiB) Viewed 33 times
So if I were you, I would ignore the aesthetic issue and simply use supported syntax ;) And of course, you can make a feature request here:
https://uservoice.ranorex.com/forums/15 ... ve-ranorex
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

MichalSk
Posts: 35
Joined: Fri Jul 10, 2020 9:23 am
Location: Pforzheim, Germany

Re: Question about module variables in Code modules

Post by MichalSk » Wed Aug 26, 2020 10:13 am

Hello,

alright, thanks for the explanation!

Because of the fact, that I need to see those variables in a list (especially in the test suite view, under Data Binding) I will go with the Ranorex Syntax.

Of course, I could make an feature request, but there are already so many reports, that I want the Production team to focus on that ;)
Especially requests like improving the API documentation or IDE are really needed.