This project is read-only.

Make Namespace declaration optional for VB generated code


VB.Net sets the root namespace and the assembly name to be the same thing by default. Unlike C Sharp, when you put additional namespace declarations in code, you get a namespace MyProject.MyProject for the generated code. At first, this appears to be unimportant, until you start adding classes, For example, create an Expression blend MVVM databound application called MyProject, then add an additional usercontrol plus view model and let it be called View1. Compile and drag an instance of View1 onto the MainView window and name the View1 control "ViewOne". Add a schema to the project, and make it bindable and an ObservableCollection. Call It MyCol. Add that as a datasource.
In app.xaml, you will find
<MyProject_MyProject:MyCol x:Key="MyColDataSource" d:IsDataSource="True" />
generated by Visual Studio.
When you name View1 as ViewOne in MainView, VS will generate code in MyProject.g.i.vb. It expects to find everyting in the generated namespace instead of the code in MainView.xaml, and build will fail.
If you remove the namespace declaration NameSpace MyProject....End Namespace, you can fix the double declaration of MyProject.MyProject and everything will work fine.
So my suggestion for VB code generation is to either leave out the Namespace declaration or to give the option to call it something else other than the root namespace.