The SharePoint 2010 Development Tools for Visual Studio 2010 is great and I really like the way that the project is built using the different artifacts. One thing really annoys me though and that is the way that the code is generated and named when you add items. For example if you create a project and then add a Web Part item to that project then Visual Studio will create a Web Part class with a namespace and class name like this:
namespace Wictor.CodeAnalysis.WebPart1 {
public class WebPart1 : WebPart {
// ---
}
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }As you can see the namespace and the name of the Web Part has the same name. This is a violation of one of the basic naming guideline rules (CA1724 if you run the code analysis in Visual Studio 2010). Although it works it will make your generated assembly having many different namespaces which makes it quite hard to work with. For each new item you will get a sub-namespace.
With tools like WSPBuilder I normally placed Web Parts within one namespace, controls in one and event receivers in another. This made the experience when working with the assembly easy.
If you now decide to change the namespace to something mode naming-convention-compliant such as below, then you need to update your Web Parts Control Description file (.webpart) and the SafeControl entry in the Package manifest.
namespace Wictor.CodeAnalysis.WebParts {
public class WebPart1 : WebPart {
// ---
}
Making all these manual corrections will likely make your project break at some time. So I guess we have to put up with this…but it is not good looking (so if you guys there in Redmond have a few nights over until VS2010 RTM, please fix this).