By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,685 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,685 IT Pros & Developers. It's quick & easy.

Namespaces in VB.NET

P: n/a
I'm working on a VB library application. I want Visual Studio to
automatically
put in the namespace on the class when I add it under a directory. Like C#
does.

So if I have a directory in my project called /tools, and my default
namespace of the project
is myproject, the editor should put in the namespace of "myproject.tools".
That's how Csharp works.

Does anyone know if this is an option in Visual Studio or something?

Nov 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
maxmann,
Does anyone know if this is an option in Visual Studio or something? Unfortunately there is no option to automatically do this.

I normally include the Namespace statement in each source file. Which of
course has issues if you move the file. Note I still set the root namespace
under Project Properties for classes in the project root.

NameSpace Design

Public Class WidgetEditor
End Class

End NameSpace

Hope this helps
Jay

"news.microsoft.com" <ma*****@xceligent.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl... I'm working on a VB library application. I want Visual Studio to
automatically
put in the namespace on the class when I add it under a directory. Like C# does.

So if I have a directory in my project called /tools, and my default
namespace of the project
is myproject, the editor should put in the namespace of "myproject.tools".
That's how Csharp works.

Does anyone know if this is an option in Visual Studio or something?

Nov 20 '05 #2

P: n/a
right. we have the root namespace set, I was just wanting to get around
having to manually add the namespace in for every class file we create.
Doesn't make sense that VB can't do this when C# does it by default.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
maxmann,
Does anyone know if this is an option in Visual Studio or something? Unfortunately there is no option to automatically do this.

I normally include the Namespace statement in each source file. Which of
course has issues if you move the file. Note I still set the root

namespace under Project Properties for classes in the project root.

NameSpace Design

Public Class WidgetEditor
End Class

End NameSpace

Hope this helps
Jay

"news.microsoft.com" <ma*****@xceligent.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl...
I'm working on a VB library application. I want Visual Studio to
automatically
put in the namespace on the class when I add it under a directory. Like

C#
does.

So if I have a directory in my project called /tools, and my default
namespace of the project
is myproject, the editor should put in the namespace of "myproject.tools". That's how Csharp works.

Does anyone know if this is an option in Visual Studio or something?


Nov 20 '05 #3

P: n/a
* "axmann" <ma*****@xceligent.com> scripsit:
right. we have the root namespace set, I was just wanting to get around
having to manually add the namespace in for every class file we create.
Doesn't make sense that VB can't do this when C# does it by default.


You can write an add-in that inserts the code...

;-)))

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

P: n/a
Axmann,
I don't think its a matter that VB can't, its a matter that VB does not!

I have to wonder how many VB.NET projects actually include folders. So
adding the feature to VB.NET for the two of us makes sense how? :-)

Also I tend to start all my classes in the root of the project, then when I
have enough classes I tend to move them to folders later, so having the
namespace added when I create the class is not going to help me... Rather
then move them into a folder, I may actually move them into their own class
library assembly. Granted others work differently then you or I.

Also as Herfried stated, you could write a macro or add-in to take care of
it.

I'm not sure if it will be changed in VB.NET 2004 or not.

You could always submit a Wish to Microsoft to have the behavior changed,
not sure if it will make VB.NET 2004 as I understand the beta for VB.NET
2004 will be at PDC.

http://register.microsoft.com/mswish...=EN-US&gssnb=1

Hope this helps
Jay

"axmann" <ma*****@xceligent.com> wrote in message
news:O8**************@TK2MSFTNGP11.phx.gbl...
right. we have the root namespace set, I was just wanting to get around
having to manually add the namespace in for every class file we create.
Doesn't make sense that VB can't do this when C# does it by default.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
maxmann,
Does anyone know if this is an option in Visual Studio or something?

Unfortunately there is no option to automatically do this.

I normally include the Namespace statement in each source file. Which of
course has issues if you move the file. Note I still set the root

namespace
under Project Properties for classes in the project root.

NameSpace Design

Public Class WidgetEditor
End Class

End NameSpace

Hope this helps
Jay

"news.microsoft.com" <ma*****@xceligent.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl...
I'm working on a VB library application. I want Visual Studio to
automatically
put in the namespace on the class when I add it under a directory.
Like
C#
does.

