Using Third Party Compare/Merge Tools with TFS 2010

21. November 2011

 

    When you compare changes with previous version or merge changes, TFS uses the visual studio default compare and merge tools. 

But, we can configure this to use your favorite compare, merge tools, like Araxis merge, WinMerge, Beyond Compare, etc.

 

Following are the steps to change the comapre/merge tools in visual studio TFS.

1. Open "Configure user tools" popup.

           Tools -> options -> source control -> visual studio team foundation server -> "configure user tools"

2. Click Add, It opens Configure tools popup

          Enter extension, and select operation, either compare or merge.

 

Use the following table to enter the command and the arguments field. 

Compare Tools:

Tool

Command

Arguments

TFS Default

diffmerge.exe

%1 %2 %6 %7 %5 /ignorespace

WinDiff

windiff.exe

%1 %2

WinMerge.

winmerge.exe

/ub /dl %6 /dr %7 %1 %2

DiffDoc (for MS Word files)

DiffDoc.exe

/M%1 /S%2

Beyond Compare.

bc2.exe

%1 %2 /title1=%6 /title2=%7

KDiff3.

kdiff3.exe

%1 --fname %6 %2 --fname %7

Araxis Compare.

compare.exe

/wait /2 /title1:%6 /title2:%7 %1 %2

Compare It!.

Wincmp3.exe

%1 /=%6 %2 /=%7

SourceGear DiffMerge.

DiffMerge.exe

/title1=%6 /title2=%7 %1 %2

Beyond Compare 3.

BComp.exe

%1 %2 /title1=%6 /title2=%7

TortoiseMerge.

TortoiseMerge.exe

/base:%1 /mine:%2 /basename:%6 /minename:%7

Visual SlickEdit.

win\vsdiff.exe

%1 %2

 

Merge Tools:

 

Tool Command Arguments
TFS Default diffmerge.exe /merge %1 %2 %3 %4 %6 %7
Araxis Merge. compare.exe /wait /swap /a3 /3 /title1:%6 /title2:%7 /title3:%8 %1 %2 %3 %4
Beyond Compare (2-way merge). bc2.exe %1 %2 /savetarget=%4 /title1=%6 /title2=%7
KDiff3. kdiff3.exe %3 --fname %8 %2 --fname %7 %1 --fname %6 -o %4
WinMerge (2-way merge). winmerge.exe /ub /dl %6 /dr %7 %1 %2 %4
Visual SourceSafe. ssexp.exe /merge %1 %2 %3 %4 %6 %7
Guiffy. guiffy.exe -s -h1%6 -h2%7 -hm%9 %1 %2 %3 %4
Ellie Computing. guimerge.exe --mode=merge3 %3 %1 %2 --to=%4 --title0=%8 --title1=%6 --title2=%7 --to-title=%9
SourceGear DiffMerge. DiffMerge.exe /title1=%6 /title2=%8 /title3=%7 /result=%4 %1 %3 %2
Beyond Compare 3. BComp.exe %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9
TortoiseMerge. TortoiseMerge.exe /base:%3 /mine:%2 /theirs:%1 /basename:%8 /minename:%7 /theirsname:%6 /merged:%4 /mergedname:%9
Visual SlickEdit. win\vsmerge.exe %3 %1 %2 %4

 

For example, to use araxis merge, 

Select the compare.exe from the Araxis installation folder and enter the arguments.

 

And click Ok in popups to save changes.

That's it, from now on, if you select compare in visual studio, it will invoke your favorite compare tool.

, , ,

Extension methods, Advantages, Best Practices

18. May 2011

 

What is Extension Method?

Extension methods allow developers to add new methods to the public contract of an existing type, without having to sub-class it or recompile the original type. It allows static methods to be invoked on instance variables. Extension methods can be defined on classes, structures and interfaces.

These methods must take at least one parameter, which represents the instance the method is to operate on. For example, in C#, this is done by using the modifier on such a parameter, when defining the method: 

