JetBrains Rider import reference inside namespace - jetbrains-ide

We have a style rule that requires 'using' statements be 'inside' a namespace declaration in a class.
I cannot find where to set my automatic references from the code editor so that any 'using' statements which are added will be inside the namespace rather than at the top of the page.
In Settings there is Code Style | C# | Code Style | Reference Qualification but those settings do not deal with placement in the file.
Is this possible, where?

I found the answer # https://rider-support.jetbrains.com/hc/en-us/community/posts/360001334920-Optimize-imports-add-reference-option-to-put-using-directives-inside-namespace
File | Settings | Editor | Code Style | C# | Code Style | Reference Qualification | Add 'using' directive to deepest scope

Related

Fitnesse assign value to global variable and reuse in multiple Fixtures

Hi I am new to Fitnesse framework, and I'm trying to find a way where I can assign a value to a global variable somehow from a database sequence. I already have written few test cases using a variable on page but its value had to be changed manually each time before running test, since I have declared it as,
!define prefix {100}
!|Some Col Fixuture-1
|header1 |header2 |
|Val1 |Val2-${prefix} |
!|Some Col Fixuture-2
|header1 |header2 |
|Val3 |Val4-${prefix} |
Is there any way I can assign value to variable "prefix" dynamically so instead of changing it manually I can just start test and at runtime it may get assigned to it. I tried assigning it in another fixutre before calling any other fixutre but that didn't work, I did something like below,
!define prefix {100}
!|Database Sequence Col Fixuture
|nextVal? |
|$prefix = |
in java I have nextVal method and I'm calling DB to get next value from a sequence and it seems to be working but this new value doesn't get passed to other column fixtures mentioned above, probably due to scope of the variable.
It would be really great help if anyone can suggest or provide any sample to assign value to global variable and using it in multiple fixtures, or if there is any other way to do so.
Any help would be really appreciated, thanks in advance.
Regards,
Harsh
If you are using slim you should be able to use the variable as $prefix.
Please note this is a different variable type, a slim symbol, as compared to the wiki variable you created using !define, you don’t need that define

ANTLR4: Use getText() in label of python

I'm currently having one issue with ANTLR4. I have previously worked with ANTLR4 and generated the classes in Java. I would then be able whenever I found a label to do: ctx.label.getText() to get the text in the label.
Now I'm trying to do the same thing in Python3, however, it is not working.
For example in this grammar when I try to access the value.
expression
: LPARENS expression RPARENS
| ...
| value=(INTEGER | FLOAT | BOOLEAN | STRING | HOLE)
;
When trying to access ctx.value.getText() it gives me the following error:
print(ctx.value.getText())
AttributeError: 'CommonToken' object has no attribute 'getText'
Since I'm pretty new in using antlr4 with python was wondering what workaround exists for this.
In case of tokens, value=TOKEN, it’s .text:
print(ctx.value.text)
In case of a parser rule, value=expression, then it is value.getText(), I believe.

How to ignore stepdefinition variable declaration in cucumber for same value

How to ignore stepdefination variable declaration in cucmber for same value?
So suppose I have example as below:
Scenario Outline: Looking up the definition of fruits
Given the user is on the Wikionary home page
When the user <name> looks up the definition of the word <name>
Then they should see the definition 'An edible fruit produced by the pear tree, similar to an apple but elongated towards the stem.'
Examples:
| name |
| pear |
Step definition like below:
#When("^the user (.*?) looks up the definition of the word (.*?)$")
public void when(String name, String name2){
System.out.println(name);
System.out.println(name2);
}
Now in above step I have created two variables unnecessary and I am doing it because my cucumber report should get the name at two places in the when statement.
If I put only one variable then cucumber will throw an error.
Please let me know if you need any further information or if I am missing anything.
Use non-capturing group in regex - (?:.*?) to any of the groups. Only one argument will then be required in method.
https://agileforall.com/just-enough-regular-expressions-for-cucumber/

How can structs in separate files reference each other?

