SharePoint 2010 Ribbon Feature (bug?)

by Danielvg 14. February 2010 11:45

I am testing some of the new parts of SharePoint 2010 for an upcoming project at work, and while creating a new Ribbon tab I ran into some problems. The tab is defined in a CustomAction that is deployed as a feature. While playing around with different setups I started to encounter errors that I simply could not fix even when I undid everything and used a version I knew had worked. After spending way to much time on this issue this happened:

I changed the Tab title from “The Tab” to “Another Tab”, when deployed everything seemed fine:

image_thumb1

But when I clicked on the tab the title changed back to the old title

image_thumb7

Well that made no sense what so ever, so I started to test a bit and it seems SharePoint keeps a copy of the feature even when the feature and solution it came in is removed. The funny part is that it is only some parts of the “old feature copy” that SharePoint remembers.
So how to overcome this issue? I started to Google and it seems I am not the only one with this problem, some suggested to recreate the VS solution every time you change something in the Ribbon with comments like “You only have one shot at this, be sure to get it right the first time”. I found that the easiest way to make sure changes made to the Ribbon actually gets deployed is to change the Feature Id, this can be done in VS2010 in the feature properties:

image_thumb5

So I am left with a workaround but no idea as to why SharePoint keeps parts of old features and no idea if this is working as intended? I do not recall having this problem in MOSS2007..
I will try and dig a little deeper into this and update this post if I find anything worth mentioning.

Increasing Productivity in Visual Studio

by Danielvg 29. January 2010 20:57

There are a lot of ways to increate productivity, this post will focus on some of the stuff that can be used within visual studio to code a bit faster. The plan is to keep updating this post so it can be used as a reminder/encyclopedia for myself and anyone interested. NB: The stuff below works in vs2010 but should also work with vs2008, at least if you are using ReSharper.

Key bindings:

Keys Description
Ctrl+Alt+L Focus on Solution Explorer
Ctrl+½+M Focus on Team Explorer
Ctrl+Tab Tab open documents within visual studio
Ctrl+Shift+A Add new item
Ctrl+M –> Ctrl+O Collapse everything in the document
Ctrl+M –> Ctrl+L Expand everything
Ctrl+M –> Ctrl+M Collapse/Expand a block
   
Ctrl+F5 Start without debugging
Shift+F5 Stop debugging
   
Ctrl+. Resolve
Ctrl+i Incremental search
Ctrl+, Quick search
   
Ctrl+K -> Ctrl+F Auto format selected
Ctrl+K -> Ctrl+C Comment out selected
Ctrl+K -> Ctrl+U Uncomment selected
Ctrl+R -> Ctrl+R Rename
Ctrl+R -> Ctrl+M Extract Method
Ctrl+R -> Ctrl+E Encapsulate field
Ctrl+Shift+V Paste by cycling through latest clipboards

I am not really a fan of bookmarks so they have been left out until someone says they are the best thing in the world.

Macros:
Macros are a way of recording and playing a set of key strokes, they can be used to ease the work of tedious tasks. Some sample macros come with visual studio but the most useful feature, at least for me, is temporary macros.

In visual studio to help speed up the process and use the temporary macros more often I bind the following keys:
Ctrl+Shift+R - to start recording
Ctrl+Shift+E – to stop recording

and of cause use the default ctrl+shit+P to play the macro.

If you are not already using macros, try them out!

Snippets:
Creating your own snippets is of cause always a good thing, here are some of the default snippets:
(if your new to snippets, type the name of the snippet and press tab a few times)

Name Outcome
prop
public int MyProperty { get; set; }
propg
public int MyProperty { get; private set; }
propfull
private int myVar;

public int MyProperty
{
    get { return myVar; }
    set { myVar = value; }
}

for
for (int i = 0; i < length; i++)
{
}
forr
for (int i = length - 1; i >= 0 ; i--)
{
}
foreach
foreach (var item in collection)
{
}
invoke
EventHandler temp = MyEvent;
if (temp != null)
{
    temp();
}
cw
Console.WriteLine();
mbox
global::System.Windows.Forms.MessageBox.Show("Test");
ctor
public NameOfMyClass()
{

}

try
try
{

}
catch (Exception)
{
    throw;
}

tryf
try
{

}
finally
{

}

testm
[global::Microsoft.VisualStudio.TestTools.UnitTesting.TestMethod]
public void MyTestMethod()
{
}
propnew

private int myVar;
public int MyProperty
{
    get
    {
        if (myVar == null)
        {
            myVar = new int();
        }
        return myVar;
    }
    set { myVar = value; }
}

Other:

Method/Class/.. Comments
Typing 3 times “/” creates the default comment template:


Automatically turns into: 

 

Box select
The newly added box select has been surprisingly useful, simply hold the “Alt” key and select with the mouse. 

 

 

On a somewhat related note; a blog post, that can be found here, raises some pretty interesting questions about your font type, m-mz says that you can read 14% faster with a proportional font when compared with a fixed width font. Maybe it is worth a try?

UPDATE
4/2-2010: Added custom snippet; propnew - propnew.snippet (1,30 kb)

--------

Did I miss that one perfect shortcut or something else? Let me know and I will add it!

To be updated!

VS2010 – (auto) Generate Sequence Diagram

by Danielvg 22. December 2009 18:49

Instead of booting up Visio and spending hours creating sequence diagrams, Visual Studio 2010 now has a build in feature for creating sequence diagrams!

Being a student, that too often have to make somewhat pointless sequence diagrams, I nearly jumped out of my seat when I saw this feature demonstrated at “best of pdc 09”!

This is how easy it is; right click a method, press “Generate Sequence Diagram…”…

image

A few seconds later the sequence diagram is created, and in this case the result is:

image

Should you want to edit the generated diagram then the toolbox gives you the basics for this:
image

For some this might seem like a useless feature, but it really helps when you need to understand code made by others (and in some cases, save a few hours of Visio work).

A note for students: I am guessing this is an Ultimate only feature, but it seems dreamspark will be offering VS2010 Ultimate so it should be no problem getting it!