CodeRush for Roslyn 1.0.11 is now available

By now, CodeRush for Roslyn (CRR) preview version 1.0.10 will have expired.

This can mean only one thing……..

CRR version 1.0.11 is now available!!!

Update: Release notes are available here

PSA:
--------------------------------------------
However it appears that for the moment, for some people, Visual Studio is having difficulty locating extension updates.

Normally the typical method of upgrading CRR would be

  • Let Visual Studio detect and notify you of said upgrade’s availability.
  • Allow Visual Studio to download and apply the upgrade.
  • However as we suggested, this isn’t working at the time of writing.

    Fear not dear developer, for we have you covered.

    If you visit the Visual Studio Gallery via this link, you will be able to download the upgrade directly from the gallery, and by-pass the issue currently stopping Visual Studio from assisting you in your upgrade.

    We are quite sure the Visual Studio will not have this issue for long, but we wanted to make sure that nothing stood between you and the latest version of CodeRush for Roslyn.
    --------------------------------------------

    CodeRush for Roslyn: Quick Nav

    For those who don’t already know, Quick Nav is CodeRush’s Symbol Search.

    It’s what you use when you’re trying to find the declaration of some code element when you know part of it’s name.

    Usage

    The default shortcut for this feature is Ctrl + Shift + Q. Once triggered you’ll see the following screen:

    image[Quick Nav - Clean, Simple and Instant]

    [Tip: If you’d prefer to use another hotkey to launch Quick Nav, you can customize this in the Options dialog (Ctrl+Shift+Alt+O) on the shortcuts page (IDE\Shortcuts) in the Navigation section.]

    For demonstration purposes I’ve loaded the source of OpenLiveWriter (A non trivial 27 project open source solution).

    Let’s assume you’ve been working on this project and now you need to find the ‘BrowseMiniForm’. The simplest approach is to type ‘Browse’ into the search panel. As you type, CodeRush presents and filters a list of matching symbols.

    image

    Note how CodeRush presents the results.

    Each symbol is listed with Name, Namespace, Project Name and File Type ensuring that when multiple similarly named symbols are found, there should be no confusion as to the nature of these items. Additionally note how within each item, the placement of your search term is indicated in red. In this case the word ‘Browse’ is lit up in red to show you the grounds on which it was included.

    In this case the item we were searching for, is immediately below the one highlighted.

    Use the Arrow keys to navigate to the next item and hit Enter to take you to the symbol’s declaration.

    Narrowing the Search

    The more you type the narrower the search. If you were to continue typing and change the text to ‘BrowseMini’ your results would be further limited.

    image

    In this case only 2 Items are found making your chosen symbol even simpler to locate.

    Camel Case Searching

    If you don’t feel like typing all that text, then you can use Camel Case Searching to find the symbol you’re looking for.

    BrowserMiniForm’ (The Symbol we were looking for) is a symbol made from 3 words ‘Browser’, ‘Mini’ and ‘Form’. If you type the capitalized initial characters of these words, CodeRush understands that you’re looking for symbols containing these characters in that specific order.

    So if you enter ‘BMF’ into the search text, you get the same results as typing ‘BrowserMini’, but you’ve typed far less.

    image

    As before CodeRush uses red text to indicate the justification of each entry’s inclusion. This can help to alleviate confusion when more items are included than you were expecting.

    Show me the Options

    All examples used thus far have searched the entire solution, however you may also have noticed a note in the bottom left of our screen shots.

    If you tap Ctrl, you can change the default search options.

    If you do so, the screen will expand to show the following:

    image

    As you can see these options are arranges neatly into 4 groups: Scope, Types, Members and Access. All of the items within are used to influence the items that are shown (or not shown)

    Within Scope, the available items are Solution, Project, Namespace and File. Your choice of one of these restricts the symbols that are visible to Quick Nav relative to your current location.

    Any combination of Types, Members and Access may also be independently chosen to suit your needs.

    For those who prefer to keep their hands on the keyboard, these options may all be set/toggled using the indicated shortcut keys.
    (Scope:1, 2, 3, 4 Types: C, S, I, E, D Members: M, P, V, F and Access: W, O, N, T, B)

    For those who are happier to use the mouse the same options will react to a simple click.

    So use Ctrl+Shift+Q to launch Quick Nav and Jump to any symbol in your solution in seconds.

    .. and feel free to leave us your feedback to indicate how we might improve this and other features.

    Extending Selection Embedding with CodeRush

    In my last post, I showed you around some of the Selection Embeddings that ship with CodeRush. 

    Like many CodeRush features, Selection Embeddings are user extensible. In this post I’m going to show you around the options for Selection Embedding and how you can make your own custom Selection Embeddings.

    As an Example:

    Let’s imagine you have some text in a HTML file that looks like this…

    SelectionEmbedding5Items

    … and that you’d like to have it look like this

    SelectionEmbedding5ItemsAfter

    That’s the Selection Embedding we’re going to create.

    Options

    In order to create or alter a Selection Embedding, you need to access the corresponding options page.

    • Press Ctrl+Shift+Alt+O and the Options screen will appear.
    • Select Editor \ Selections \ Embedding from the tree of pages on the left.

    You will be presented with the Selection Embedding configuration page.

    Ensure you have the correct language settings for the file you want to target. This dropdown is at the bottom of the page.

    Since this time we’re going to create a HTML Selection Embedding, we’ll select HTML from the language drop down.

    SelectionEmbeddingLanguageSelection

    Next press the green plus symbol at the top left of the page. You’ll be presented with a template for a new Selection Embedding.

    SelectionEmbeddingNewEmbedding_thumb[2]

    Let’s walk through the various parts of configuring your new selection embedding available on this page.

    Naming

    The Caption field represents the text value which you will see on the Code \ Embed Selection submenu.

    The Name field is used if you wish to bind the embedding to a shortcut later on.

    SelectionEmbeddingOptionsNameCaption

    Set the Name and Caption of our embedding to ‘Unordered List ‘

    Style offers 5 alternate styles of selection embedding.

    SelectionEmbeddingOptionsStyles

    With Style 1 you are able to enter text for the Top, Bottom, Left and Right of your selection.

    • Text entered for left and right will be repeated for each line of your selection.
    • Text entered for Top and Bottom, will be added above and below your selection.

    SelectionEmbeddingOptionsStyle1

    In Style 2 you are able to enter text for the Top and Bottom of your selection.

    • Text entered for Top and Bottom, will be added above and below your selection .

    SelectionEmbeddingOptionsStyle2

    In Style 3 you are able to enter text for the Left and Right of your selection.

    • Text entered for Left and Right will be repeated for each line of your selection.

    SelectionEmbeddingOptionsStyle3

    In Style 4 things change a little:

    • The Top Text is moved to the Left of the Top line of your selection replacing the Left text from Style 3 and Style 1.
    • The Bottom text is moved to the Right of the Bottom line of your selection replacing the Right text from Style 3 and Style 1.
    • Note how text which will appear in the Bottom Left and Top Right sections, is copied in the screenshot from the appropriate Middle Line text.

    SelectionEmbeddingOptionsStyle4

    Style 5

    In Style 5

    SelectionEmbeddingOptionsStyle5

    Set the Style of our Selection Embedding to ‘Style 1’

    Text Options

    If you select a style with Left and Right Text (any style except Style 2) then the following set of options will be enabled

    SelectionEmbeddingOptionsLeftRight

    These options specify where you would like the Left and Right text to be placed relative to the selection they wrap. Experiment with these and see what a difference they can make to your Embeddings.

    In our case choose ‘Start of code’ and ‘End of code’ respectively.

    The last options allow you to enter TextCommands and StringProviders into your Embedding to produce numerous effects when the expansion happens.

    SelectionEmbeddingTextCommands

    We don’t need these options for our selection embedding, but it’s worth knowing they’re here.

    The last part of the configuration is the most important. You need to specify the various pieces of text that will surround your selection.

    You’re fully configured Selection Embedding, should look something like this:

    SelectionEmbeddingUnorderedListWithHighlights

    Click Ok, and you’re done.

    Once you have completed the previous steps, all you have to do is

    • Select your text
      SelectionEmbeddingSelectText
    • Hit your CodeRush\Refactor key and Select Unordered List from the Embedding menu.
      SelectionEmbeddingSelectOrderedList

    and CodeRush does the rest.

    As I’ve stated many times before. One of the best features of CodeRush is it’s extensibility. If the features don’t ship out of the box just the way you like them, you can adjust, configure and augment to your hearts content.

    Feel free to share any custom Selection Embedding ideas in the comments below.

    Selection Embedding with CodeRush

    Selection Embedding is one of those CodeRush features that doesn’t get a lot of mention, but it is extremely powerful.

    It provides the user with the ability to wrap some text (code, mark-up, comments) around some existing code already in place.

    Selection Embedding is available from your the Code section of your CodeRush SmartTag menu (As well as via several custom shortcuts)

    Each Selection Embedding is context sensitive, so that only those for the current document type are shown to you.

    Below is an example of the selection embeddings available from within the C# editor.

    SelectionEmbeddingCSharp

    These are produced when I highlight some text in the HTML editor.

    cSelectionEmbeddingHTML

    Selection Embeddings do not have to be picked from the SmartTag menu. As mentioned, some have associated shortcut keys.

    Try highlighting 1 or more lines of C# code and then …

    …pressing T causes your code will be wrapped in a try..catch..finally block.
    …pressing C causes your code will be wrapped in a try..catch block.
    …pressing F causes your code will be wrapped in a try..finally block.
    …pressing B or { causes your code will be wrapped in a brace (ie { and } ) block.
    …pressing ( or ) causes your code will be wrapped in parenthesis.
    …pressing R causes your code will be wrapped in a #region…#endregion block.
    …pressing U causes your code will be wrapped in a using block.
    …pressing W causes your code will be wrapped in a waitcursor block.

    Some of these are pretty simple wrapping effects. Others put CodeRush fields and text commands in place to enhance your experience further.

    Here the using embedding places your caret within the using expression so you can more easily fill it out.
    Additionally, when you press enter, your caret is moved to the bottom of the expression ready for further code.

    SelectionEmbeddingUsing

    Here CodeRush provides a specialized try..finally block…

    SelectionEmbeddingWaitCursor

    • Saves your current cursor
    • Sets your cursor to the WaitCursor.
    • Executes your original code.
    • Restores your cursor to it’s original state, regardless of the success of your code.

    This is all boiler-plate code, but it’s boiler-plate code you don’t have to write yourself. This reduces the chance of typos or, worse still, logic errors.

    As you can see, Selection Embedding can be a very powerful tool, providing you with boiler-plate code in a fraction of the time, with fewer keystrokes and reducing the chance for typewritten errors across the board.

    As with most CodeRush features, Selection Embedding is user extensible.

    In my next post, I’ll show you how to make your own Selection Embeddings.

    New CodeRush Plugin – SplitTag

    This is certainly one of the more simplistic plugin’s I’ve written, and yet it’s also one I use all the time.

    Imagine that you have the following fragment of HTML and you’d like to split it in half.

    SplitTagBefore

    • Simply place your caret where you’d like to split the tag.
    • Hit your CodeRush \ Refactor key

    SplitTagMenu

    • Select ‘Split Tag’ from the menu
    • … and CodeRush will break your single tag into 2 of the same type.

    SplitTagAfter

    This plugin can be particularly useful when creating <li> tags within various lists.

    CR_SplitTag

    Availability

    This plugin is available from either The Visual Studio Gallery or from GitHub

    The source is available on Github

    More Posts