Using structs that reference each other is common in a single file, but when I separate the structs into two files, I get an error.
mod_1.rs
mod mod_2;
use mod_2::Haha;
pub struct Hehe {
obj: Haha,
}
fn main() {
Hehe(Haha);
}
mod_2.rs
mod mod_1;
use mod_1::Hehe;
pub struct Haha {
obj: Hehe,
}
fn main() {
Haha(Hehe);
}
This will produce an error. When compiling the mod_1.rs:
error: cannot declare a new module at this location
--> mod_2.rs:1:5
|
1 | mod mod_1;
| ^^^^^
|
note: maybe move this module `mod_2` to its own directory via `mod_2/mod.rs`
--> mod_2.rs:1:5
|
1 | mod mod_1;
| ^^^^^
note: ... or maybe `use` the module `mod_1` instead of possibly redeclaring it
--> mod_2.rs:1:5
|
1 | mod mod_1;
| ^^^^^
When compiling the mod_2.rs:
error: cannot declare a new module at this location
--> mod_1.rs:1:5
|
1 | mod mod_2;
| ^^^^^
|
note: maybe move this module `mod_1` to its own directory via `mod_1/mod.rs`
--> mod_1.rs:1:5
|
1 | mod mod_2;
| ^^^^^
note: ... or maybe `use` the module `mod_2` instead of possibly redeclaring it
--> mod_1.rs:1:5
|
1 | mod mod_2;
| ^^^^^
In mod_1.rs I use something from mod_2.rs and in mod_2.rs, I use mod_1.rs's thing, so I'd like to find a way to get rid of the cycle reference module problem.
Trying to get Rust to load files is a similar but different problem.
This is a common misunderstanding of Rust's module system. Basically, there are two steps:
You have to build a module-tree. This implies that there are not cycles in this module-tree and there is a clear parent-child relationship between nodes. This step is simply to tell Rust what files to load and has nothing to do with usage of certain symbols in different modules.
You can now reference each symbol in your module tree by its path (where each module and the final symbol name is separated by ::, for example std::io::read). In order to avoid writing the full path every time, you can use use declarations to refer to specific symbols by their simple name.
You can read a bit more on that in the Rust book chapter.
And again, to avoid confusion: in order to use a symbol from a module, you don't necessarily have to write mod my_module; in your module! For each non-root module of your project there is only one line in your entire project saying mod said_module; (the root module does not have such a line at all). Only once!
About your example: you first compiled mod_1.rs via rustc mod_1.rs. This means that mod_1 is the root module in your case. As explained above, the root module doesn't need to be declared via mod at all, but all other modules need to be declared exactly once. This means the mod mod_2; in mod_1.rs is completely correct, but the mod mod_1; in mod_2.rs is incorrect. The compiler even suggest the right thing to do:
note: ... or maybe `use` the module `mod_2` instead of possibly redeclaring it
You are already useing it, so you can just remove the line mod mod_1; and solve this error.
However, I think you are still thinking incorrectly about the module system. As mentioned above you first need to design a more or less fixed module tree which implies that you have one fixed root module. Whatever you pass to rustc is the root module and it doesn't make sense to use different modules as root module. In your project there should be one fixed root module. This could be mod_1 as explained above. But it's usually more idiomatic to call it lib for libraries and main for executables.
So again: first, draw your module tree on a piece of paper. Consider this fixed for the moment and then you can create the files and mod declarations appropriately.
Last thing: even when fixing the module system, your example won't work, because Haha and Hehe are types with infinite size. Fields of structs are directly put into the memory layout of the struct (without boxing them like in Java!). Thus you can't have cycles in struct definitions, except if you manually add a layer of indirection, like boxing the fields. Please read this excellent explanation on this issue.

Resharper 6 - automatically adding "this"

There is a naming style in a company I work for that "this" must be added to every function, property call and field. Sometimes I forget about it. I want Resharper to do it automatically.
Any suggestions?
Find option ReSharper | Options -> Code Editing | C# | Formatting Style | Other -> Other | Force "this." qualifier for instance member and change it to Use always, then run full Code Cleanup.

Resources