Apply a context action to an entire file - resharper

Is there any way to make Resharper apply a context action at every applicable site in a file?
In particular, in order to comply with coding standards, I wish to apply 'Specify type explicitly' to every 'var' declaration across a number of files.

In general, you can't apply a context action in multiple code positions.
However, in the case of specifying type explicitly, you can use Code Cleanup to batch-apply this.
Choose "ReSharper > Tools > Clean up code"
Click "Edit Profiles"
Click "Add" to create a new cleanup profile and specify a name for it (say, "goodbye var").
In the list of profile settings, clear all check boxes to prevent unwanted code style changes.
Under C# > Use 'var' in declaration, select "Do not change" for "Replace direction", and "Always use explicit type" in the other two drop-downs.
Click "OK".
Choose "ReSharper > Tools > Clean up code" once more, choose the "goodbye var" profile, and click "Run".
Note that you can invoke code cleanup in different scopes: step 7 above implies that you're calling it in the scope of the currently opened file. However, you can choose a wider scope (folder, project, solution) in the Solution Explorer and invoke Code Cleanup from there.

Related

How to add a new method in Pharo?

In the Nautilus System Browser (Pharo 6) there's a right-click command to Add package... as well as Add class... and even Add protocol..., but I can't find anywhere a way to Add method....
Where is that command?
In Pharo, adding a method is not as explicit as the other elements. To add a new method:
Select the protocol for the method, and you should see a template in the editor pane:
messageSelectorAndArgumentNames
"comment stating purpose of message"
| temporary variable names |
statements
Edit this template to make a new method,
Save (Right-click Accept) it using Ctrl-S.
In fact, any time you change a method's definition (e.g., messageSelectorAndArgumentNames) and save it in the editor (Right-click Accept or Ctrl-S), it will create a new method.
For more details, see the section 1.3 of Developing a simple counter document (emphasis is mine):
Create a method
Now let us create the accessor methods for the instance variable count. Start
by selecting the class Counter in a browser, and make sure the you are editing the instance side of the class (i.e., we define methods that will be sent to
instances) by deselecting the Class side radio button.
Create a new protocol by bringing the menu of methods protocol list. Select
the newly created protocol. Then in the bottom pane, the edit field displays
a method template laying out the default structure of a method. As a general
hint, double click at the end of or beginning of the text and start typing your
method. Replace the template with the following method definition:
count
"return the current value of the value instance variable"
^ count
This defines a method called count, taking no arguments, having a method
comment and returning the instance variable count. Then choose accept in
the menu to compile the method.

Select a check box in Blueprism

I need to select a check box as shown in below image. I tried giving "Set Checked" on Navigate stage but it didn't seem to work.
When i try to capture the Checkbox element using HTML Mode, it is getting captured as a HTML Element and not HTML Checkbox.
Can anyone help me here please.
In my projects, a lot of times it was possible to use action "Write", and write value "True" to this element.
If not, then it should be possible to change the element type directly in the Application Modeler. Please inspect first your element, and then change these two parameters:
Element type = "HTML Check Box"
Data Type = "Flag"
Afterwards, in "Navigation" stage, there should be an action "Set checked" available.
For reference, I was able to inspect the logo from w3schools.com and mark it as checkbox in BluePrism.
Just take your datatype as 'Text' and set it to click centre in navigation.
While running the step it will set it checked and proceed it further.
When you use the "Set Checked" action as part of a Navigate stage, you have to set the "Checked" parameter in the lower portion of the Stage Properties window to "True".
Identify the required check box in Active Accessibility SPY Mode. The element Type for this will be Check Box(AA), Change it to Active Accessibility from the drop down. And then use this element in Navigate stage and select "Global Mouse Click Center" in the Actions drop down, to Check this check box

How do you set the File Layout to put [ClassInitialize] and [ClassCleanup] at the top of the file using Resharper 9?

How do you set the File Layout to put the MsTest [ClassInitialize] and [ClassCleanup] methods at the top of the file using Resharper 9?
With the default set-up for R#, the methods are just alpha sorted with the other test methods
I appreciate that I can amend the "All other members" from sort by Name, to sort first by Static and then by Name, but this seems like a quick hack
You can edit the file layout rules that ReSharper uses for reordering file content by code cleanup, by going to ReSharper → Options → Code Editing → C# → File Layout.
Full details are available in the web help, but the idea is to create a pattern very similar to the default "NUnit Test Fixtures" pattern, but for MSTest. In fact, this is a nice idea for a default pattern, so I've added a feature suggestion you can track or vote: RSRP-446275
Essentially, you want to do what the default NUnit Test Fixtures rule does.Create a new "type pattern" and add it between "NUnit Test Fixtures" and "Default Pattern". Double click to edit the pattern, and switch to constraints view by clicking the cog in the top right. Here you can say it has to be of Kind "Class" And "Has attribute" Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute.
Switch back to Composition (rules) view, and add an "Entry" from the Toolbox. Give it a name, such as "Setup/Teardown Methods", and double click on it. This should be set up the same as NUnit's - And (Kind=Method, Or (Has attribute=Microsoft...ClassInitializeAttribute, Has attribute=Microsoft...ClassCleanup)).
The NUnit pattern defines another couple of entries - an empty one for "All other members" and one for "Test methods", which is kind=method and has attribute=Test. Something similar could be done for mutest's TestMethod attribute.

