Stop ReSharper cleanup from reordering unit tests - resharper

Currently when I run Full Cleanup on a file with NUnit tests R# totally ruins it. For some reason it reorders the methods with [Test] in alphabetical order. How can I turn this "feature" off?
I'm using version 9.2.

This is explained in the documentation here
you need to go to Code Editing | C# | File Layout page of ReSharper options and then remove the default NUnit layout pattern (or change it so that it doesn't reorder alphabetically)
The simplest way to do this via the ui (which seems to be very confusing) is to double click each Type Pattern and make sure you are in composition view (click the icon in the top right corner until its a cog) then double click the method Entry elements until you find the one which has the constraint for the attribute for NUnit framework (somethign like this):
and then change the Sort By option in the bottom right of the main settings window to be none

Related

Godot: Is there any way I can invoke a method in my Script from the editor? (for testing purposes)

I come from Unity, and there you can use ContextMenu method attribute. It will add a button in the editor you can click and the method in your script will be invoked.
This is very helpful for testing/debugging purposes. When you are testing a functionality and you want an easy way to trigger it.
Is there something similar in Godot, or any workaround I can use?
(Godot 3.5 here)
There are multiple ways to run code in the editor.
In fact, Godot games and the Godot editor are built on the same core. One way to say is that Godot is build on Godot… But a more accurate way to say it is that your games are Godot without the editor, plus whatever you built on top.
As a consequence, you have a lot of freedom when extending the Godot editor.
For starters you will be making a tool script. To do that you the tool keyword on the top of the script file. This allows the script to run in the editor.
Warning: Remember that in Godot the Game is not running inside the Editor. Anything that your script moves while running in the Editor would be a modification to the project, for good or ill. And it does not come with build-in undo functionality. It is possible to add undo functionality (with the UndoRedo class), but that is also something you would have to program.
By the way, you might want to know if your code is running on the editor or not. For that, you can check Engine.editor_hint which will be true in the editor.
Read more on the article Running code in the editor.
Since the tool script modify the project. What I present below is more often used to setup parts of the scene or to automate parts of the development workflow. Not for testing features. However since the linked documentation about ContextMenu mentions that it is useful for…
automatically setting up Scene data from the script
I believe what present below is not out of place.
With that said, some modifications of the editor are harder than others. I believe you don't really want to go into the trouble of adding a button to the editor (which is perfectly possible) or an option to the menus (which is also possible, but not everywhere, at least not easily). Instead, I'll stay with the easy options for this answer:
You can make an EditorScript. That is a script that extends the EditorScript class and overrides the _run method. For example:
tool
extends EditorScript
func _run():
print("Hello from the Godot Editor!")
To execute it, have it open in the Script Editor, and to the File menu, and select Run. You can also use secondary click on the script on the "Scripts Panel (on the left of the Script Editor) and select Run in the contextual menu.
The drawback is that is script does not work in the game. It is only for the editor.
Although Godot 3.x does not have official (there is a plugin) support for inspector actions (it might land in Godot 4), we can workaround that. What we will do is export a bool property, and handle (with a setter, which we specify with setget) what happens when you set it. Like this:
tool
extends Node # or whatever
export var do_something:bool setget on_do_something
func on_do_something(_mod_value:bool) -> void:
# do whatever you want
pass
The property should show up as a checkbox in the Inspector panel when the node is selected. And clicking the checkbox will trigger the setter method on_do_something… Which will do whatever you want it to do. Notice also that I'm discarding the value that Godot is trying to set to the property (_mod_value) so it will remain false.
This pattern has got popularity among Godot developers.
If you want to add elements to the Godot UI you would have to make an EditorPlugin (see the Editor Plugins section in the documentation).
Alright but, since the tool script could cause modifications to the project, which might be a problem for testing… What do we do for testing?
Well, I will remind you that you can tell Godot to execute specific scenes (it does not have to run the main scene), and that can another way to test your code.
Furthermore, when your game is running you can go to the Scene panel and select the Remote tab to see the Nodes that exist in the game. Which will allow you to select them, which shows their properties in the Inspector, which would be able to modify (having an effect in real time on the executing game).
… And thus something similar to what I described above about using a setter would work. Except it does not need the tool keyword since it won't be running in the editor:
# No tool
extends Node # or whatever
export var do_something:bool setget on_do_something
func on_do_something(_mod_value:bool) -> void:
# do whatever you want
pass
By the way, in the inspector, when the game is executing and you have the relevant Node selected, you will see your property twice. The first one will trigger the setter, while the second one bypasses it. So pay attention which one you are using.
You might also be interested in the "Project Camera Override" feature, which allows you to freely move the game camera from the editor. You access the feature via the top bar in the editor.
You will also find that it is possible to modify Resources in the editor and see the effect in real time while the game is running. And a Script is a Resource… However pause the game from the Debugger panel (or use a breakpoint) and make sure the script you want to modify is not being executed before you modify it.