public static bool IsPalindrome(this string s)
{
      //implementation follows here
}

This example allows one to write, for example:

“some string”.IsPalindrome();

 

Advantages:

  • Cleaner and readable code. LINQ benefits greatly from extension methods as LINQ queries would be almost unreadable without them.
  • Extend functionality on third party objects and sealed classes.
  • Intellisense support. When you add an extension method M on type T, you get 'M' in T's intellisense list (assuming the extension class is in-scope). This make 'M' much easier to find than StaticClass.M(T,...)
  • Create default functionality for interfaces without having to implement an abstract class

 

Disadvantage:

  • There's no compiler error or warning if you have a regular method and an extension method with the same signature in the context.
  • Object and the extension method are versioned independently. You can be put in a trouble when vendor of a class you are extending on creates the method with the same name.
  • You have an extension method and another library creates an extension method with the same signature? You will end up with difficulties in using both namespaces.
  • You can only have extension methods, not properties, indexers, operators, constructors etc.

 

Best practice:

  • Put extension methods into their own namespace. By putting extension methods into their own namespace you enable consumers to include or exclude them separately from the rest of your library. This makes them pluggable.
  • Avoid defining extension methods on System.Object, unless absolutely necessary. When doing so, be aware that VB users will not be able to use thus-defined extension.
  • Think twice before extending types you don't own. The types can include methods with the same name any time.
  • Avoid redefining extension methods on a type T with extension methods on the same type.
  • Use extension methods :
    • To provide helper functionality relevant to every implementation of an interface. 
    • To provide extension to a library that cannot be extended in other way and on which you do not have access over
    • To use with Interfaces. Interfaces cannot include behavior by default. But now you can add it with Extension Methods

 

.Net, c# , ,

Few Differences between WPF and Silverlight

19. April 2011

 

  1. WPF is a thick Windows client platform, SilverLight is a browser based plug-in. WPF is built on top of .Net Framework and that has access to the full .Net Framework APIs. Silverlight has access to only a subset of the .Net Framework (called the CoreCLR). 

  2. Silverlight is just a subset of WPF.

  3. Silverlight is meant to for web based application (that can run out of browser), while WPF is for desktop applications.

  4. Silverlight is compatible with multiple browsers, devices and operating systems, bringing a new level of interactivity wherever the Web works.

  5. Within WPF, all visually rendering elements derive from the 'Visual' class. Within Silverlight, they do not; Both technologies, however, eventual derive from the DependencyObject class up the hierarchy.

  6. WPF supports 3 types of routed events (direct, bubbling, and tunneling). Silverlight supports direct and bubbling only (so there is no Preview___ events).

  7. There's quite a few data-binding differences. Currently, Silverlight doesn't support the binding mode, OneWayToSource. In addition, Silverlight defaults to OneWay databinding if none is set, while WPF uses the default mode specified by the dependency property.

  8. Silveright doesn't support MultiBinding.

  9. Silverlight supports the XmlDataProvider but not the ObjectDataProvider. WPF supports both.

  10. Silverlight supports browser interop, more media streaming options including timeline markers, and Deep Zoom. WPF doesn't support these features yet.

  11. Silverlight 5(Beta) got XAML debugging support, which is not available in WPF.

Silverlight, wpf ,

Debug bindings in XAML with Breakpoints

19. April 2011

    In Silverlight 5 (Beta), one of the most interesting and important enhancement is the ability to set breakpoints in XAML and debug bindings. Before Silverlight 5 (and in WPF), debugging the binding is a difficult task, there is no direct way to put debug code.

Following are the options that we use to debug the binding errors.

  1. Look at the output window for all tyeh errors and try to resolve.
  2. Write dummy converters and attach to all the bindings. and set breakpoint inside the converter.

The binding xaml breakpoints in Silverlight 5 is a more flexible, powerful, and saves the time spend in debugging.