NSIS section hide (compile and execute)

Well I found a few forum topics on nsis section hiding, also checked NSIS help but couldn't find my answer. I want a simple thing i.e. per my requirement I want to hide a section completely without commenting whole lines of code.
Now this should effect two things.
Section should be removed from compilation scope just like if I commented those lines.
Do not execute the section codes from installer.
If I use #, /o or - before section name. It's doing the 2nd point. But any way to achieve the first one?
You can use conditional compiling:
!define INCLUDESECTION
!ifdef INCLUDESECTION
Section "section1"
...
SectionEnd
!endif
You can also decide to include the section or not, from command line:
makensis.exe /DINCLUDESECTION example.nsi
In this case, you don't have to define INCLUDESECTION inside your nsis code.
It's bad idea to disable sections at compile time to avoid it's selection/execution because:
Sections designed all about of code runtime behaviour, not of compile time. Otherwise it produces an infinite set of !ifdef...!endif for section scope control and bloatware compilation definitions incorporation like yours INCLUDESECTION.
At some point you will want to switch a section selection/visibility in the runtime which will force you to mix the runtime and compile time code that is even worse.
I may think it all went from an invalid undestanding of section selection/hideness behaviour in the runtime. So, to ensure you that theres is no much problems to use section selection/hiding in the runtime you have to understand several things to think on:
In Windows sections implemented through the SysTreeView32 control and inherites/workarounds all issues introduced by such controls. This means you have to hide/unhide sections (controls items) in a Page Pre (OnCreate) function instead of Page Show (OnShow) function which basically uses to control a section visibility state.
Sections can still run even if hidden, because the hidden state is independent to the selection state. To hide section you have to set empty string to the section name when the selection state introduced by the respective contol item flag. So, in some cases you might have to test a section hideness at the section code block to skip it's further execution.
Parent section selection triggers children selection recursively by the control. But because hidden not readonly children sections does select too, you have to update parent selection state from the "Partial Selected"/"All Selected"/"All Unselected" manually at the end of your .onSelChange handler function to fixup control checkboxes visibility to it's actual appearence.
So, to do all things right you have to:
Write the set of the UpdateSectionGroupSelectionN macroses to postprocess each section group visibility state update, where N - is number of subitems in a section. If all not hidden subitems in a section is selected, then parent must be updated to the "All Selected" state. If some of not hidden subitems in a section is selected, then parent must be updated to the "Partial Selected" state. If all subitems is hidden then you have to decide that to do with such parent items (may be it's should not even change or must be hidden too in the Page Pre function).
Add to a section beggining hideness state check code to bypass section further execution in case if other section neighbors could be hidden or in case of some other reason.
I know all said it's a bit tricky to do, but you will find that this way is almost one common way to fixup all section issues at once and for all and avoid the code further complication on the way.

Default selection of checkbox group

I wanted to put checkbox in my cognos 8 report based on some condition i.e if condition is true checkbox will appear with click mark and if it is not then without click mark.
I'm assuming you are placing this control on a prompt page...
It's kind of convoluted, but here's the only way I know how to do it. You can place 2 "Value Prompt" controls on your prompt page, and set the "Required" property to "No" on both. Set the "Parameter" property to be the same for both prompts (i.e., they will apply the same filter criteria on your query). For one of the prompts, set the "Default Selections" property so that your default value will be automatically selected on one of the controls. Also, be sure to set the "Select UI" property to "Check Box Group" (even if you only have one value to be checked) so you get a check box control.
Now that your controls are setup, you need to place them on your prompt page and apply a conditional render variable to both controls (you can look it up in Help if you aren't sure how to do this -- it's simple, but too lengthy to describe here). Basically, when your query condition is true, render the one with the check box clicked, otherwise render the one without. I not sure about the version support for the "Render Variable" property, but it works in version 8.4.
There isn't a way to my knowledge to dynamically select a default value on a prompt by linking it directly to a query -- You have to go through the conditional formatting/rendering approach.
yes i completely agree with jamey this is the only known way to do this.
there is another much difficult way to do it is by writing a java code which pretty much does tha same.
so i suggest you stick with jamey's solution.
as far as the version question comes, the 'render variable' property works the same in all versions of cognos 8 i.e. 8.2, 8.3 and 8.4.

Resources