IntelliJ - Collapsable blocks

I've used Php for quiet some time and really liked/got used to the feature to collapse code blocks surrounded by curly brackets, with a click on the little plus/minus icons next to the linenumbers.
PhpStorm
Now I'm doing a Java project with IntelliJ and would like to have this feature too. It works for certain cases like classes, functions and custom regions, but not for if/else, switch statements.
IntelliJ without icons
Already tried changing the Folding options, but without success. I know I can achieve the same result by some keyboard-shortcut, but I would like to have those little plus/minus icons next to the linenumbers.
After using the shortcut the little icons appear though.
IntelliJ with icons
Am I missing some options or is there a plugin that can do that?
Currently it's shown for classes, functions, and custom regions. Please vote for this request to change default behavior: https://youtrack.jetbrains.com/issue/IDEA-144819
It is not clear from your question if you tried to enable "code folding outline" feature in the settings, which is under Editor -> General -> Code Folding -> Show code folding outline which does what you want basically.

Can ReSharper ignore projects/tests in navigation

When using the various navigation and usage features of ReSharper, is there a way to make it hide some of the projects (with tests) in the solution?
Often when I'm browsing through the code, I'm not really interested in the tests, but only the production code.
I received this answer from the Resharper support team.
I have looked at "find usages" deeper and figured out that there is the
following item in filter dropdown -- "Show Unit Test Usages" (attached). So
if you uncheck this item -- usages from Test Projects won't appear in search
result.
Well im not sure this works for the navigation and usage features but for analysis it does, tryto use the skip files and folders menu to add folders which should be excluded.
Under Optionmenu use Settings under the Code Inspection section and select "Edit Items to Skip" and select your folder.
Take a look at this Article too
First, there's no setting in ReSharper to "forget" a certain project in solution.
However, in some cases, navigation combos may help you out.
For example, when you search for types, files or symbols with ReSharper, you can restrict search scope with navigation combos. Say, in NHibernate, entering "dm spec " in Go to Type restricts search scope to Projects\Core\NHibernate.DomainModel\NHSpecific

Resharper test unit shortcut missing

A few months back, I used to be able to click a circle in the code margin, and the given unit test would run (attributes [TestFixture] / [Test]).
Now on my VS2010, the only way to run a single unit test (NUnit is being used) is to type ctrl+alt+U (or do the same via the resharper menu), select the test, and press the debug button.
Anyone know where those code margin buttons went + how to get them back. The icon was a single circle coloured in two halves.
which exact version of resharper do you use? I have Resharper 6.1.37.86 and this option is there.
Also try checking resharper options: Resharper -> Options -> Tools -> Unit testing. Both 'Enable unit testing' and 'Enable NUnit support' should be checked.
Problem was solved by installing a new version of Resharper.

Sort "usings" directive by ReSharper Clean-up

How to setup ReSharper to call "Sort usings" in class?
I will answer for my question.
Using shortcut from Resharper it's not best solution. Nice tool is CodeMaid it makes few nice cleanup's when saving file like with no shortcut key press:
sorting usings alphabetically and remove unused
deleting empty lines
This tool is complement for Resharper.
Resharper (9) will sort usings if you run Code Cleanup, via menus or keyboard shortcut CTRL+E, CTRL+C
Try using the Stylecop Resharper Plugin
Stylecop Rule SA1210: Using directives must be sorted alphabetically by the namespaces will allow you to use a quick fix to sort them by pressing ALT+ENTER.
Using Stylecop is good at helping you write clean code, but you may want to turn off some of the rules.
You don't need ReSharper to do this. By Default the shortcut CTRL+E, R will remove (unused) and sort the using statements.
If you only want sorting or the shortcut isn't set on your instance of Visual Studio, go to:
Tools-> Options.
Environment -> Keyboard
Search for "Editor.ContextMenus.CodeWindow.OrganizeUsings".
There are a few options there to play with.
This question already covers this:
Remove unused Usings across entire assembly
The feature is in ReSharper 4.5. If you right click on the solution,
there's a Cleanup Code... item, which allows you to apply a cleanup
profile to the solution. You can create a new cleanup profile from the
Code Cleanup node within ReSharper options, if you want a profile to
just adjust the using directives.

Resources