But the sad part is that WPF is not getting this ability to set breakpoint in XAML in the next version too. Pete Brow, Developer Division Community Program Manager at Microsoft mentioned this in his post.

He also mentioned that, "While from the outside they're very similar, the Silverlight and WPF codebases are very very different. It's actually a ton of work to implement some things in WPF due to those differences. In fact, most of Silverlight is native code whereas much of WPF is managed. If it were just an easy imp, the team would have done it.".

So, We have to wait till WPF 6(?) to get the same featuter.

.Net Tips, wpf , , ,

WPF : Not Using StringFormat when the data is null.

21. March 2011

 

When you are using StringFormat in XAML, if the data is null, the oputput will be just the format text.

For example, consider the following example.

 

<TextBlock Text="{Binding Path=Amount, StringFormat=Total: {0:C}}" />

 

When the Amount is null, the output of the above binding will be "Total:" This doesn't makes any sense. So, most of teh cases, you have to hide the text or display alternative text. You can achive this with converters (IValueConverter).

There is another simple way to do it without writing any C# code using TargetNullValue. Here is how you can achieve the result.

<TextBlock Text="{Binding Path=Amount,  
TargetNullValue={x:Static System:String.Empty},  
StringFormat=Total: {0:C}}" />

Note:-

If you are using TargetNullValue in Binding, if the value is null, it will ignore the StringFormat. In some cases, you might want to display the Text with formatted string. In this case, you cannot use the above mentioned method. you have to implement your converter.

.Net Tips, .Net, wpf , ,

What is MVVM? and Why MVVM?

2. March 2011

 

 

What is MVVM?

    Model-View-ViewModel (aka Presentation Model), provides architectural solution for the Aplication with UI with complex interdependent interactions.

    Separate the UI(View) from the UI logic using a ViewModel that encapsulates the interactions and provides properties for a View to retrieve its state (and the state of its elements). 

 

Why MVVM?

1. Separates UI from Model. If model needs to change, it can without changing the view and vice versa.

2. Avoids duplicated code to update views.

3. Unit testable UI logic.

4. You can use a 'viewmodel' to aggregate parts of your model that exist in separate classes/libraries to facilitate a more fluent interface for the 'view' to deal with.

5. Data-binding support with INotifyPropertyChanged, ICommand and IvalueConverters

6. Easy to refactor

7. Extensibility.

 

interview questions, .Net, wpf ,

What is WPF and Why WPF?

2. March 2011

What is WPF?

 

    The Windows Presentation Foundation (WPF) is Microsofts next generation UI framework to create applications with a rich user experience. It is part of the .NET framework 3.0 and higher. 

 

Why WPF?

1. Ability to separate UI from logic effectively.

2. Powerfull Data binding, much better than with the WinForms application.

3. Inbuilt animation and storyboarding models.

4. UI virtualisation feature to handle large set of data.

5. Flexible modelling of data on UI with data and control templates.

6. 3D graphics.

7. Video, 3D content and animations support.

8. Declarative UI programming.

9. Rich Event support with routed Events.

 

.Net, interview questions ,

Useful Visual studio Shortcut keys

12. January 2011


We all are familiar with visual studio shortcut keys, But not all the shortcut keys. I have listed few usefull shortcut keys that we don't use frequently.

Shortcut Key

Functionality

Ctrl-W

Selects the word containing the cursor or the word to the right of the cursor

Ctrl-= 

Selects from the current location in the editor back to the previous location in the navigation history

F7

Switches from the design view to the code view in the editor

Shift-F7

Switches from the code view to the design view in the editor

Shift-F12 

Finds a reference to the selected item or the item under the cursor (Find all references of the current item)

Ctrl-G

Displays the Go to Line dialog. If in TFS work item, it displays go to work item dialog.

Ctrl-] 

Moves the cursor to the matching brace in the document.
If the cursor is on an opening brace, this will move to the corresponding closing brace and vice versa

Ctrl-K, Ctrl-I

