Disable the Toggle Completion Mode in Visual Studio

When writing code in Visual Studio, the shortkey Ctrl+Alt+Space toggles the completion mode of IntelliSense in the Text Editor.
The completion mode can be manually changed by going to this menu in VS2012:
EDIT > IntelliSense > Toggle Completion Mode

However the shortkey can be annoying while coding, depending on your keyboard configuration and language.

To disable this shortkey command in Visual Studio 2012 follow these steps:

  • Go to TOOLS
  • Select Options…
  • Go to Environment > Keyboard
  • Below the Show commands containing: type the word completion and hit the TAB-key
  • The filtered listbox should now contain a command called Edit.ToggleCompletionMode
  • Select it and hit the button Remove
  • Click OK to close the Options form

visual studio 2012 keyboard command options

These steps are very similar to Visual Studio 2010.

Get information from Team Foundation Server (TFS) via C# code

This code shows you how you could interact with your team foundation server. In my case a TFS 2010.

Open a new console application in Visual Studio and add these references:

  • Microsoft.TeamFoundation.Client
  • Microsoft.TeamFoundation.VersionControl.Client
TeamFoundationServer tfs = new TeamFoundationServer("http://yourtfsserver:port/something");
List<string> changedFiles = new List<string>();

VersionControlServer VCServer = (VersionControlServer)tfs.GetService<VersionControlServer>();

try
{
string path = @"C:\Users\<username>\Documents\Visual Studio 2010\Projects\just the path to your solution";
VersionSpec version = VersionSpec.Latest;
int deletionId = 0;
RecursionType recursion = RecursionType.Full;
string user = @"domain\yourusername";

foreach (Changeset item in VCServer.QueryHistory(path, version, deletionId, recursion, user, null, null, Int32.MaxValue, true, false, true))
{
  foreach (Change c in item.Changes)
  {
	// c.Item.ServerItem;
  }
}
}
catch { }

Happy coding ;)

BugAid for Visual Studio: Enhance your debugging experience

BugAid is an extension for Visual Studio that can help you whenever you debug C# code. Using our unique features you can debug faster than ever before and have more time for writing quality code!

P.S.: If you buy BugAid, I would appreciate it if you leave them a message that you got the news from this blog ;-)

[ link ]

Raise PropertyChanged events without using strings in Prism

While I was testing something with Prism4 + MEF, I found this interesting method overload to raise PropertyChanged events without having to use the string name of the property itself.
Because having a typo in such a string can be very painful. :)

Let’s say you have a ViewModel which derives from the NotificationObject. In the setter I’m using the ‘better’ way of raising that PropertyChanged event:

public class TestViewModel : NotificationObject
{
private string _Title;

public string Title
{
get { return _Title; }
set
{
if (value != _Title;)
{
_Title = value;
this.RaisePropertyChanged(() => this.Name);
}
}

}
}

instead of writing:

this.RaisePropertyChanged("Title");

If you have already your project full of RaisePropertyChanged methods with strings you can easily replace them in Visual Studio with Regular Expressions:

- [Ctrl]+[F]
- Select [Quick Replace]
- In the dropdown menu choose [Replace in Files] instead of [Quick Replace]
- Look in: [Entire Solution]
- check [Use] and select [Regular expressions]
- Find what: RaisePropertyChanged\(\”{[:a]*}\”\)\;
- Replace with: RaisePropertyChanged(() => this.\1);

Have fun ;)

HTML5 support for Visual Studio 2010 Editor

Today, a faction of the Web Platform and Tools team, spearheaded by Mads Kristensen, is pleased to announce the Visual Studio Web Standards Update. This adds better support for HTML5, CSS3 and new JavaScript features to ALL versions of Visual Studio.

More info and the download link here.

[ source ]

Debugger Canvas for Visual Studio

Microsoft and Brown University have collaborated to create Debugger Canvas, a free Power Tool that adds Code Bubbles™ to Visual Studio for a new way to debug.

Do you get lost in the document tabs? Are you tired of the debugger jumping around from file to file? Debugger Canvas pulls together the code you’re exploring onto a single pan-and-zoom display. As you hit breakpoints or step into code, Debugger Canvas shows just the methods that you’re debugging, with call lines and local variables, to help you see the bigger picture.

Release info:

We are currently in the last phase of shipping! The first alpha release will be available in early June 2011. (download link)

Something I will check out for sure! ;)
Update: works only with Visual Studio 2010 Ultimate :(

More info on the Microsoft Research page.

[ source ]

White screen of Darn

Ever had a White screen of Darn (WSOD) in Visual Studio or an error like this: “exception of type system.componentmodel.design.exceptioncollection was thrown” ?

If the [Clean Solution] and [Rebuild Solution] didn’t work.
Here is how to find the culprit:

  1. Open Visual Studio 2010 and open/load your solution containing the problem
  2. Open a second Visual Studio 2010 instance

In the second VS2010 instance do the following things:

  1. Go to [Tools] > [Attach to Process...]
  2. Select devenv.exe with which contains the solution with the problem from the Available Processes and click OK
  3. Next go to [Debug] > [Exceptions...]
  4. Check [Common Language Runtime Exceptions] in the [Thrown] column

Now go to your first Visual Studio 2010 instance with your project and open the designer file which causes you the PITA (Pain In The Ass).

Your second VS2010 instance should break on the exception, showing you where it goes wrong in your code.

Enjoy ;)

Visual Studio Styles

I’ve been using a new style in Visual Studio recently, because my eyes got a bit too tired of looking constantly at the white background of the editor in Visual Studio 2010.

Today I’ve installed the style also at work and I must say that my eyes like it ^^.

I used “Son of Obsidian” from StudioStyl.es.

Installing this style is simple, if you have problems read the StudioStyl.es FAQ.

Happy coding ;)

[ source ]

 

Using C# keywords in your Enums

Sometimes you want to define a value in your enumeration which has the same name as a keyword in C#.

The compiler will not like this:

The solution in C# for this is to prefix your value with the @-character:

namespace EnumTest
{
 //as = attosecond
 public enum Time : byte
 {
 s = 1,
 ms = 2,
 @as = 3
 }
}

For Visual Basic use square brackets like this [as].