Finally VS 2010 RC is out. It’s available to MSDN subscribers today, February 8th. Everybody else will be able to download it on February 10th.
Archive for the ‘Visual Studio’ Category
Posted by Vadim on February 8, 2010
Posted by Vadim on May 9, 2009
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.
I 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.
– 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.
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:
|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.
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.
Posted by Vadim on November 9, 2008
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 was 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.
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.
Posted by Vadim on November 9, 2008
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”
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.
Posted by Vadim on October 18, 2008
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:” label 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.
Posted by Vadim on October 16, 2008
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.
Posted by Vadim on July 9, 2008
Have you ever scroll, scroll, scroll to find the beginning of if else statement? In this post I’m not going to tell you that long methods and classes are evil. Instead, I want to share with you how to move fast between open and close braces.
Put your cursor before or after the brace (your choice) and then press Ctrl+]. It works with either curly or round braces. From now on you don’t need to play Where’s Waldo? to find that brace.
I’ve been using this trick since Visual C++ 4.0.
Posted by Vadim on May 23, 2008
On two different occasions I was asked to help when VS 2005 would not load. We were able see only VS 2005 splash screen and that’s it. In first case the CPU usage by devenv.exe was 25%. To resolve this problem I launched VS in safe mode.
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE>devenv.exe /SafeMode
This prevents all third-party VSPakages from loading. After that VS 2005 was loading properly all the time.
I believe that in both cases it happened after the developer installed an add-in.
Posted by Vadim on April 1, 2008
ReSharper is a wonderful tool that makes writing code much easier. One of the features of this tool is ability to create templates. With ReSharper you can create Live, Surround With, and File Template. In this post I want to share with you how to create a File Template for MbUnit Test Fixture.
Step 1: Open ReSharper – Options dialog.
Start Visual Studio and from menu bar select ReSharper – Options (you also can get there by pressing Alt-R + O).
Step 2: Create a new template.
- In the left panel select File Templates under Templates section.
- Then select User Templates in Available templates.
- In this sample we’re going to create C# template, so select Class (C#) in Quick access list (it should be the first item in the list).
- Last click on Create Template icon to see Edit Template dialog box.
Step 3: Create and save MbUnit Test Fixture template.
- In Name text box enter MbUnit Fixture. It’s a name that will appear in the menu when you add a new test fixture.
- In File name prefix text box enter MbTest. It’s going to be a suggestion for your test file / class.
Next click on everywhere link next to the word Available to see the Template Options dialog box. Select Only in projects for language radio button and chose C# projects including ASP.NET C#projects) from the drop-down control. Extension for created files leave as cs.
Now we are ready to create actual template.
Enter the code below into Template text.
I’m sure that you noticed $NAMESPACE$, $CATEGORY$, and $CLASS$. These three are ReSharper variables. You declare a variable by surrounding a word with $ sign.
The reason we created variables because we want to do something with them.
Click on Choose macro link and choose following options in Choose Macro dialog box.
|$NAMESPACE$||Default namespace for current file|
|$CLASS$||Current file name without extension|
Uncheck Editable Occurrence check box for NAMESPACE variable.
You can see that CATEGORY variable has a red link Constant value. Click on it and enter Category in String value text box of Choose Parameter Value dialog box.
Now you can start using this template.
Next time I’ll show how to create a Live Template for tests, test SetUp(s) and TearDown(s).
Posted by Vadim on September 5, 2007
Let assume that you have an int array.
If you try to get the type of the array, you’ll get int type.
So far so good. But what if code needs to perform different logic for array of ValueType and Reference Type elements. We all know that int is a ValueType. However, array of int is not. So the if statement below will output ‘Reference Type’.
The code above outputs ‘ValueType’ as expected.