Shows a quick description about whatever object the cursor is currently resting on

Ctrl-Down Arrow 

Scrolls text down one line without moving the cursor.
This is useful for scrolling without losing your place.

Ctrl-Up Arrow 

Scrolls text up one line without moving the cursor.
This is useful for scrolling without losing your place.

Ctrl-K, Ctrl-C

Marks the current line or selected lines of code as a comment.

Ctrl-K, Ctrl-U

Uncomments the line/ or selected lines if commented.

Ctrl-K, Ctrl-\ 

Removes all the whitespaces in the selection or removes whitespace adjacent to the cursor if there is no selection.

Ctrl-L

Cuts all selected lines or the current line if nothing has been selected to the clipboard

Ctrl-Shift-L

Deletes all selected lines or the current line if no selection has been made

Ctrl-Enter 

Inserts a blank line above the cursor

Ctrl-Shift-Enter 

Inserts a blank line below the cursor

Ctrl-Shift-Spacebar 

Displays a tooltip that contains information for the current parameter, based on the current language

 

.Net Tips, Technical

Office 2010 beta expired

31. October 2010

 

When you try to start a Microsoft Office 2010 application, you receive the following message:

"Your beta software has expired. Use Add or Remove Programs in Control Panel to remove the beta software from your computer."

    This issue occurs because the beta version of the Office 2010 application that you are using has expired. The beta 1 and beta 2 versions of the Office 2010 applications expire on the following dates:

  • 2010 Microsoft Office Beta 1: October 31, 2010
  • 2010 Microsoft Office Beta 2: November 1, 2010

 

To resolve this issue, Uninstall the beta version of the office 2010.

    If you have problems uninstalling the beta version of the Office 2010 application, visit How do I uninstall Office 2003, Office 2007 or Office 2010 suites if I cannot uninstall it from Control Panel

    If you try to install the release version of Office 2010 while the beta version is installed you may receive an error. Visit the following Microsoft Knowledge Base article if this occurs: Error message when you try to install Office 2010: "Microsoft Office 2010 does not support upgrading from a pre-release version of Microsoft Office 2010"

 

General

Xmarks service ends January 2011?

30. September 2010

 

Today, I have received an email from XMarks saying that It will end the service by Jan 2011. Following is the content of the email.

 

Dear Xmarks User,

We've always said we won't email you unless it's important; this is one of those occasions:

Xmarks will be shutting down our free browser synchronization services on January 10, 2011. For details on how to transition to recommended alternatives, consult this page.

For the full story behind the Xmarks shutdown, please read our blog post.

Thank you for being a part of the Xmarks community; we apologize for any inconvenience this step may cause you. We believe we have the best users in the world, and we hope your bookmarks find a new and happy home soon.

Asynchronously,

— The Xmarks Team

 

In their blog they have mentioned that they are closing as they are running out of money. Following is the message from Xmarks:

"By Spring 2010, with money running tight and options fading, we started searching for potential buyers of the company. Over the past three months, we have been remarkably close to striking a deal, only to have the potential buyer get cold feet. We also considered refocusing Xmarks as a freemium sync business, but the prospects there are grim too: with the emergence of competent sync features built in to Mozilla Firefox and Google Chrome, it’s hard to see users paying for a service that they can now get for free. For four years we have offered the synchronization service for no charge, predicated on the hypothesis that a business model would emerge to support the free service. With that investment thesis thwarted, there is no way to pay expenses, primarily salary and hosting costs. Without the resources to keep the service going, we must shut it down. Our plan is to keep the service running for another 90+ days, after which the plug will be pulled.

The past four years have been a wild ride for us: growing something from nothing to substantial scale, providing a simple service that people love because it simplifies their lives. We’ve learned tons along the way, often by making big mistakes. We’re really sorry that this last lesson means that you’ll have to find an alternative to Xmarks, but the alternatives exist and you’ll have no problem finding them. (Start here for specific recommendations.)" 

 

General