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

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.

Related

How to get the text of a menu item with its ID

I have an old visual prolog project in which I have to change the text of a menu during runtime.
This is what I've done to change the text:
menu_setText(Win, id_menu, NewMenuText)
This works fine, however, when I want to enable/disable this menu, the following does not work (meaning the menu item doesn't change its state):
menu_Enable(Win, id_menu, b_true)
After some search, I found that:
Under MS-Windows, submenus can not be referred to by a resource identifier. If the menu entry for a submenu, needs to enabled, disabled, checked or have the text changed. it is necessary to use a special versions of the menu_Enable, menu_Check and menu_SetText predicates, which specify the text of the menu entry instead of the constant.
menu_Enable(WinHandle, String, BOOLEAN)
menu_Check(WinHandle, String, BOOLEAN)
menu_SetText(WinHandle, String, NewString)
The weird thing is that in my case, menu_setText works just fine with the constant where menu_Enable requires the text itself. (yes I tested menu_Enable with the initial text of the menu item, but when the text changes then everything breaks)
Here comes my question:
How can I enable/disable a menu when I know its ID but not its name ?
If not possible directly, how can I get the current name of a menu when I know its ID ?
In case this helps, this project is opened and compiled with VIP52 (since before the year 2001).
I finally found a workaround that solves my problem, but I'm still not really satisfied, so if anyone comes up with a better answer, I'll take it !
I declared:
txt_menu(menu_tag,string)
And then called:
txt_menu(id_menu, MenuText),
menu_setText(Win, MenuText, NewText),
retractAll(txt_menu(id_menu,_)),
assert(txt_menu(id_menu,NewText)),
menu_Update(Win)
whenever I have to change the text of a menu item, and this can easily be transformed into a menu_setTextById predicate as such:
menu_setTextById(Win, MenuId, NewText):-
txt_menu(MenuId, MenuText),
menu_setText(Win, MenuText, NewText),
retractAll(txt_menu(MenuId,_)),
assert(txt_menu(MenuId, NewText)),
menu_Update(Win).
with the usage:
menu_setTextById(Win, id_menu, "My new text menu").
Noted that if I ever have the need to have several windows with menus, I'll have to add the Window Id to my txt_menu clause.
The main problem with this workaround is that I can't use & in the new text menu because if my menu has "&Menu" as text (meaning that M will be underlined), then trying to use menu_setText(Win,"&Menu","New Menu") will break because "&Menu" is not found.
So I'd need to remove any ampersand from the string before trying to use it in such predicates.

A couple questions -- in regard to beginning Pharo

Using 2.0
Getting starting, confortable with Smalltalk, so tool questions I have not found readily in image or 'by Example' book (outdated).
Looking for entry field (not ready-to-use dialog box).
Like:
(TextMorph new) contents: '(enter name here)'; openInWorld.
"but this just opens text, would like to be editable"
Would like to construct [simple] canvas with say four fields e.g. entry, radio, dropdown, etc. examples available?
Anyone know where 'PreferencesBrowser' has been moved to (e.g. keyboard etc.).
Is there a 'Local senders of...' in regard to class browser selected method?
In order to construct a UI you could either use Polymorph or Spec.
For Polymorph examples try in a workspace:
UITheme exampleDialogs.
UITheme exampleBasicControls
For a Spec tutorial have a look at:
Bahman Movaqar, Spec - Part I: The Basics.
The Preferences Browser is replaced by the much nicer Settings Browser which can be found in WorldMenu > System > Settings.
And you can display a method’s senders in Nautilus (the new standard system browser) when you right click on a method name in the method list via the context menu.
You may want to read a Spec tutorial: http://www.bahmanm.com/blogs/spec-part-1-basics

TODO tag comments for SSJS in Xpages in Notes Version 9

At one of the Lotusspere sessions in Orlando, the //TODO comment tag was mentioned. I thought that this was an extremely useful feature but sadly in looks to me like it does not work in SSJS?
Task Tags in XSP sources
Any chance this has been fixed in version 9? It does work in 8, but you need to place it outside your SSJS code block.
I am using the Domino Designer 9 beta build from December (the public beta). The Task Tags functionality still does not include TODO tags in SSJS script libraries and SSJS code blocks.
--
Do the following to control what contents the Tasks view shows:
Choose the Configure Contents
Select "On any element in same project"
You can do the same with the Problems view.
It may have been my session. It's standard Eclipse functionality, so only works in certain editors like the XML Editor. You may have hit the same gotcha I hit during preparation. Enabling it in the Tasks view is not enough. You need to enable it in the relevant editors in the Preferences. Open up preferences and type "Task" in the filter box. It should then get picked up from any SSJS in the source pane. It gets updated when the project is built.

State driven menuitem in Visual Studio 2012 extension

I am writing a Visual Studio 2012 extension that defines several sub-menus to go in two existing Visual Studio context menus. The sub-menu items appear to work correctly except for one thing:
Until the first menu item in my package is clicked, the state of each menu item is its default state depending on its definition in the VSCT file. That works fine for menu items that are always enabled, but some menu items should be enabled or disabled based on certain changing conditions. After the package is sited, their states are set correctly, but how can I get the states to be set correctly before the first item is clicked?
There is no default state that works in my solution. The conditions might be true or false the first time my menus appear.
If you have a solution for this, or know where this has been addressed in a tutorial somewhere, I would appreciate your help.
I finally discovered the answer to my question at MSDN in an article called How to: Autoload a VSPackage. The "trick" is to set the ProvideAutoLoadAttribute on the package class that's created for the project. Here is the declaration for one of the projects I am working on:
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[ProvideAutoLoad("{f1536ef8-92ec-443c-9ed7-fdadf150da82}")]
[Guid(GuidList.guidXamlHelpmeetPkgString)]
public sealed class XamlHelpmeetPackage : Package
{ ...
The third line is all that I added to make the otherwise working extension load early rather than on demand.

Apply a context action to an entire file

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.

Resources