Archive

Posts Tagged ‘Visual Studio’

Suggestion: Visual Studio should offer to implement callbacks

I type-in new PropertyMetadata(OnCenterXPropertyChanged) but since I haven’t yet implemented On…, I get a suggestion by the IDE to implement it but it suggests to add field, property or read-only field, not to implement the callback for me with the given name. It can find the method signature needed from the delegate that PropertyMetadata (one of its overloaded versions) expects.

It came to me while I was trying to implement Silverlight’s CompositeTransform for WPF:

public static readonly DependencyProperty CenterXProperty = 
DependencyProperty.Register("CenterX", typeof(double),
typeof(CompositeTransform),
new PropertyMetadata(OnCenterXPropertyChanged));

for the Compatibility library I maintain at http://github.com/zoomicon/Compatibility. I have used that library a lot in ClipFlair to maintain a common C# source and XAML between Silverlight and WPF projects (I do code sharing between projects via linked files).

Can vote for this suggestion at:

http://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/10906626-offer-to-implement-callbacks

Advertisements

HowTo: Remove unused references and using clauses in Visual Studio

I recently posted a list of the VS2015 extensions I use on my main machine at: https://zoomicon.wordpress.com/2015/11/13/visual-studio-2015-extensions-i-use/

From that list of extensions I use the Productivity Power Tools one, it has a "Power Commands > Remove and Sort Usings" action that one can right click and run on the whole solution. Much easier than opening it for each

There is another nice extension called ResolveUR that is not available for VS2015, but only for VS2013 (think you can edit its .vsix and make it work for it too though, see the process for other similar extension explained at https://devio.wordpress.com/2014/12/03/remove-unused-references-with-visual-studio-2013/). I usually open up the solution in VS2013 too just to run that. Resharper also has such functionality as shown at:

https://www.jetbrains.com/resharper/help/Refactorings__Remove_Unused_References.html

Alternative is to use the Copy References extension and right click a reference under the References subtree of a project, then select "Copy Reference", then Remove the reference and rebuild that project. If rebuild fails, then right click at the References again and select Paste Reference. Then repeat till you remove all references that are not needed

In fact one should FIRST remove all unused using clauses and THEN remove unused references. That is because some files like App.xaml.cs, AssemblyInfo.cs may have using clauses that they don’t really use. So unless those using clauses are removed, the compiler thinks respective references to assemblies those namespaces were at are needed

Visual Studio 2015 Extensions I use

%d bloggers like this: