.Net, Visual Studio, VS2017

VS 2017 Structure Visualizer

After installation of Visual Studio 2017, you probably noticed some vertical dotted lines.  Many people find them annoying and want to remove them.  At the end at this article I’ll show you how you can disable this feature but first I’d like to tell you how this new feature can be beneficial to you.

It’s not hard to figure out that these lines are lining up with structured code blocks.  It allows you quickly figure out the code scopes.  The biggest benefit you get when you hover over the line.  It allows you easily see namespace, class, method, and other code blocks without the need to scroll.  I’ve been using a lot Ctrl+] to jump between difference braces in Visual Studio.  Now I just need to hover over the line and see the scope of the code at a glance.

StructureVisualizer

If you think you like this feature but don’t use VS 2017 yet, you can install Productivity Power Tools for VS 2015 or VS 2013.

Ideally, you write your code in such manner that each code block can be easily seen on a single screen.  Even if you succeed to write the code nice and concise, the need to read someone else code will arise in your career and this feature might be helpful you.

Disable this feature.

If you still believe that this new feature is not going to help you, then you can disable it by going to Tools > Options > Text Editor and uncheck “Show structure guide lines”.

Disable structure guilde lines

In case you like this feature but you want the guide lines to be less or more prominent you can go Tools > Options > Environment > Fonts and Colors.  In “Display items” select box choose “Structure Guide Lines” option and pick the color that suits you best.

Modify structure guilde lines

I hope you find this article and this new feature useful.

Advertisements
FxCop, Visual Studio, VS2008

Integrate FxCop 1.36 & VS 2008

Update: Visual Studio Team System (VSTS) has Code Analysis feature.  It’s not FxCop but it does serve the same purpose and is built using the same engine as FxCop.  Unfortunately I’m working with VS Professional that doesn’t include Code Analysis.

FxCopI was looking for way to integrate FxCop 1.36 with Visual Studio   2008.  I even asked the same question on StackOverflow.  The only answer I got was a link to MSDN article.  I follow direction in the article but wasn’t successful.  I assume that if you have only one project and don’t have a solution it will work for you but it’s not my case.  I have many project in my solution.  However, the MSDN article got me going.  Let me present you my solution of integration.

Create FxCop project using FxCop GUI.

Important:
– Save the project file in the same directory where your solution is.
– Project name must be the file name of your solution (including .sln extension).  For example: If your solution file is MySolution.sln, the FxCop project name must be MySolution.sln.FxCop.

FxCop - Name project

Add FxCop to VS External Tools.

In Visual Studio select Tools->External Tools…  You should see the External Tools dialog box.

You must fill following fields:

Title: FxCop
Command: C:\Program Files\Microsoft FxCop 1.36\FxCopCmd.exe
Arguments: /c /p:"$(SolutionDir)\$(SolutionFileName).fxcop" /cXsl:"C:\Program Files\Microsoft FxCop 1.36\Xml\VSConsoleOutput.xsl"
Initial Directory: C:\Program Files\Microsoft FxCop 1.36
Use output window Must be checked

If you install FxCop in different location than C:\Program Files\Microsoft FxCop 1.36, you need to use your own path.

FxCop-ExternalTools

In case you want to grok the switches we use, you can read more about FxCopCmd options.

Run FxCop from Visual Studio.

We are done.  Now we just need to run FxCop.

Tools –> FxCop should analyze your code and because we checked “Use Output window” in External Tools dialog result should appear in VS output window.

FxCop - result

kick it on DotNetKicks.com

Tips And Tricks, Visual Studio, VS2010 CTP

Copy & Paste is broken in Visual Studio 2010 CTP

I was astonished when I realized that copying & pasting a line in VS 2010 doesn’t works the same as in previous versions of Visual Studio.  I wasC_Key blogging more than a year ago about wonderful feature how to copy and paste in Visual Studio.

In previous versions you can copy a line by moving cursor anywhere on a line you want to copy and without selecting anything press Ctrl-C.  Then you can paste that  line anywhere by pressing Ctrl-V.  The line will be inserted above the line where the cursor is without breaking that line.

However, in VS 2010 CTP the same technique will not work despite that option to turn this feature on/off exists in Options dialog.  Just open this dialog by selecting Tools/Options and then select Text Editor/All Languages.  ‘Apply Cut or Copy commands to blank lines when there is no selection’ check box should be checked by default.

2010_Option_Copy_Paste

Actually in previous VS version I notice the same broken behavior with XAML files.

I really hope that Microsoft will make copy & paste work as before.  I’m so used to move line up or down with Ctrl-C and Ctrl-V keys.

kick it on DotNetKicks.com

CTP, Visual Studio

Problem installing VS 2010 & .NET 4.0 CTP

I thought it’s time for me to follow everyone and install Visual Studio 2010.  Microsoft provides us with Virtual PC image that includes Visual Studio 2010 and .NET Framework 4.0.  So I downloaded all 11 parts, each of them is 700 MB except the last 11th part which is 286 MB.

I’m at the next point to extract the virtual machine image.  I eagerly click on Accept button at the EULA screen.  Few minutes later I see the following error when it gets to part 2:

“Write error in the file VisualStudio2010CTP.vhd. Probably the disk is full”

VS2010CTP_error

After making sure that I have enough disk space, I Google.  I was very disappointed that this time so reliable Google fail me.

I was able to figure out the problem few minutes later.  The Virtual Machine hard drive image is 23Gb.  I tried to extract it to my external hard drive  that was formatted as FAT32.  The biggest file on FAT32 file system you can have is 4Gb.

So if you encounter the same error just extract the image to hard drive with NTFS file system.

Tips And Tricks, Visual Studio, VS2005, VS2008

Incremental search in Visual Studio

When you’re writing code in VS environment, I bet that you often use Ctrl+F keystroke to display “Find and Replace” dialog box.

There’s a better way.  Next time you need to look for some text in your code, press Ctrl+I and start typing your search.  After the text is found, you can use F3 key to find a next occurrence.

As soon as you press Ctrl+I, you’ll see “Incremental Search:” labelIncrementalSearch on the left part of VS status bar.  Your search text will appear on the status bar as you type it.  If you mistype your search text, you can use Backspace key to correct wrong characters.

kick it on DotNetKicks.com

.Net, Coding, ReSharper, Tips And Tricks, Visual Studio

Shortcut Key to Comment code in VS and SQL Server Management Studio

When we learn any programming language, one of the firsCtrl+Ct thing  we discover is the syntax how to comment our code.  Some of you probably already have been using this shortcut key for awhile.

Select multiple lines of code and press Ctrl+K,Ctrl+C, and you hard work is going to be ignored. To reverse just press Ctrl+K,Ctrl+U

These keystrokes will comment/uncomment your code only with line comment like // in C# or — in SQL.  I’m not aware how to comment code with block comment (/**/) without using a plug-in for VS.

One more thing.  If you need to comment/uncomment a single line, you don’t need to select the whole line.  Just move the cursor to any position on the line you want to comment, and let you fingers press the magic combination.

If you like me (there’s nothing wrong to be different from me) and use ReSharper, than you would like to use Ctrl+Alt+/ with line comment and Ctrl+Shift+/ with block comment.

kick it on DotNetKicks.com