So if I have a directory in my project called /tools, and my default
namespace of the project
is myproject, the editor should put in the namespace of

"myproject.tools". That's how Csharp works.

Does anyone know if this is an option in Visual Studio or something?



Nov 20 '05 #5

P: n/a
Well, for organization sake I would think A LOT of projects, VB or not,
should have code grouped in folders.
I guess if you broke every little piece of functionality into their own dll
you might not, but I would rather not
have to work with 30 different projects myself when the functionality is
closely related, but still groupable.

Also, it's just good coding practice to namespace your classes out
corresponding directly to your folder
structure. I've heard that from the experts. My company recently brought
in Rockford Lhotka (the author)
for .NET training and that's what he recommended.

Anyway, I added it to the wishlist. Thanks for the link. I may try an
add-in, but I have tons of more important
things to do at the moment. :)

thanks, Mark

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Axmann,
I don't think its a matter that VB can't, its a matter that VB does not!

I have to wonder how many VB.NET projects actually include folders. So
adding the feature to VB.NET for the two of us makes sense how? :-)

Also I tend to start all my classes in the root of the project, then when I have enough classes I tend to move them to folders later, so having the
namespace added when I create the class is not going to help me... Rather
then move them into a folder, I may actually move them into their own class library assembly. Granted others work differently then you or I.

Also as Herfried stated, you could write a macro or add-in to take care of
it.

I'm not sure if it will be changed in VB.NET 2004 or not.

You could always submit a Wish to Microsoft to have the behavior changed,
not sure if it will make VB.NET 2004 as I understand the beta for VB.NET
2004 will be at PDC.

http://register.microsoft.com/mswish...=EN-US&gssnb=1
Hope this helps
Jay

"axmann" <ma*****@xceligent.com> wrote in message
news:O8**************@TK2MSFTNGP11.phx.gbl...
right. we have the root namespace set, I was just wanting to get around
having to manually add the namespace in for every class file we create.
Doesn't make sense that VB can't do this when C# does it by default.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in

message
news:%2****************@TK2MSFTNGP10.phx.gbl...
maxmann,
> Does anyone know if this is an option in Visual Studio or something?
Unfortunately there is no option to automatically do this.

I normally include the Namespace statement in each source file. Which of course has issues if you move the file. Note I still set the root

namespace
under Project Properties for classes in the project root.

NameSpace Design

Public Class WidgetEditor
End Class

End NameSpace

Hope this helps
Jay

"news.microsoft.com" <ma*****@xceligent.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl...
> I'm working on a VB library application. I want Visual Studio to
> automatically
> put in the namespace on the class when I add it under a directory. Like C#
> does.
>
> So if I have a directory in my project called /tools, and my default
> namespace of the project
> is myproject, the editor should put in the namespace of

"myproject.tools".
> That's how Csharp works.
>
> Does anyone know if this is an option in Visual Studio or something?
>
>
>



Nov 20 '05 #6

P: n/a
axmann,
Well, for organization sake I would think A LOT of projects, VB or not,
should have code grouped in folders. I believe you miss read me! You and I believe this way, I question if other,
less informed VB.NET programmers know this, especially when coming from VB6
which did not support it!

And yes my estimate of 2 may have been low ;-)
I guess if you broke every little piece of functionality into their own dll you might not, but I would rather not I never said 'little piece', An example of what I meant: Is one project with
500 classes in it better or worse than 10 projects with 50 classes each? I
find 10 projects with 50 classes each to be 'more manageable'. Would I have
5 projects with 100 classes each, I'm not sure. I think it would depend on
how well those classes grouped or didn't. However it is doubtful that I
would have 50 projects with 10 classes each, then again it there were 50
obvious groupings...
Also, it's just good coding practice to namespace your classes out
corresponding directly to your folder structure I never said it wasn't, I almost always do. However like any rule, there are
exceptions that make sense. :-)

If anything I normally do it the other way: I will put classes into a
namespace in the root folder, before I would put files in a folder without a
namespace (if that made sense).

Hope this helps
Jay
"axmann" <ma*****@xceligent.com> wrote in message
news:e%****************@tk2msftngp13.phx.gbl... Well, for organization sake I would think A LOT of projects, VB or not,
should have code grouped in folders.
I guess if you broke every little piece of functionality into their own dll you might not, but I would rather not
have to work with 30 different projects myself when the functionality is
closely related, but still groupable.

