Mark Miller

October 2008 - Posts

  • Announcing CodeRush Xpress for C#

    Developer Express and Microsoft are proud to announce a new version of CodeRush licensed exclusively for C# developers working in Visual Studio. The new product is called CodeRush Xpress, and it includes a fresh selection of hand-picked features taken from CodeRush and Refactor! Pro.

    Here's a sampling of what you get:

    Find any File or Symbol...

    Go to any file or symbol in the solution efficiently.

    Quick File Navigation

    Type in a few letters of the name to filter...

    Quick File Navigation-call

    Or hold down the shift key to filter only on uppercase letters...

    Quick File Navigation-R

    Uppercase characters can appear anywhere. Any uppercase characters not specified in the filter are highlighted in blue...

    Quick File Navigation-RC

    The uppercase letters need not be sequential. Notice how "RD" in the screen shot below matches both "ResolveDelegate.cs" and "ResolveCallbackDelegate.cs"

    Quick File Navigation-RD  

    Tab to Next Reference

    This is a really cool navigation feature that takes you to the next (and previous) reference just by pressing the Tab key (or Shift+Tab key to go backwards) when the caret is inside an identifier, member, or a type. For example, in the following code, the caret was inside the last Person type reference (in the "new Person()" instantiation call) when the Tab key was pressed, causing the Person reference at the top of the file to become highlighted.

    TabToNextReference

    Expand/Shrink Selection

    This feature allows you to increase a selection by logical blocks, or decrease an expanded selection by the same logical blocks. This feature is perfect when refactoring, since many refactorings work on a contiguous selection of code (e.g., extract method, introduce local, etc.).

    TDD-Style Intelligent Declaration Based on Usage

    Place the caret on any undeclared element in your code and press the Refactor/Code key (Ctrl+`) to see list of intelligent suggestions for the type of the new variable. For example, in the screen shot below two appropriate types are suggested, even though Console.WriteLine has many overloads that accept a wide variety of types.

    DeclareLocalTwoOptions

    You can even turn a function call or property access into a variable declaration.

    DeclareLocalOnProperty

    This makes writing code with Visual Studio's Intellisense really fast. Just use Intellisense to produce the property reference or function call, and then press the Refactor/Code key to declare a new local variable of the appropriate type. Here's an example with a function call -- notice the caret can be just about anywhere on the function call, even at the end of the line.

    DeclareLocalOnFunction

    You can even declare a local from a simple instantiation, like this:

    DeclareLocalNewPerson

    And it's worth noting you can declare all kinds of elements based on usage, not just locals. Anything you need types, members, fields -- the full list of elements that can be declared appears below.

    Professional Grade Refactorings

    CodeRush Xpress includes many powerful refactorings to help improve the quality of your code. For example, consider the following:

        private static void ShowInt(int n)
        {
         
    Console.WriteLine(n);
        }
       
    private static void ShowEntries(List<int> entries)
        {
          entries.ForEach((
    Action<int>)ShowInt);
        }

    With the caret on the ShowInt method reference, you can press the Refactor! key...

    InlineDelegate 

    and then select Inline Delegate. This will produce the following code:

        private static void ShowEntries(List<int> entries)
        {
          entries.ForEach(
    delegate(int n)
                          {
                           
    Console.WriteLine(n);
                          });
        }

    Notice the caret is on the delegate keyword. You can immediately press the Refactor! key again...

    CompressToLambdaExpression

    Note that we can go in two directions now. We can either convert the anonymous method to a named method (in essence reversing the Inline Delegate refactoring we just performed), or we can take it a step further and compress the anonymous method into a lambda expression. Choosing Compress to Lambda Expression, we get the following:

        private static void ShowEntries(List<int> entries)
        {
          entries.ForEach(n =>
    Console.WriteLine(n));
        }

    CodeRush Xpress is loaded with powerful refactorings taken from Refactor! Pro. One of our favorites, Extract Method to Type, allows you to extract a method from one type into another, updating both the calling code and the extracted method appropriately. For an example, consider the following code:

      class Person
      {
        public string Name { get; set; }
        public bool IsAnOrphan { get; set; }
        public Person Mother { get; set; }
        public Person Father { get; set; }
      }
    // ...
      class BabyMaker
      {
        public Person MakeOne(Person mother, Person father, string name)
        {
          Person newBaby = new Person();
          newBaby.Name = name;
          newBaby.Mother = mother;
          newBaby.Father = father;
          newBaby.IsAnOrphan = newBaby.Mother == null && newBaby.Father == null;
          return newBaby;
        }
      }

    Notice that the code in the MakeOne method contains a local variable that's an instance of type Person, and that code sets the IsAnOrphan property. There is some logic in this method that pertains to Person, but it feels like it's in the wrong class!

    We already have the class Person in our solution, so it makes sense to move some of this code to the proper class. With CoderRush Xpress installed, all we need to do is select the code we want to move....

    SelectCodeToExtract 

    Press the Refactor key...

     ExtractMethodToPerson3

    And choose "Extract Method to Person". CodeRush Xpress analyzes the selection and determines there's at least one local variable of a type you have declared elsewhere in the solution. Now let's apply this refactoring...

     TargetPicker2

    Press the Up and/or Down arrow keys to select a location for this new method, and press Enter to commit. Give the method a meaningful name...

    SetParents

    Cool. Now we have the logic (that should have been inside Person to start with) right where it belongs. Notice how the new SetParents instance method works on the instance itself (compare that code with the original code that operated on the newBaby local). The code is easier to read and cleaner in both locations.

    Notice also that tiny dark blue triangle, in the code above. That's a stack-based marker, and CodeRush Xpress drops markers automatically whenever you apply a refactoring or TDD-style declaration that takes you away from the original location. You can jump back at any time to the top marker on the stack by pressing Escape.

    There are many more refactorings and cool features in CodeRush Xpress. This is just a preview. Here's the full list of what you get:

    Editor Features

    • Duplicate Line
    • Highlight Usages
    • Clipboard Features
      • Smart Cut/Copy
      • Paste Replace
    • Enhanced Selection Abilities
      • Extend/reduce selection
      • Camel-case selection

    Navigation Features

    • Camel-case Navigation
    • Tab to Next Reference
    • Go to File
    • Go to Symbol (QuickNav)

    TDD - Declaration from Usage

    • Types
      • Declare Class
      • Declare Delegate
      • Declare Enum
      • Declare Enum Element
      • Declare Interface
      • Declare Struct
    • Members
      • Declare Constructor
      • Declare Event Handler
      • Declare Getter
      • Declare Method
      • Declare Property
      • Declare Property (auto-implemented)
      • Declare Property (with backing field)
      • Declare Setter
    • Variables
      • Declare Field
      • Declare Local
      • Declare Local (implicit)

    Refactorings

    • Add/Remove Block Delimiters
    • Combine Conditionals (merge nested "If" statements)
    • Compress to Lambda Expression
    • Compress to Ternary Expression
    • Convert to Auto-implemented Property
    • Convert to Initializer (use object/collection initialize when possible)
    • Create Backing Store (converts Auto-implemented Property to standard Property with get and set)
    • Decompose Initializer
    • Decompose Parameter
    • Expand Lambda Expression
    • Expand Ternary Expression
    • Extract Method to Type
    • Flatten Conditional
    • Introduce Local (introduce variable)
    • Inline Delegate
    • Inline Temp (inline variable)
    • Make Explicit
    • Make Implicit
    • Move Type to File
    • Name Anonymous Method
    • Name Anonymous Type
    • Reverse Conditional (invert "if")
    • Split Conditional (split complex "If" statements)
    • Use StringBuilder
    • Use String.Format
  • If there's one thing you see at PDC...

    If there's one thing you see, one place you want to be... this is it.

    Time: Monday night, 6:55pm

    Place: PDC. Exhibition hall. The Oversized 30x30 DevExpress booth.

    At this time and place, DevExpress will be showing quite likely the most amazing thing ever presented at any technical conference ever (if not the most amazing thing anyone has ever seen or will ever see in the entire history and future of humanity). And that's an understatement. I haven't even begun to raise expectations yet.

    I'm not kidding.

    This will be the event that everyone will be blogging about and talking about. If you're there, you'll be among those who will speak with authority. If you're not, well, I don't even want to look at your face anymore.

    Seriously.

    Now, back to work on cloning my new assistant for the demo....

  • Think I'm Starting a Trend

    Looks like Julian has started to fancy my new Mr. Clean look.

LIVE CHAT

Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

FOLLOW US

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

Copyright © 1998-2017 Developer Express Inc.
All trademarks or registered trademarks are property of their respective owners