Quick Visual Studio Tip – Delete to End of Line

There are tons of times where you want to delete from the right of your cursor, while preserving everything to the left of your cursor.

Today the most common way is to do SHIFT + END to highlight it all and then hit DEL, such as below.

endoflinedelete

However, there’s a way to delete to the end of the line by binding a keyboard shortcut to Edit.DeleteToEOL.  By default this is not bound to any keyboard shortcut, so you’ll have to pick one.

If you haven’t overrode a keyboard shortcut before, you can go to Tools => Options => Keyboard, and then type Edit.DeleteToEOL in the “Show commands containing” text box.  You can then type a keyboard

I removed all previous bindings to CTRL + L and bound Edit.DeleteToEOL to that, but you can pick whatever you want.

2017-05-29_14-37-42

Now when I hit CTRL + L it removes everything after my cursor, saving me some keyboard strokes.

endoflinedelete2

Hope this helps.

Quick xUnit Test Tip – Use xunit.methodDisplay to Clean Up Your Test Results

I recently discovered an xUnit configuration value that was super helpful, so thought I’d write up a quick blog post.

Out of the box, xUnit results look like this in Visual Studio Test Explorer:

xUnitBefore

 

About half of that is noise, specifically the namespace (xUnitDemo) and the class name (DrivingServiceIsValidAgeToDrive).  The namespace isn’t really relevant to the test, and the class name is already available as the parent node above all the tests.

Solution

A simple change to your app.config will make this much easier to read.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="xunit.methodDisplay" value="method"/>
  </appSettings>
</configuration>

 

Now when we run we get this:

xUnitAfter

Much cleaner.

 

As an aside.  I prefer the naming convention of:

  • Test Class Name: <ClassYou’reTesting><MethodYou’reTesting>
    • Example above, DrivingService is the class and IsValidAgeToDrive is the method
  • Test Method Name: Does<Something>_Given<Scenario>
    • Example above, DoesReturnTrue_GivenAgeIs16OrOlder

 

I’ve found this helps make it crystal clear what you’re testing.  As a bonus, it makes it fairly easy to show the names to a BA/Stakeholder to make sure you’re covering all their scenarios.

Glyphfriend lost font intellisense fix

I use the Glyphfriend extension which gives you intellisense for a bunch of font based libraries (such as Font Awesome, Glyphicons and others) and it gives you preview of the icon as you type.  I highly recommend it.  It looks like this:

fontawesome

This is extremely helpful, and allows me to avoid going to FontAwesome’s site to search for an icon I need, but for some reason it went away in one of my projects, and all I got was the font awesome icons I’ve used throughout the project, which looked like this:

fontawesomebroken

The Solution

Turns out someone deleted the non-minified file from the project in an effort to clean up the project.  Adding the full non-minified file back to the project brought my Glyphfriend intellisense preview back and all was right with the world.  Hope this helps someone else.

 

UPDATE: 1/18/2017 – It looks like with Glyphfriend 2.0 this no longer happens.  They acknowledged this limitation  (#1 under “limitations” in this post) and “fixed” this where the icons are compiled at build time and not evaluated at runtime.  Looks awesome.