Also, it's just good coding practice to namespace your classes out
corresponding directly to your folder
structure. I've heard that from the experts. My company recently brought
in Rockford Lhotka (the author)
for .NET training and that's what he recommended.

Anyway, I added it to the wishlist. Thanks for the link. I may try an
add-in, but I have tons of more important
things to do at the moment. :)

thanks, Mark

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Axmann,
I don't think its a matter that VB can't, its a matter that VB does not!

I have to wonder how many VB.NET projects actually include folders. So
adding the feature to VB.NET for the two of us makes sense how? :-)

Also I tend to start all my classes in the root of the project, then when
I
have enough classes I tend to move them to folders later, so having the
namespace added when I create the class is not going to help me... Rather then move them into a folder, I may actually move them into their own class
library assembly. Granted others work differently then you or I.

Also as Herfried stated, you could write a macro or add-in to take care of it.

I'm not sure if it will be changed in VB.NET 2004 or not.

You could always submit a Wish to Microsoft to have the behavior changed, not sure if it will make VB.NET 2004 as I understand the beta for VB.NET
2004 will be at PDC.

http://register.microsoft.com/mswish...=EN-US&gssnb=1

Hope this helps
Jay

"axmann" <ma*****@xceligent.com> wrote in message
news:O8**************@TK2MSFTNGP11.phx.gbl...
right. we have the root namespace set, I was just wanting to get around having to manually add the namespace in for every class file we create. Doesn't make sense that VB can't do this when C# does it by default.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in

message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> maxmann,
> > Does anyone know if this is an option in Visual Studio or something? > Unfortunately there is no option to automatically do this.
>
> I normally include the Namespace statement in each source file. Which of > course has issues if you move the file. Note I still set the root
namespace
> under Project Properties for classes in the project root.
>
> NameSpace Design
>
> Public Class WidgetEditor
> End Class
>
> End NameSpace
>
> Hope this helps
> Jay
>
> "news.microsoft.com" <ma*****@xceligent.com> wrote in message
> news:eG**************@TK2MSFTNGP11.phx.gbl...
> > I'm working on a VB library application. I want Visual Studio to
> > automatically
> > put in the namespace on the class when I add it under a directory.

Like
> C#
> > does.
> >
> > So if I have a directory in my project called /tools, and my

default > > namespace of the project
> > is myproject, the editor should put in the namespace of
"myproject.tools".
> > That's how Csharp works.
> >
> > Does anyone know if this is an option in Visual Studio or something? > >
> >
> >
>
>



Nov 20 '05 #7

P: n/a
Hi Jay, Axman,

2? That's 3, thank you very much!! [much fake indignation, lol]

Actually, though I use folders a lot (and then I might migrate out to
projects), I prefer explicit namespaces. I also have temporary folders where
things are put just so that I don't have to play scroll and click so much. I
wouldn't want any automatic namespaces for those.

I haven't had the pain of too much renaming upheaval but if it comes to
it, ...Hey - opportunity for a utiity. Doesn't even have to be an add-in -
just a console app that reads a bunch of solution files, project files and
directory structures.

Regards,
Fergus
Nov 20 '05 #8

P: n/a
well, I submitted it to the good old MS wish list. We'll see what happens.

I think it would be best if it were an option , that way if you wanted
Visual Studio to do it , it would, and vice versa.

I agree that not every programmer out there would want the feature, but the
option would be helpful.

"Fergus Cooney" <fi******@tesco.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Jay, Axman,

2? That's 3, thank you very much!! [much fake indignation, lol]

Actually, though I use folders a lot (and then I might migrate out to
projects), I prefer explicit namespaces. I also have temporary folders where things are put just so that I don't have to play scroll and click so much. I wouldn't want any automatic namespaces for those.

I haven't had the pain of too much renaming upheaval but if it comes to it, ...Hey - opportunity for a utiity. Doesn't even have to be an add-in -
just a console app that reads a bunch of solution files, project files and
directory structures.

Regards,
Fergus

Nov 20 '05 #9

P: n/a
Hi Axmanm,

I'm all in favour of options, so I hope you get your wish.

If ever I do that utility, I will send it to you at xceligent.com ;-)

Regards,
Fergus
Nov 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.