Mark Miller
  • CodeRush Screenshot of the Week – Test Runner Goodness

    This week’s screenshot, submitted by CodeRush customer Casey Kramer, who likes the CodeRush Test Runner:

    Unit Test Window in Happy TDD Land_CaseyKramer

    Casey says: "I dig the unit test runner, and I do TDD whenever I can….here is a view in the “Red” stage of the Red-Green-Refactor cycle.  The graphic elements on the tests themselves are nice too."

    Congratulations, Casey. Your t-shirt is in the mail!

    Seen something cool in CodeRush? Take a screenshot and send it to me (markm at the DevExpress domain). If we use your image we’ll send you one of these highly coveted CodeRush Nation t-shirts.

    CodeRush Nation t-shirt

  • CodeRush Screenshot of the Week – Adding Contracts to Methods

    This week’s screenshot, submitted by CodeRush customer Jeff Forrett, who’s a big fan of adding method contracts quickly:

    Generating Null Exceptions in CodeRush

    Jeff says: "Saving time by generating null exceptions, I like it."

    Congratulations, Jeff. Your t-shirt is in the mail!

    Jeff’s screenshot has inspired us to reveal a sneak preview of more chunky goodness, support for .NET 4.0 contracts, coming in CodeRush 10.2:

    CodeRush_Add_Contract

    Seen something cool in CodeRush? Take a screenshot and send it to me (markm at the DevExpress domain). If we use your image we’ll send you one of these highly coveted CodeRush Nation t-shirts.

    CodeRush Nation t-shirt

  • CodeRush Screenshot of the Week

    One of the things I love about CodeRush is there’s so much depth that sometimes even I forget what we put in there. Here’s an example of a feature I discussed with the devs a while back, but didn’t need until moments ago: Create Event Trigger

    With the caret on an event declaration, press the CodeRush/Refactor! key (Ctrl+` by default).

    CreateEventTrigger

    I love it when a plan comes together. :-)

    Seen something amazing in CodeRush? Take a screenshot and send it to me (markm at the DevExpress domain). If we use your photo we’ll send you a killer CodeRush Nation t-shirt.

    CodeRush Nation t-shirt

  • Interesting CodeRush Blog Series

    CodeRush user Jason Follas has started an interesting blog series on CodeRush; interesting because Jason talks about essential and important CodeRush features from his perspective. So far in the series Jason discusses:

    Great work, Jason! Looking forward to see what else you have in store for us.

     

     

  • Working with Color in CodeRush

    Working with color in source code has never been as easy or intuitive as it should be. Looking at hex values or a color name like Bisque and then trying to imagine what that color looks like is a challenge. Finding the correct color to use in a new style in a CSS file is also challenging.

    Furthermore, going from color to code is rarely a picnic.

    Fortunately, CodeRush 10.1 brings developers much closer to the real colors with new Color features. In this post I’ll discuss CodeRush features for working with color, both new and old.

    Generating Color Declarations from HTML

    This Intelligent Paste feature has been around for years. Simply copy an HTML color declaration (e.g., “#4B70BC”) and paste that inside a C# or VB file inside a method, property accessor, or inside a type (but not in a member) on an empty line, and you’ll get something like this (C# example shown):

    ShowColorSmartPaste

    This intelligent paste will create a local variable or a field, depending upon where you paste. As with all Intelligent Paste operations, you can press Undo to get the literal contents of the clipboard if you don’t like the CodeRush version. All Intelligent Paste operations are defined on the Intelligent Paste options page. Follow these steps to get there if you want to see them all:

    1. From the DevExpress menu, select "Options...".
    2. In the tree view on the left, navigate to this folder: Editor\Clipboard
    3. Select the "Intelligent Paste" options page.

    Note: This page level is Advanced, and will only be visible if the Level combo on the lower-left of the Options dialog is set to Advanced or Expert.

    Working with Color Declarations from Templates

    When working with color from templates, the mnemonic to remember is “CL”.

    Normally (without CodeRush), if I want to bring up a list of named colors using Intellisense, I have to type in “Color.”. With CodeRush installed, I can now simply type “CL” (lower case is fine) followed by the space bar to expand the template, and this is important: the caret must be at a location where a Color expression is valid (so not on an empty line but instead as a parameter to a method or an assignment to a variable or a property. Also, the active project must have a reference to System.Drawing or System.Windows.Media (CodeRush will add the appropriate namespace reference to the source file if needed).

    If you need a color from the SystemColors class, expand the “SYC” template (again, lowercase is fine, but for clarity I like to specify templates using uppercase letters).

    Back to that CL mnemonic. You can combine this shortcut with other CodeRush code templates that work with types. For example, MCL will generate a method that returns a Color, VCL will create a variable declaration (local, parameter, or field) of type Color, and ACL will generate an auto-implemented property of type Color. There are also PCL (for properties of type Color with backing store) and NCL for newly-initialized variables of type Color.  And there is “CL.E” for Color.Empty.

    Try these in a project that references System.Drawing or System.Windows.Media.

    Color Swatches in the Code

    Remember that color declaration we generated at the top of this post when I pasted a color reference into the code? You probably noticed that bluish rectangle under the word Color. Here’s that screen shot again:

    ShowColorSmartPaste

    And here’s a variation with different values:

    ColorSwatch

    Those rectangles appearing below the Color type reference are color swatches. These are very cool. Now you no longer have to reverse engineer RGB color values in your head to figure out exactly what color you’re looking at in the code.

    NamedColorSwatches

    The CodeRush Color Dialog

    So what happens when you want to edit a color in the code? Good news: just click the color swatch with the mouse and up pops the CodeRush Color dialog, which looks like this:

    ColorPickerAppears

    The CodeRush Color dialog consists of several pages, which we’ll examine in a moment. At the bottom of the CodeRush Color dialog is a sample color swatch which reveals the selected color, and to the right of the sample is a Favorites button. FavoritesButton

    We’ll talk more about the cool things you can do with favorite colors in a moment. But first, let’s take a look at the pages.

    The Color Picker

    The “Picker” page, the one you see in the screen shot above, is perhaps the most weighty. If you need to pick a color based on hue, saturation, brightness, red, green, or blue, you can do it here. You can also set opacity, enter an HTML color (including shorthand for web-safe colors such as “369”), and change a selected color to it’s nearest web-safe neighbor. And you can select a color from an existing image or window appearing on your desktop by clicking the eye-dropper tool. EyeDropper

    When working with color, you can use one of two mechanisms: red, green, & blue or hue, saturation & brightness (RGB and HSB). You may prefer to work with HSB on the Picker page since these attributes make it easy to change the brightness or the saturation without modifying the hue, which can produce nice color variations like this:

    Variations

    or this:

    Variations2

    Keeping most of the UI colors in the same hue is useful for reducing visual noise in a user interface.

    Regardless of which of the two mechanisms you choose to work in, specifying a color on this page is always a convergence of three values. I like to visualize this as a cube which holds all colors. If I’m working in RGB, the dimensions of that cube are 256x256x256.

    Here’s an example of a three-dimensional arrangement of colors organized by saturation (width), brightness (height), and hue (depth):

    ColorCube

    So to specify a color in this three-dimensional space the Picker page gives you a two-dimensional grid, like this:

    TwoDimensionalGrid

    and a one-dimensional vertical gradient, like this:

    OneDimensionalGrid

    These two controls work together to let you specify any color in this three-dimensional space. The vertical gradient allows you to select any plane in this space, and two-dimensional grid lets you select a color on that plane.

    The vertical gradient is useful when you want to isolate one of the three attributes of the cube you’re working with onto a single dimension, allowing adjustments to only one value while keeping the other two attributes static.

    To isolate an attribute just click its corresponding radio button on this page.

    For example, to isolate the Saturation attribute, click the “Sat:” radio button.

     BySaturation

    Notice the labels on the two-dimensional grid have changed to show Brightness on the vertical axis and Hue on the horizontal axis.

    Isolating the Brightness attribute looks like this:

    ByBrightness

    Things get interesting when you isolate one of the RGB channels. For example, here’s Red:

    ByRed

    Here you can see where the color will go as you increase or decrease the RGB values.

    Here’s what it looks like when you isolate the Green channel:

    ByGreen

    And for completeness, here’s what it looks like when you isolate the Blue channel:

    ByBlue

    If you need a color from the desktop, click the Eyedropper button EyeDropper and then click on the color you want. A sample of the color under the eyedropper will appear below the button, and to the right you’ll see a magnified portion of the screen with a rectangle in the center representing the eyedropper position.

    PickColor

    If we’re working with a color that isn’t web safe, the “Make Web Safe” button will be enabled. Clicking it will to take the selected color to its nearest web-safe neighbor, like this:

     WebSafeNow

    Right above the Make Web Safe button is the hex edit control, useful for copying or pasting hex triplet representations of color (for example, “B6005A”). You can also use a three-digit shorthand when representing web safe colors, for example enter “369” in the hex edit control and you’ll get this:

    WebSafeShorthand

    Which is shorthand for #336699.

    Web Colors

    Speaking of web-safe colors, let’s switch to the Web page, where you can select from all 216 web-safe colors:

    WebSafeColors

    Named Colors

    Here’s the Named page for .NET colors based on the X11 color names:

    NamedColors

    System Colors

    SystemColors

    Document Colors

    The Document page shows all the colors defined in the active document (before taking this screen shot I opened a C# class which defined many colors):

    DocumentColors

    Favorite Colors

    And finally, we have the Favorites page, which might initially look like this:

    Favorites

    The favorites page holds favorite colors in groups called palettes.

    There are three interesting buttons on the top row of this page:

    DeleteSelectedColor Delete Selected Color
    DeleteActivePalette Delete Active Palette
    CreateNewPalette Create New Palette

    You can rename the active palette simply by typing in a new name in the combo box at the top of the dialog (press Enter to commit the change or Escape to cancel). For example, let’s rename this palette to “My Faves”, like this:

    MyFaves

    Press Enter to commit the change, or you can commit the rename by simply moving focus away to another control.

    At the bottom of the CodeRush Color dialog, to the right of the color sample, sits the Favorites button. FavoritesButton

    If you click the button, the sample color will be added to the active palette page.

    AddFavorite

    Let’s add another color to this page. Click on the Named color tab, select DarkOrange:

    DarkOrange

    Then click the Favorite button, and watch what happens under the mouse:

    ReturnButtonBig

    The Favorites button changes to a Return button, so a single click on this can get you right back to the page you started from. This makes it easy to add several favorite colors from anywhere in the CodeRush Color window.

    There’s one more cool thing you can do with favorite colors. To demonstrate, let’s create a new palette page. Click the Create New Palette button. CreateNewPalette

    Now let’s go to the Picker page and find a favorite color, like this:

    DevExpressBlue

    For this demo I’m grabbing the DevExpress blue from the web site using the Eyedropper.

    Now, right-click the Favorite button and select Add Color Distribution, then click the number of colors of varying lightness you want to add in the same hue as this color. I’ll select 21.

    AddColorDistribution

    Which generates 21 colors based on the selected color, like this:

    DevExpressColorDistribution

    Generating the Color Reference

    Once you have the color you want, just click the OK button and the active color reference will be replaced with a reference to the color selected. Here’s the DevExpress blue placed in a C# file after clicking OK:

    DevExpressColorInCode

    Oh, and if you’re still wondering what Bisque looks like, here it is:

      ColorBisque

    We hope you enjoy the CodeRush features that make working with color easier. As always, let us know what we can do to improve your development experience.

  • CodeRush Xpress & CodeRush Ready for Visual Studio 2010

    Both CodeRush Xpress and CodeRush have been released this week. CodeRush Xpress went final and became available only a few seconds after Visual Studio 2010 became officially released.

    The full version of CodeRush 10.1 is available on the Betas tab of your client center download page.

    While CodeRush Xpress is final, the full version of CodeRush 10.1 is expected to be final by the end of April when the rest of DXperience 10.1 ships.

  • Spend a Day with Miller in Vegas! (Free CodeRush Training)

    Hey kids,

    Ever wish you could spend the day with your good old buddy Mark Miller in a Las Vegas training room?

     MillerHangingOut

    Just sitting back, shooting the breeze and talking about whatever CodeRush thing is on your mind? Well the good folks at DevExpress are working hard to make your dream come true. :-)

    That’s right, kids. DevExpress is putting together a full day’s worth of formal CodeRush training, tentatively scheduled for Thursday the 15th of April, the day after the DevConnections conference and the official launch of Visual Studio 2010 in Las Vegas. And like the title of this blog post reads, this training session will be 100% free.

    Not only will it be free, but DevExpress will also be giving away prizes, we’ll hear from a special guest speaker from the Visual Studio team at Microsoft, and there’ll be some yummy food to eat. All courtesy of DevExpress. It’s crazy I tell you. Absolutely crazy. :-)

    As for content, we’ll start off the morning talking about CodeRush Xpress, then we’ll move into the more powerful features of the full version of CodeRush, wrapping up with extensibility, showing how to radically customize your IDE. The course content will look something like this:

    • CodeRush Xpress
      • Navigation
      • Selection
      • Clipboard Features
      • Declaration from Usage
      • Refactoring
      • Performance/Memory Comparison
    • CodeRush
      • Selection Embedding
      • Other Productivity Features
        • Intellassist
        • Auto Declare
        • Smart Semi-Colon
        • Smart Parens
      • Templates
      • Code Issues
      • Test Runner
      • More Code Providers
      • More Clipboard Features
      • More Refactorings
      • Other Language Features
        • ASP.NET
        • XAML
        • JavaScript
        • etc.
      • Extensibility
        • Third Party Plug-ins
        • Introduction – Creating a Simple Plug-in
        • Creating Refactorings
        • Creating Code Providers
        • Creating Code Issues

    So what’s the catch, you ask? It’s simple. We need to get a sense of how many people will show up, and we need to know very soon so we can book a room big enough to hold everyone. If this event sounds like your kind of fun and you can make it to Vegas in April, post a comment below to let us know of your intentions to be there. I expect that soon we’ll create a registration page so you can lock in your spot, and when that’s page is available we’ll let you know through blogs, tweeting, shouting and otherwise general mayhem.

  • Slicing and Dicing Strings with CodeRush for Visual Studio

    CodeRush brings powerful string manipulation features to Visual Studio. Here are a few of my favorites:

    Splitting Strings

    When you need to break a string literal into two or three pieces. For example, let’s start with the following text:

     

    public string GetGreetingText(int daysLeft)
    {
      return "Welcome back, customer. \nSo glad to see you. Days remaining on our special offer: " + daysLeft.ToString();
    }

    I can place the caret (the flashing I-beam that marks the editor’s insertion point) right before “Days remaining” text and press the CodeRush/Refactor! key (Ctrl+` by default) and then choose Split String.

    SplitStringInto2

    This will split the string into two pieces.

    Next, let’s select the last two expressions on this line:

    SelectLastExpression

    Press the CodeRush/Refactor! key, and choose Extract Method to create a new method called GetDaysRemaining, like this:

    GetDaysRemaining

    Use String.Format

    Next, move the caret down inside the string inside the GetDaysRemaining method. Press the CodeRush/Refactor! key and select Use String.Format.

    UseStringFormat

    This neatly combines the concatenation into a single string that is easy to read and so much easier to translate (translating string fragments is much harder to do when grammatical rearrangements are needed as part of the localization).

    Speaking of translation…

    Extract String to Resource

    Move the caret inside the “Days remaining…” string. Press the CodeRush/Refactor! key and select Extract String to Resource, then select “Create new resource file”.

    ExtractStringToResource

    CodeRush will create a new resource file to hold this string, and highlight the resource identifier for an easy rename (tip: I like to use Camel Case Nav and Camel Case Select – Alt plus Left or Right arrow keys with Shift to select -- to quickly trim a long identifier down to a reasonable size). Let’s call this resource “DaysRemaining”.

    DaysRemainingResource

    Placing strings in resource files is a good first step to preparing your code for translation.

    Splitting Strings, Revisited

    The CodeRush Split String refactoring has a bonus feature built in: the ability to split a string into three pieces. Just select the portion of the string that you want to pull out and apply the refactoring. For example, in the code above, there is a “\n” appearing inside the string. This “\n” may be confusing to translators, it makes the string harder to read, and it may not be the most appropriate way to terminate lines on some platforms, so let’s take it out and replace it with the Environment.NewLine expression.

    First, select the “\n”:

    SelectSlashN

    Press the CodeRush/Refactor! key and select Split String

    ApplySplitStringIntoThree

    Applying the refactoring will leave you with this:

    SplitStringInto2Applied

    Notice the “\n” string fragment is selected for easy editing. Now we can use CodeRush’s “enl” template to replace the “\n” with a proper Environment.NewLine expression.

    AfterEnvironmentNewLine

    Introduce Format Item

    See that “Welcome back, customer.” string in the code above? It would be great if we could actually pass in the customer’s name in place of the text “customer”. That would make the greeting certainly more personal. It’s easy to do this with CodeRush. Just select the part of the string that you want to replace, and press the CodeRush/Refactor! key, like this:

    IntroduceFormatItemPreviewHint

    Apply the Introduce Format Item refactoring to get this:

    AppliedIntroduceFormatItem

    Notice that once again the extracted string is selected for easy editing. Now let’s promote this string to a parameter. Press the CodeRush/Refactor! key and select Promote to Parameter.

    PromoteToParameter

    And give the new parameter a meaningful name, like customerName:

    PromoteToParameterAfterRename

    Converting Text to Strings

    Sometimes you need to work with a text coming from another environment, and that text span several lines or contain quote characters (that would need to be escaped). So in this example I used the “ms” template to create a method that returns a string, and I expanded the “r” template to get the return keyword and then I pasted in some XAML code that creates a TextBlock:

    private string GetTextBlock()
    {
      return <TextBlock
      Canvas.Left="25" Canvas.Top="5"
     
    Foreground="Teal" FontFamily="Verdana" FontSize="18" FontWeight="Bold"
     
    Text="Sample Output" />;
    }

    Of course this code will not compile. Fortunately we have CodeRush installed so getting it into its desired shape is easy. Just select the text we want to convert, press the CodeRush/Refactor! key and select Embed Selection | To string, like this:

    EmbedString

    CodeRush will convert the text into a string, like this:

    ConvertToString

    Nice. Notice how the quotes are properly escaped and the separate lines are now concatenated together.

    Now, suppose you wanted to parameterize some of the values in this string. For example, turn the “Sample Output” into a “text” parameter. How would you do that? Well, you should already know how. Just select the text, split the string, and promote it to a parameter.

    Wrapping Up

    If you’re not already using CodeRush, you should be. This post has covered only a portion of the tools and features that work with strings, and working with strings is only a very small tip of the very large iceberg of power that is CodeRush. CodeRush is the fastest, most powerful, and most memory-efficient developer productivity add-on available for Visual Studio.

  • The Extensible Test Runner You’ve Been Waiting For

    We’ve been hard at work fine-tuning the CodeRush Test Runner, and we’re getting excited.

    This screen shot contains a few clues as to why we’re so pumped up:

     FirstShot

    We’re pleased with the UI. Notice in the screen shot above how failing tests are easy to spot while the less-important information is rendered in a lower contrast that’s easy on the eyes. Also, we’ve done some work on the tree list to reduce the number of clicks needed to get to tests of interest. And there’s a handy filter text box at the top.

    So it looks pretty. But more importantly, the Test Runner supports all the popular testing frameworks right out of the box, including VSTest, NUnit (including different flavors mixed in with various extensions), and the oft-neglected xUnit and MbUnit. The screen shot above is taken from a solution that includes test cases for all of these frameworks.

    CodeRush customers will also receive full source code to the plug-ins we ship that provide all this luscious unit testing support. So if you want to extend support for any of these unit test frameworks, it’s easy. Or if you want to add support for a brand new unit testing framework, you all have the sample code you need to get started. That is cool.

    Test results also appear in the code:

     TestStatus

    You can run test cases from the Test Runner, or from the code itself by clicking one of the Test Runner icons that appear next to the unit test attributes (as shown in the screen shot above).

    The Test Runner debuts in CodeRush 9.3 (beta is internal testing and will available soon if not already by the time you read this). I’ll be showing the Test Runner at PDC in Los Angeles this week, so if you’re in LA stop by our booth and check it out.

  • Here's a Picture Worth 1000 Words...

    Derek Reynolds says it all with a single screen shot.

2 3 4 5 6
7
8 9 10 11
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