Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find all namespaces in my Visual Studio solution?

I ask this question because I'm getting a compilation error in my solution: 'GiftCard' is a 'namespace' but is used like a 'type'

I tried adding a using directive like: using GiftCard.Data.Entity;

which is the correct namespace where GiftCard is found, but the error does not go away. When I add the fully qualified name in my code, i.e. GiftCard.Data.Entity.GiftCard

...then the error goes away, and code compiles.

But I'm wondering why the using directive does not work. I don't want to clutter my code with the fully qualified name every time I need to use the type. Somehow the error message is saying that I have GiftCard defined as a namespace somewhere. So how can I find all the namespaces in my solution so that I know where it is defined because I need to either remove or rename the GiftCard namespace.

like image 980
Ray Avatar asked Jul 27 '15 03:07

Ray


1 Answers

Your have a different question and a different problem.

The Problem

The Framework Design Guidelines says Do not use the same name for a namespace and a type in that namespace.

For example, do not use Debug as a namespace name and then also provide a class named Debug in the same namespace. Several compilers require such types to be fully qualified.

That is:

namespace Debug
{
    public class Debug{ … }
}

OR

namespace MyContainers.List
{
    public class List { … }
}

Why is this badness? Do not name a class the same as its namespace

Answer for the Question

View -> Object Browser (Shortcut : Ctrl+Alt+J)

like image 188
CharithJ Avatar answered Oct 13 '22 13:10

CharithJ